mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-07 03:04:05 +00:00
[client] all: move all SDL specific code into displayservers/sdl
This commit is contained in:
@@ -33,7 +33,6 @@ make_object(
|
||||
|
||||
add_library(renderer_EGL STATIC
|
||||
egl.c
|
||||
dynprocs.c
|
||||
egldebug.c
|
||||
shader.c
|
||||
texture.c
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "dynprocs.h"
|
||||
|
||||
struct EGLDynProcs g_dynprocs = {0};
|
||||
|
||||
void egl_dynProcsInit(void)
|
||||
{
|
||||
g_dynprocs.eglGetPlatformDisplay = (eglGetPlatformDisplayEXT_t)
|
||||
eglGetProcAddress("eglGetPlatformDisplay");
|
||||
g_dynprocs.eglGetPlatformDisplayEXT = (eglGetPlatformDisplayEXT_t)
|
||||
eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
g_dynprocs.glEGLImageTargetTexture2DOES = (glEGLImageTargetTexture2DOES_t)
|
||||
eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
};
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <SDL2/SDL_egl.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
typedef EGLDisplay (*eglGetPlatformDisplayEXT_t)(EGLenum platform,
|
||||
void *native_display, const EGLint *attrib_list);
|
||||
typedef void (*glEGLImageTargetTexture2DOES_t)(GLenum target,
|
||||
GLeglImageOES image);
|
||||
|
||||
struct EGLDynProcs
|
||||
{
|
||||
eglGetPlatformDisplayEXT_t eglGetPlatformDisplay;
|
||||
eglGetPlatformDisplayEXT_t eglGetPlatformDisplayEXT;
|
||||
glEGLImageTargetTexture2DOES_t glEGLImageTargetTexture2DOES;
|
||||
};
|
||||
|
||||
extern struct EGLDynProcs g_dynprocs;
|
||||
|
||||
void egl_dynProcsInit(void);
|
@@ -27,17 +27,17 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "util.h"
|
||||
#include "dynamic/fonts.h"
|
||||
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <SDL2/SDL_egl.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
|
||||
#include <wayland-egl.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "dynprocs.h"
|
||||
#include "egl_dynprocs.h"
|
||||
#include "model.h"
|
||||
#include "shader.h"
|
||||
#include "desktop.h"
|
||||
@@ -208,7 +208,7 @@ bool egl_create(void ** opaque, const LG_RendererParams params)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool egl_initialize(void * opaque, Uint32 * sdlFlags)
|
||||
bool egl_initialize(void * opaque)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
DEBUG_INFO("Double buffering is %s", this->opt.doubleBuffer ? "on" : "off");
|
||||
@@ -482,73 +482,17 @@ void egl_on_alert(void * opaque, const LG_MsgAlert alert, const char * message,
|
||||
this->showAlert = true;
|
||||
}
|
||||
|
||||
bool egl_render_startup(void * opaque, SDL_Window * window)
|
||||
bool egl_render_startup(void * opaque)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
|
||||
SDL_SysWMinfo wminfo;
|
||||
SDL_VERSION(&wminfo.version);
|
||||
if (!SDL_GetWindowWMInfo(window, &wminfo))
|
||||
{
|
||||
DEBUG_ERROR("SDL_GetWindowWMInfo failed");
|
||||
this->nativeWind = app_getEGLNativeWindow();
|
||||
if (!this->nativeWind)
|
||||
return false;
|
||||
}
|
||||
|
||||
egl_dynProcsInit();
|
||||
|
||||
EGLNativeDisplayType native;
|
||||
EGLenum platform;
|
||||
|
||||
switch(wminfo.subsystem)
|
||||
{
|
||||
case SDL_SYSWM_X11:
|
||||
native = (EGLNativeDisplayType)wminfo.info.x11.display;
|
||||
platform = EGL_PLATFORM_X11_KHR;
|
||||
this->nativeWind = (EGLNativeWindowType)wminfo.info.x11.window;
|
||||
break;
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
|
||||
case SDL_SYSWM_WAYLAND:
|
||||
{
|
||||
int width, height;
|
||||
SDL_GetWindowSize(window, &width, &height);
|
||||
native = (EGLNativeDisplayType)wminfo.info.wl.display;
|
||||
platform = EGL_PLATFORM_WAYLAND_KHR;
|
||||
this->nativeWind = (EGLNativeWindowType)wl_egl_window_create(
|
||||
wminfo.info.wl.surface, width, height);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
DEBUG_ERROR("Unsupported subsystem");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *early_exts = eglQueryString(NULL, EGL_EXTENSIONS);
|
||||
if (strstr(early_exts, "EGL_KHR_platform_base") != NULL &&
|
||||
g_dynprocs.eglGetPlatformDisplay)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplay");
|
||||
this->display = g_dynprocs.eglGetPlatformDisplay(platform, native, NULL);
|
||||
}
|
||||
else if (strstr(early_exts, "EGL_EXT_platform_base") != NULL &&
|
||||
g_dynprocs.eglGetPlatformDisplayEXT)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplayEXT");
|
||||
this->display = g_dynprocs.eglGetPlatformDisplayEXT(platform, native, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_INFO("Using eglGetDisplay");
|
||||
this->display = eglGetDisplay(native);
|
||||
}
|
||||
|
||||
this->display = app_getEGLDisplay();
|
||||
if (this->display == EGL_NO_DISPLAY)
|
||||
{
|
||||
DEBUG_ERROR("eglGetDisplay failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
int maj, min;
|
||||
if (!eglInitialize(this->display, &maj, &min))
|
||||
@@ -639,7 +583,7 @@ bool egl_render_startup(void * opaque, SDL_Window * window)
|
||||
DEBUG_INFO("EGL APIs : %s", eglQueryString(this->display, EGL_CLIENT_APIS));
|
||||
DEBUG_INFO("Extensions: %s", client_exts);
|
||||
|
||||
if (g_dynprocs.glEGLImageTargetTexture2DOES)
|
||||
if (g_egl_dynProcs.glEGLImageTargetTexture2DOES)
|
||||
{
|
||||
if (strstr(client_exts, "EGL_EXT_image_dma_buf_import") != NULL)
|
||||
{
|
||||
@@ -697,7 +641,7 @@ bool egl_render_startup(void * opaque, SDL_Window * window)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool egl_render(void * opaque, SDL_Window * window, LG_RendererRotate rotate)
|
||||
bool egl_render(void * opaque, LG_RendererRotate rotate)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
|
||||
|
@@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "texture.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/framebuffer.h"
|
||||
#include "dynprocs.h"
|
||||
#include "egl_dynprocs.h"
|
||||
#include "egldebug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -393,7 +393,7 @@ bool egl_texture_update_from_dma(EGL_Texture * texture, const FrameBuffer * fram
|
||||
|
||||
/* bind the texture and initiate the transfer */
|
||||
glBindTexture(GL_TEXTURE_2D, texture->tex);
|
||||
g_dynprocs.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
g_egl_dynProcs.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
|
||||
/* wait for completion */
|
||||
framebuffer_wait(frame, texture->height * texture->stride);
|
||||
|
@@ -177,7 +177,7 @@ enum ConfigStatus
|
||||
};
|
||||
|
||||
static void deconfigure(struct Inst * this);
|
||||
static enum ConfigStatus configure(struct Inst * this, SDL_Window *window);
|
||||
static enum ConfigStatus configure(struct Inst * this);
|
||||
static void update_mouse_shape(struct Inst * this, bool * newShape);
|
||||
static bool draw_frame(struct Inst * this);
|
||||
static void draw_mouse(struct Inst * this);
|
||||
@@ -235,8 +235,11 @@ bool opengl_create(void ** opaque, const LG_RendererParams params)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool opengl_initialize(void * opaque, Uint32 * sdlFlags)
|
||||
bool opengl_initialize(void * opaque)
|
||||
{
|
||||
//FIXME
|
||||
return false;
|
||||
#if 0
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
if (!this)
|
||||
return false;
|
||||
@@ -252,6 +255,7 @@ bool opengl_initialize(void * opaque, Uint32 * sdlFlags)
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE , 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void opengl_deinitialize(void * opaque)
|
||||
@@ -492,16 +496,17 @@ void bitmap_to_texture(LG_FontBitmap * bitmap, GLuint texture)
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
bool opengl_render_startup(void * opaque, SDL_Window * window)
|
||||
bool opengl_render_startup(void * opaque)
|
||||
{
|
||||
//FIXME
|
||||
return false;
|
||||
#if 0
|
||||
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
|
||||
this->glContext = SDL_GL_CreateContext(window);
|
||||
this->glContext = app_getGLContext();
|
||||
if (!this->glContext)
|
||||
{
|
||||
DEBUG_ERROR("Failed to create the OpenGL context");
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_INFO("Vendor : %s", glGetString(GL_VENDOR ));
|
||||
DEBUG_INFO("Renderer: %s", glGetString(GL_RENDERER));
|
||||
@@ -549,15 +554,16 @@ bool opengl_render_startup(void * opaque, SDL_Window * window)
|
||||
SDL_GL_SetSwapInterval(this->opt.vsync ? 1 : 0);
|
||||
this->renderStarted = true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool opengl_render(void * opaque, SDL_Window * window, LG_RendererRotate rotate)
|
||||
bool opengl_render(void * opaque, LG_RendererRotate rotate)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
if (!this)
|
||||
return false;
|
||||
|
||||
switch(configure(this, window))
|
||||
switch(configure(this))
|
||||
{
|
||||
case CONFIG_STATUS_ERROR:
|
||||
DEBUG_ERROR("configure failed");
|
||||
@@ -657,11 +663,11 @@ bool opengl_render(void * opaque, SDL_Window * window, LG_RendererRotate rotate)
|
||||
|
||||
if (this->opt.preventBuffer)
|
||||
{
|
||||
SDL_GL_SwapWindow(window);
|
||||
app_glSwapBuffers();
|
||||
glFinish();
|
||||
}
|
||||
else
|
||||
SDL_GL_SwapWindow(window);
|
||||
app_glSwapBuffers();
|
||||
|
||||
this->mouseUpdate = false;
|
||||
return true;
|
||||
@@ -879,7 +885,7 @@ static bool _check_gl_error(unsigned int line, const char * name)
|
||||
return true;
|
||||
}
|
||||
|
||||
static enum ConfigStatus configure(struct Inst * this, SDL_Window *window)
|
||||
static enum ConfigStatus configure(struct Inst * this)
|
||||
{
|
||||
LG_LOCK(this->formatLock);
|
||||
if (!this->reconfigure)
|
||||
|
Reference in New Issue
Block a user