preliminary/isolated opengl es support, requires USE_EGL/Makefile changes and es headers
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3734 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
456e13bf81
commit
40a18f65bb
7 changed files with 360 additions and 50 deletions
|
@ -616,6 +616,9 @@ void GLDraw_TransPicTranslate (int x, int y, int width, int height, qbyte *pic,
|
|||
qbyte *src;
|
||||
int p;
|
||||
|
||||
if (gl_config.gles)
|
||||
return; // TODO: NOT FIXED YET
|
||||
|
||||
GL_Bind (translate_texture);
|
||||
|
||||
c = width * height;
|
||||
|
@ -654,6 +657,9 @@ void GLDraw_TransPicTranslate (int x, int y, int width, int height, qbyte *pic,
|
|||
|
||||
void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b)
|
||||
{
|
||||
if (gl_config.gles)
|
||||
return; //TODO: DRAW FILL NOT FIXED YET
|
||||
|
||||
qglDisable (GL_TEXTURE_2D);
|
||||
qglColor3f (r, g, b);
|
||||
|
||||
|
@ -1514,7 +1520,11 @@ void GL_Upload32_Int (char *name, unsigned *data, int width, int height, unsigne
|
|||
if (scaled_width * scaled_height > sizeofuploadmemorybuffer/4)
|
||||
Sys_Error ("GL_LoadTexture: too big");
|
||||
|
||||
samples = (flags&IF_NOALPHA) ? GL_RGB : GL_RGBA;
|
||||
if (gl_config.gles)
|
||||
samples = GL_RGBA; /* GL ES doesn't allow for format conversion */
|
||||
else
|
||||
samples = (flags&IF_NOALPHA) ? GL_RGB : GL_RGBA;
|
||||
|
||||
if (gl_config.arb_texture_compression && gl_compress.value && name && !(flags&IF_NOMIPMAP))
|
||||
samples = (flags&IF_NOALPHA) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
|
||||
|
||||
|
|
|
@ -254,7 +254,9 @@ void Font_Init(void)
|
|||
|
||||
fontplanes.shader = R_RegisterShader("ftefont",
|
||||
"{\n"
|
||||
// "program default2d\n"
|
||||
#ifdef USE_EGL
|
||||
"program default2d\n"
|
||||
#endif
|
||||
"nomipmaps\n"
|
||||
"{\n"
|
||||
"map $diffuse\n"
|
||||
|
|
|
@ -795,8 +795,11 @@ struct sbuiltin_s
|
|||
gles versioning started at 100 and only had a single one defined
|
||||
with gl3's combined support, gl3 supports 130+ and 100, but 110 requries compat extension
|
||||
with gl4, versions are meant to match the gl version more closely, so gl4.0 uses 400.*/
|
||||
/*glsl es shaders require precisions to be defined for fragment shader variables
|
||||
more precision for shaders would be a good candidate for a cvar */
|
||||
{QR_OPENGL/*ES*/, 100, "default2d",
|
||||
"#version 100\n"
|
||||
//SGX requires #version to come before defines
|
||||
//"#version 100\n"
|
||||
"#ifdef VERTEX_SHADER\n"
|
||||
"uniform mat4 m_view;\n"
|
||||
"uniform mat4 m_projection;\n"
|
||||
|
@ -816,8 +819,8 @@ struct sbuiltin_s
|
|||
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"uniform sampler2D s_t0;\n"
|
||||
"in vec2 tc;\n"
|
||||
"varying vec4 vc;\n"
|
||||
"varying mediump vec2 tc;\n"
|
||||
"varying lowp vec4 vc;\n"
|
||||
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
|
@ -889,7 +892,7 @@ struct sbuiltin_s
|
|||
},
|
||||
{QR_OPENGL/*ES*/, 100, "defaultwall",
|
||||
"!!permu FULLBRIGHT\n"
|
||||
"#version 100\n"
|
||||
//"#version 100\n"
|
||||
"#ifdef VERTEX_SHADER\n"
|
||||
"uniform mat4 m_modelview;\n"
|
||||
"uniform mat4 m_projection;\n"
|
||||
|
@ -914,7 +917,7 @@ struct sbuiltin_s
|
|||
"#ifdef FULLBRIGHT\n"
|
||||
"uniform sampler2D s_t4;\n" /*tex_fullbright*/
|
||||
"#endif\n"
|
||||
"varying vec2 tc, lm;\n"
|
||||
"varying mediump vec2 tc, lm;\n"
|
||||
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
|
@ -926,8 +929,8 @@ struct sbuiltin_s
|
|||
"#endif\n"
|
||||
},
|
||||
{QR_OPENGL/*ES*/, 100, "defaultwarp",
|
||||
"#version 100\n"
|
||||
"varying vec2 tc;\n"
|
||||
//"#version 100\n"
|
||||
"varying mediump vec2 tc;\n"
|
||||
"#ifdef VERTEX_SHADER\n"
|
||||
"uniform mat4 m_modelview;\n"
|
||||
"uniform mat4 m_projection;\n"
|
||||
|
@ -942,15 +945,15 @@ struct sbuiltin_s
|
|||
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"uniform sampler2D watertexture;\n"
|
||||
"uniform float e_time;\n"
|
||||
"uniform float wateralpha;\n"
|
||||
"uniform mediump float e_time;\n"
|
||||
"uniform lowp float wateralpha;\n"
|
||||
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" vec2 ntc;\n"
|
||||
" mediump vec2 ntc;\n"
|
||||
" ntc.s = tc.s + sin(tc.t+e_time)*0.125;\n"
|
||||
" ntc.t = tc.t + sin(tc.s+e_time)*0.125;\n"
|
||||
" vec3 ts = vec3(texture2D(watertexture, ntc));\n"
|
||||
" lowp vec3 ts = vec3(texture2D(watertexture, ntc));\n"
|
||||
|
||||
" gl_FragColor = vec4(ts, wateralpha);\n"
|
||||
"}\n"
|
||||
|
@ -984,7 +987,7 @@ struct sbuiltin_s
|
|||
"#endif\n"
|
||||
},
|
||||
{QR_OPENGL/*ES*/, 100, "defaultsky",
|
||||
"#version 100\n"
|
||||
//"#version 100\n"
|
||||
"#ifdef VERTEX_SHADER\n"
|
||||
"uniform mat4 m_modelview;\n"
|
||||
"uniform mat4 m_projection;\n"
|
||||
|
@ -1002,24 +1005,24 @@ struct sbuiltin_s
|
|||
"uniform sampler2D s_t0;\n"
|
||||
"uniform sampler2D s_t1;\n"
|
||||
|
||||
"uniform float e_time;\n"
|
||||
"uniform vec3 eyepos;\n"
|
||||
"varying vec3 pos;\n"
|
||||
"uniform mediump float e_time;\n"
|
||||
"uniform mediump vec3 eyepos;\n"
|
||||
"varying mediump vec3 pos;\n"
|
||||
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" vec2 tccoord;\n"
|
||||
" mediump vec2 tccoord;\n"
|
||||
|
||||
" vec3 dir = pos - eyepos;\n"
|
||||
" mediump vec3 dir = pos - eyepos;\n"
|
||||
|
||||
" dir.z *= 3.0;\n"
|
||||
" dir.xy /= 0.5*length(dir);\n"
|
||||
|
||||
" tccoord = (dir.xy + e_time*0.03125);\n"
|
||||
" vec3 solid = vec3(texture2D(s_t0, tccoord));\n"
|
||||
" lowp vec3 solid = vec3(texture2D(s_t0, tccoord));\n"
|
||||
|
||||
" tccoord = (dir.xy + e_time*0.0625);\n"
|
||||
" vec4 clouds = texture2D(s_t1, tccoord);\n"
|
||||
" lowp vec4 clouds = texture2D(s_t1, tccoord);\n"
|
||||
|
||||
" gl_FragColor.rgb = (solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb);\n"
|
||||
// " gl_FragColor.rgb = solid.rgb;/*gl_FragColor.g = clouds.r;*/gl_FragColor.b = clouds.a;\n"
|
||||
|
@ -1069,7 +1072,7 @@ struct sbuiltin_s
|
|||
"!!permu FULLBRIGHT\n"
|
||||
"!!permu LOWER\n"
|
||||
"!!permu UPPER\n"
|
||||
"#version 100\n"
|
||||
//"#version 100\n"
|
||||
"#ifdef VERTEX_SHADER\n"
|
||||
"uniform mat4 m_modelview;\n"
|
||||
"uniform mat4 m_projection;\n"
|
||||
|
@ -1095,17 +1098,17 @@ struct sbuiltin_s
|
|||
"uniform sampler2D s_t0;\n" /*tex_diffuse*/
|
||||
"#ifdef LOWER\n"
|
||||
"uniform sampler2D s_t1;\n" /*tex_lower*/
|
||||
"uniform vec3 e_lowercolour;\n"
|
||||
"uniform lowp vec3 e_lowercolour;\n"
|
||||
"#endif\n"
|
||||
"#ifdef UPPER\n"
|
||||
"uniform sampler2D s_t2;\n" /*tex_upper*/
|
||||
"uniform vec3 e_uppercolour;\n"
|
||||
"uniform lowp vec3 e_uppercolour;\n"
|
||||
"#endif\n"
|
||||
"#ifdef FULLBRIGHT\n"
|
||||
"uniform sampler2D s_t3;\n" /*tex_fullbright*/
|
||||
"#endif\n"
|
||||
"varying vec2 tc;\n"
|
||||
"varying vec3 light;\n"
|
||||
"varying mediump vec2 tc;\n"
|
||||
"varying lowp vec3 light;\n"
|
||||
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
|
@ -1141,6 +1144,7 @@ static void Shader_LoadGeneric(union programhandle_u *shader, char *name, int qr
|
|||
{
|
||||
unsigned int i;
|
||||
void *file;
|
||||
|
||||
sgeneric_t *g;
|
||||
for (g = sgenerics; g; g = g->next)
|
||||
{
|
||||
|
@ -3584,7 +3588,9 @@ void Shader_Default2D(char *shortname, shader_t *s, const void *genargs)
|
|||
{
|
||||
Shader_DefaultScript(shortname, s,
|
||||
"{\n"
|
||||
// "program default2d\n"
|
||||
#ifdef USE_EGL
|
||||
"program default2d\n"
|
||||
#endif
|
||||
"nomipmaps\n"
|
||||
"{\n"
|
||||
"clampmap $diffuse\n"
|
||||
|
|
|
@ -333,6 +333,10 @@ void APIENTRY GL_BindBufferARBStub(GLenum target, GLuint id)
|
|||
{
|
||||
}
|
||||
|
||||
void APIENTRY GL_ClientStateStub(GLenum array)
|
||||
{
|
||||
}
|
||||
|
||||
#define getglcore getglfunction
|
||||
#define getglext(name) getglfunction(name)
|
||||
void GL_CheckExtensions (void *(*getglfunction) (char *name), float ver)
|
||||
|
@ -943,13 +947,12 @@ void GL_Init(void *(*getglfunction) (char *name))
|
|||
qglEndList = (void*)getglcore("glEndList");
|
||||
qglCallList = (void*)getglcore("glCallList");
|
||||
|
||||
qglBindBufferARB = (void *)getglext("qglBindBufferARB");
|
||||
qglBindBufferARB = (void *)getglext("glBindBufferARB");
|
||||
if (!qglBindBufferARB)
|
||||
qglBindBufferARB = (void *)getglext("qglBindBuffer");
|
||||
qglBindBufferARB = (void *)getglext("glBindBuffer");
|
||||
if (!qglBindBufferARB)
|
||||
qglBindBufferARB = GL_BindBufferARBStub;
|
||||
|
||||
|
||||
gl_vendor = qglGetString (GL_VENDOR);
|
||||
Con_SafePrintf ("GL_VENDOR: %s\n", gl_vendor);
|
||||
gl_renderer = qglGetString (GL_RENDERER);
|
||||
|
@ -1014,8 +1017,8 @@ void GL_Init(void *(*getglfunction) (char *name))
|
|||
qglShadeModel = NULL;
|
||||
qglDepthRange = NULL;
|
||||
|
||||
qglEnableClientState = NULL;
|
||||
qglDisableClientState = NULL;
|
||||
qglEnableClientState = GL_ClientStateStub;
|
||||
qglDisableClientState = GL_ClientStateStub;
|
||||
|
||||
qglDrawRangeElements = GL_DrawRangeElementsEmul;
|
||||
}
|
||||
|
|
232
engine/gl/gl_vidgles.c
Normal file
232
engine/gl/gl_vidgles.c
Normal file
|
@ -0,0 +1,232 @@
|
|||
#include "gl_vidgles.h"
|
||||
|
||||
EGLContext eglctx = EGL_NO_CONTEXT;
|
||||
EGLDisplay egldpy = EGL_NO_DISPLAY;
|
||||
EGLSurface eglsurf = EGL_NO_SURFACE;
|
||||
|
||||
static void *egllibrary;
|
||||
static void *eslibrary;
|
||||
|
||||
static EGLint (*qeglGetError)(void);
|
||||
|
||||
static EGLDisplay (*qeglGetDisplay)(EGLNativeDisplayType display_id);
|
||||
static EGLBoolean (*qeglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
static EGLBoolean (*qeglTerminate)(EGLDisplay dpy);
|
||||
|
||||
static EGLBoolean (*qeglGetConfigs)(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
static EGLBoolean (*qeglChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
|
||||
static EGLSurface (*qeglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
|
||||
static EGLBoolean (*qeglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
|
||||
static EGLBoolean (*qeglQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
|
||||
|
||||
static EGLBoolean (*qeglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
|
||||
static EGLBoolean (*qeglMakeCurrent)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
static EGLContext (*qeglCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
|
||||
static EGLBoolean (*qeglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
|
||||
static void *(*qeglGetProcAddress) (char *name);
|
||||
|
||||
/*
|
||||
static dllfunction_t qeglfuncs[] =
|
||||
{
|
||||
{(void*)&qeglGetError, "eglGetError"},
|
||||
{(void*)&qeglInitialize, "eglInitialize"},
|
||||
{(void*)&qeglTerminate, "eglTerminate"},
|
||||
|
||||
{(void*)&qeglGetConfigs, "eglGetConfigs"},
|
||||
{(void*)&qeglChooseConfig, "eglChooseConfig"},
|
||||
|
||||
{(void*)&qeglCreateWindowSurface, "eglCreateWindowSurface"},
|
||||
{(void*)&qeglDestroySurface, "eglDestroySurface"},
|
||||
{(void*)&qeglQuerySurface, "eglQuerySurface"},
|
||||
|
||||
{(void*)&qeglSwapBuffers, "eglSwapBuffers"},
|
||||
{(void*)&qeglMakeCurrent, "eglMakeCurrent"},
|
||||
{(void*)&qeglCreateContext, "eglCreateContext"},
|
||||
{(void*)&qeglDestroyContext, "eglDestroyContext"},
|
||||
|
||||
{(void*)&qeglGetProcAddress, "eglGetProcAddress"},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
*/
|
||||
|
||||
void *EGL_Proc(char *f)
|
||||
{
|
||||
void *proc = NULL;
|
||||
|
||||
/*
|
||||
char fname[512];
|
||||
{
|
||||
sprintf(fname, "wrap_%s", f);
|
||||
f = fname;
|
||||
}
|
||||
*/
|
||||
|
||||
if (qeglGetProcAddress)
|
||||
proc = qeglGetProcAddress(f);
|
||||
if (!proc)
|
||||
proc = dlsym(eslibrary, f);
|
||||
if (!proc)
|
||||
proc = dlsym(egllibrary, f);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
void EGL_UnloadLibrary(void)
|
||||
{
|
||||
if (egllibrary)
|
||||
dlclose(egllibrary);
|
||||
if (egllibrary == eslibrary)
|
||||
eslibrary = NULL;
|
||||
if (eslibrary)
|
||||
dlclose(eslibrary);
|
||||
eslibrary = egllibrary = NULL;
|
||||
}
|
||||
|
||||
qboolean EGL_LoadLibrary(char *driver)
|
||||
{
|
||||
/* ignore driver for now */
|
||||
egllibrary = dlopen("libEGL.so", RTLD_LAZY);
|
||||
if (!egllibrary)
|
||||
return false;
|
||||
|
||||
/*eslibrary = dlopen("GLESwrap.so", RTLD_LAZY);*/
|
||||
eslibrary = dlopen("libGLESv2.so", RTLD_LAZY);
|
||||
if (!eslibrary)
|
||||
return false;
|
||||
|
||||
qeglGetError = dlsym(egllibrary, "eglGetError");
|
||||
|
||||
qeglGetDisplay = dlsym(egllibrary, "eglGetDisplay");
|
||||
qeglInitialize = dlsym(egllibrary, "eglInitialize");
|
||||
qeglTerminate = dlsym(egllibrary, "eglTerminate");
|
||||
|
||||
qeglGetConfigs = dlsym(egllibrary, "eglGetConfigs");
|
||||
qeglChooseConfig = dlsym(egllibrary, "eglChooseConfig");
|
||||
|
||||
qeglCreateWindowSurface = dlsym(egllibrary, "eglCreateWindowSurface");
|
||||
qeglDestroySurface = dlsym(egllibrary, "eglDestroySurface");
|
||||
qeglQuerySurface = dlsym(egllibrary, "eglQuerySurface");
|
||||
|
||||
qeglSwapBuffers = dlsym(egllibrary, "eglSwapBuffers");
|
||||
qeglMakeCurrent = dlsym(egllibrary, "eglMakeCurrent");
|
||||
qeglCreateContext = dlsym(egllibrary, "eglCreateContext");
|
||||
qeglDestroyContext = dlsym(egllibrary, "eglDestroyContext");
|
||||
|
||||
qeglGetProcAddress = dlsym(egllibrary, "eglGetProcAddress");
|
||||
|
||||
// TODO: properly unload on error
|
||||
if (!qeglGetError || !qeglGetDisplay || !qeglInitialize || !qeglTerminate || !qeglCreateWindowSurface ||
|
||||
!qeglDestroySurface || !qeglGetConfigs || !qeglChooseConfig || !qeglQuerySurface ||
|
||||
!qeglSwapBuffers || !qeglMakeCurrent || !qeglCreateContext || !qeglDestroyContext ||
|
||||
!qeglGetProcAddress)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EGL_Shutdown(void)
|
||||
{
|
||||
if (eglctx == EGL_NO_CONTEXT)
|
||||
return;
|
||||
|
||||
qeglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
qeglDestroyContext(egldpy, eglctx);
|
||||
|
||||
if (eglsurf != EGL_NO_SURFACE)
|
||||
qeglDestroySurface(egldpy, eglsurf);
|
||||
|
||||
qeglTerminate(egldpy);
|
||||
|
||||
eglctx = EGL_NO_CONTEXT;
|
||||
egldpy = EGL_NO_DISPLAY;
|
||||
eglsurf = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
void EGL_BeginRendering (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void EGL_EndRendering (void)
|
||||
{
|
||||
qeglSwapBuffers(egldpy, eglsurf);
|
||||
/* TODO: check result? */
|
||||
}
|
||||
|
||||
qboolean EGL_Init (rendererstate_t *info, unsigned char *palette, EGLNativeWindowType window)
|
||||
{
|
||||
EGLint numconfig;
|
||||
EGLConfig cfg;
|
||||
EGLint attrib[] =
|
||||
{
|
||||
EGL_BUFFER_SIZE, info->bpp,
|
||||
EGL_SAMPLES, info->multisample,
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
EGL_ALPHA_MASK_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint contextattr[] =
|
||||
{
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE, EGL_NONE
|
||||
};
|
||||
|
||||
if (!EGL_LoadLibrary(""))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: unable to load library!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
egldpy = qeglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (egldpy == EGL_NO_DISPLAY)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't get display!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!qeglInitialize(egldpy, NULL, NULL))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't initialize display!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!qeglGetConfigs(egldpy, NULL, 0, &numconfigs) || !numconfigs)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't get configs!");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!qeglChooseConfig(egldpy, attrib, &cfg, 1, &numconfig))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't choose config!");
|
||||
return false;
|
||||
}
|
||||
|
||||
eglsurf = qeglCreateWindowSurface(egldpy, cfg, window, NULL);
|
||||
if (eglsurf == EGL_NO_SURFACE)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: no surface!");
|
||||
return false;
|
||||
}
|
||||
|
||||
eglctx = qeglCreateContext(egldpy, cfg, EGL_NO_SURFACE, contextattr);
|
||||
if (eglctx == EGL_NO_CONTEXT)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: no context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!qeglMakeCurrent(egldpy, eglsurf, eglsurf, eglctx))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't make current!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
16
engine/gl/gl_vidgles.h
Normal file
16
engine/gl/gl_vidgles.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __GL_VIDGLES_H__
|
||||
#define __GL_VIDGLES_H__
|
||||
|
||||
#include "quakedef.h"
|
||||
#include <EGL/egl.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
void *EGL_Proc(char *f);
|
||||
void EGL_UnloadLibrary(void);
|
||||
qboolean EGL_LoadLibrary(char *driver);
|
||||
void EGL_Shutdown(void);
|
||||
void EGL_BeginRendering (void);
|
||||
void EGL_EndRendering (void);
|
||||
qboolean EGL_Init (rendererstate_t *info, unsigned char *palette, EGLNativeWindowType window);
|
||||
|
||||
#endif
|
|
@ -33,12 +33,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "glquake.h"
|
||||
|
||||
#include <GL/glx.h>
|
||||
#ifdef USE_EGL
|
||||
#include "gl_vidgles.h"
|
||||
#endif
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#ifdef USE_DGA
|
||||
#include <X11/extensions/xf86dga.h>
|
||||
#include <X11/extensions/Xxf86dga.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -148,7 +151,6 @@ qboolean GLX_InitLibrary(char *driver)
|
|||
qglXMakeCurrent = dlsym(gllibrary, "glXMakeCurrent");
|
||||
qglXCreateContext = dlsym(gllibrary, "glXCreateContext");
|
||||
qglXDestroyContext = dlsym(gllibrary, "glXDestroyContext");
|
||||
qglXDestroyContext = dlsym(gllibrary, "glXDestroyContext");
|
||||
qglXGetProcAddress = dlsym(gllibrary, "glXGetProcAddress");
|
||||
if (!qglXGetProcAddress)
|
||||
qglXGetProcAddress = dlsym(gllibrary, "glXGetProcAddressARB");
|
||||
|
@ -585,6 +587,9 @@ static void GetEvent(void)
|
|||
|
||||
void GLVID_Shutdown(void)
|
||||
{
|
||||
#ifdef USE_EGL
|
||||
EGL_Shutdown();
|
||||
#else
|
||||
printf("GLVID_Shutdown\n");
|
||||
if (!ctx)
|
||||
return;
|
||||
|
@ -618,6 +623,7 @@ void GLVID_Shutdown(void)
|
|||
XCloseDisplay(vid_dpy);
|
||||
vid_dpy = NULL;
|
||||
vid_window = (Window)NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLVID_DeInit(void) //FIXME:....
|
||||
|
@ -730,15 +736,22 @@ GL_BeginRendering
|
|||
*/
|
||||
void GL_BeginRendering (void)
|
||||
{
|
||||
#ifdef USE_EGL
|
||||
EGL_BeginRendering();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
#ifdef USE_EGL
|
||||
EGL_EndRendering();
|
||||
#else
|
||||
//return;
|
||||
//we don't need the flush, XSawpBuffers does it for us.
|
||||
//chances are, it's version is more suitable anyway. At least there's the chance that it might be.
|
||||
qglXSwapBuffers(vid_dpy, vid_window);
|
||||
#endif
|
||||
}
|
||||
|
||||
qboolean GLVID_Is8bit(void)
|
||||
|
@ -762,6 +775,9 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
#ifdef USE_EGL
|
||||
XVisualInfo vinfodef;
|
||||
#endif
|
||||
XVisualInfo *visinfo;
|
||||
qboolean fullscreen = false;
|
||||
Atom prots[1];
|
||||
|
@ -776,11 +792,19 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
|
||||
S_Startup();
|
||||
|
||||
#ifdef USE_EGL
|
||||
if (!EGL_LoadLibrary(info->glrenderer))
|
||||
{
|
||||
Con_Printf("couldn't load EGL library\n");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (!GLX_InitLibrary(info->glrenderer))
|
||||
{
|
||||
Con_Printf("Couldn't intialise GLX\nEither your drivers are not installed or you need to specify the library name with the gl_driver cvar\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
vid.colormap = host_colormap;
|
||||
|
||||
|
@ -828,12 +852,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
}
|
||||
#endif
|
||||
|
||||
visinfo = qglXChooseVisual(vid_dpy, scrnum, attrib);
|
||||
if (!visinfo)
|
||||
{
|
||||
Sys_Error("qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
|
||||
}
|
||||
|
||||
#ifdef WITH_VMODE
|
||||
vidmode_usemode = -1;
|
||||
if (vidmode_ext)
|
||||
|
@ -880,6 +898,21 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
|
||||
vidglx_fullscreen = fullscreen;
|
||||
|
||||
#ifdef USE_EGL
|
||||
visinfo = &vinfodef;
|
||||
if (!XMatchVisualInfo(vid_dpy, scrnum, info->bpp, TrueColor, visinfo))
|
||||
// if (!XMatchVisualInfo(vid_dpy, scrnum, DefaultDepth(vid_dpy, scrnum), TrueColor, &visinfo))
|
||||
{
|
||||
Sys_Error("Couldn't choose visual for EGL\n");
|
||||
}
|
||||
#else
|
||||
visinfo = qglXChooseVisual(vid_dpy, scrnum, attrib);
|
||||
if (!visinfo)
|
||||
{
|
||||
Sys_Error("qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
|
@ -898,10 +931,11 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
}
|
||||
#endif
|
||||
|
||||
ActiveApp = false;
|
||||
vid_window = XCreateWindow(vid_dpy, root, 0, 0, info->width, info->height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
|
||||
ActiveApp = false;
|
||||
/*ask the window manager to stop triggering bugs in Xlib*/
|
||||
prots[0] = XInternAtom(vid_dpy, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(vid_dpy, vid_window, prots, sizeof(prots)/sizeof(prots[0]));
|
||||
|
@ -911,7 +945,7 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
XMapWindow(vid_dpy, vid_window);
|
||||
/*put it somewhere*/
|
||||
XMoveWindow(vid_dpy, vid_window, 0, 0);
|
||||
|
||||
|
||||
//XFree(visinfo);
|
||||
|
||||
#ifdef WITH_VMODE
|
||||
|
@ -929,6 +963,7 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
|
||||
XFlush(vid_dpy);
|
||||
|
||||
#ifndef USE_EGL
|
||||
#ifdef WITH_VMODE
|
||||
if (vidmode_ext >= 2)
|
||||
{
|
||||
|
@ -961,6 +996,20 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
return false;
|
||||
}
|
||||
|
||||
GL_Init(&GLX_GetSymbol);
|
||||
|
||||
#else
|
||||
EGL_Init(info, palette, vid_window);
|
||||
GL_Init(&EGL_Proc);
|
||||
#endif
|
||||
|
||||
GLVID_SetPalette(palette);
|
||||
GLVID_ShiftPalette(palette);
|
||||
|
||||
qglGetIntegerv(GL_STENCIL_BITS, &gl_canstencil);
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
vid.pixelwidth = info->width;
|
||||
vid.pixelheight = info->height;
|
||||
|
||||
|
@ -971,14 +1020,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
|
|||
|
||||
vid.numpages = 2;
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
GL_Init(&GLX_GetSymbol);
|
||||
qglGetIntegerv(GL_STENCIL_BITS, &gl_canstencil);
|
||||
|
||||
GLVID_SetPalette(palette);
|
||||
GLVID_ShiftPalette(palette);
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", info->width, info->height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
|
|
Loading…
Reference in a new issue