Browse Source

[sdl] dynamically load all GL functions (#806)

Zeta 1 tháng trước cách đây
mục cha
commit
40f146801c
2 tập tin đã thay đổi với 47 bổ sung3 xóa
  1. 45 0
      libs/sdl/GLImports.h
  2. 2 3
      libs/sdl/gl.c

+ 45 - 0
libs/sdl/GLImports.h

@@ -1,4 +1,49 @@
+#ifndef GL_IMPORT
+#define GL_IMPORT(fun, ty)
+#endif
 #ifndef __APPLE__
+#ifndef _WIN32
+GL_IMPORT(glClear, CLEAR);
+GL_IMPORT(glGetError, GETERROR);
+GL_IMPORT(glEnable, ENABLE);
+GL_IMPORT(glDisable, DISABLE);
+GL_IMPORT(glScissor, SCISSOR);
+GL_IMPORT(glClearColor, CLEARCOLOR);
+GL_IMPORT(glClearDepth, CLEARDEPTH);
+GL_IMPORT(glClearStencil, CLEARSTENCIL);
+GL_IMPORT(glViewport, VIEWPORT);
+GL_IMPORT(glFlush, FLUSH);
+GL_IMPORT(glFinish, FINISH);
+GL_IMPORT(glGetString, GETSTRING);
+GL_IMPORT(glPixelStorei, PIXELSTOREI);
+GL_IMPORT(glPolygonMode, POLYGONMODE);
+GL_IMPORT(glPolygonOffset, POLYGONMODE);
+GL_IMPORT(glCullFace, CULLFACE);
+GL_IMPORT(glBlendFunc, BLENDFUNC);
+GL_IMPORT(glBlendEquation, BLENDEQUATION);
+GL_IMPORT(glDepthMask, DEPTHMASK);
+GL_IMPORT(glDepthFunc, DEPTHFUNC);
+GL_IMPORT(glColorMask, COLORMASK);
+GL_IMPORT(glGenTextures, GENTEXTURES);
+GL_IMPORT(glActiveTexture, ACTIVETEXTURE);
+GL_IMPORT(glBindTexture, BINDTEXTURE);
+GL_IMPORT(glTexParameterf, TEXPARAMETERF);
+GL_IMPORT(glTexParameteri, TEXPARAMETERI);
+GL_IMPORT(glTexImage2D, TEXIMAGE2D);
+GL_IMPORT(glTexImage3D, TEXIMAGE3D);
+GL_IMPORT(glCompressedTexImage2D, COMPRESSEDTEXIMAGE2D);
+GL_IMPORT(glCompressedTexImage3D, COMPRESSEDTEXIMAGE3D);
+GL_IMPORT(glTexSubImage2D, TEXSUBIMAGE2D);
+GL_IMPORT(glTexSubImage3D, TEXSUBIMAGE3D);
+GL_IMPORT(glCompressedTexSubImage2D, COMPRESSEDTEXSUBIMAGE2D);
+GL_IMPORT(glCompressedTexSubImage3D, COMPRESSEDTEXSUBIMAGE3D);
+GL_IMPORT(glDeleteTextures, DELETETEXTURES);
+GL_IMPORT(glReadPixels, READPIXELS);
+GL_IMPORT(glReadBuffer, READBUFFER);
+GL_IMPORT(glDrawElements, DRAWELEMENTS);
+GL_IMPORT(glDrawArrays, DRAWARRAYS);
+GL_IMPORT(glGetIntegerv, GETINTEGERV);
+#endif
 GL_IMPORT(glCreateProgram, CREATEPROGRAM);
 GL_IMPORT(glDeleteProgram, DELETEPROGRAM);
 GL_IMPORT(glLinkProgram, LINKPROGRAM);

+ 2 - 3
libs/sdl/gl.c

@@ -15,7 +15,7 @@
 #	define glMemoryBarrier(...) hl_error("Not supported on OSX")
 #elif defined(_WIN32)
 #	include <SDL.h>
-#	include <GL/GLU.h>
+#	include <GL/GL.h>
 #	include <glext.h>
 #elif defined(HL_CONSOLE)
 #	include <graphic/glapi.h>
@@ -30,8 +30,7 @@
 #	define HL_GLES
 #else
 #	include <SDL2/SDL.h>
-#	include <GL/glu.h>
-#	include <GL/glext.h>
+#	include <GL/glcorearb.h>
 #endif
 
 #ifdef HL_GLES