From 9f0570ef8a1bc26f3ca78d53a327ccf0e3b1b0ee Mon Sep 17 00:00:00 2001 From: Alexander Gusak Date: Fri, 5 Aug 2011 01:16:03 +0300 Subject: [PATCH] =?UTF-8?q?[win32,opengl]:=20Added=20two-variant=20OpenGL?= =?UTF-8?q?=20procedures=20loading=20=E2=80=94=20w/wo=20"EXT"=20suffix=20i?= =?UTF-8?q?n=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yg/internal/gl_procedures.inl | 32 +++++++++++++++++ yg/internal/opengl_win32.cpp | 67 +++++++---------------------------- yg/internal/opengl_win32.hpp | 25 +++---------- yg/yg.pro | 1 + 4 files changed, 49 insertions(+), 76 deletions(-) create mode 100644 yg/internal/gl_procedures.inl diff --git a/yg/internal/gl_procedures.inl b/yg/internal/gl_procedures.inl new file mode 100644 index 0000000000..123e5a91a9 --- /dev/null +++ b/yg/internal/gl_procedures.inl @@ -0,0 +1,32 @@ +// Intentionally no #pragma once + +// buffer objects extensions + +DEFINE_GL_PROC(PFNGLBINDBUFFERPROC, glBindBuffer) +DEFINE_GL_PROC(PFNGLGENBUFFERSPROC, glGenBuffers) +DEFINE_GL_PROC(PFNGLBUFFERDATAPROC, glBufferData) +DEFINE_GL_PROC(PFNGLBUFFERSUBDATAPROC, glBufferSubData) +DEFINE_GL_PROC(PFNGLDELETEBUFFERSPROC, glDeleteBuffers) +DEFINE_GL_PROC(PFNGLMAPBUFFERPROC, glMapBuffer) +DEFINE_GL_PROC(PFNGLUNMAPBUFFERPROC, glUnmapBuffer) + +// framebuffers extensions + +DEFINE_GL_PROC(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer) +DEFINE_GL_PROC(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D) +DEFINE_GL_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer) +DEFINE_GL_PROC(PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers) +DEFINE_GL_PROC(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers) +DEFINE_GL_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT) +DEFINE_GL_PROC(PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer) + +// renderbuffer extensions + +DEFINE_GL_PROC(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers) +DEFINE_GL_PROC(PFNGLDELETERENDERBUFFERSEXTPROC, glDeleteRenderbuffersEXT) +DEFINE_GL_PROC(PFNGLBINDRENDERBUFFEREXTPROC, glBindRenderbufferEXT) +DEFINE_GL_PROC(PFNGLRENDERBUFFERSTORAGEEXTPROC, glRenderbufferStorageEXT) + +// multisampling extensions + +DEFINE_GL_PROC(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample) diff --git a/yg/internal/opengl_win32.cpp b/yg/internal/opengl_win32.cpp index 2710dc6e52..db66c0af15 100644 --- a/yg/internal/opengl_win32.cpp +++ b/yg/internal/opengl_win32.cpp @@ -8,27 +8,10 @@ #ifdef OMIM_OS_WINDOWS -PFNGLBINDBUFFERPROC glBindBuffer; -PFNGLGENBUFFERSPROC glGenBuffers; -PFNGLBUFFERDATAPROC glBufferData; -PFNGLBUFFERSUBDATAPROC glBufferSubData; -PFNGLDELETEBUFFERSPROC glDeleteBuffers; -//PFNGLACTIVETEXTUREPROC glActiveTexture; -//PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; -PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; -PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; -PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; -PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; -PFNGLMAPBUFFERPROC glMapBuffer; -PFNGLUNMAPBUFFERPROC glUnmapBuffer; -PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; +#define DEFINE_GL_PROC(type, name) \ + type name; +#include "gl_procedures.inl" +#undef DEFINE_GL_PROC namespace win32 { @@ -48,15 +31,13 @@ namespace win32 { HMODULE hInst = 0; - /// buffer objects extensions - - glBindBuffer = GetGLProc(hInst, "glBindBuffer"); - glGenBuffers = GetGLProc(hInst, "glGenBuffers"); - glBufferData = GetGLProc(hInst, "glBufferData"); - glBufferSubData = GetGLProc(hInst, "glBufferSubData"); - glDeleteBuffers = GetGLProc(hInst, "glDeleteBuffers"); - glMapBuffer = GetGLProc(hInst, "glMapBuffer"); - glUnmapBuffer = GetGLProc(hInst, "glUnmapBuffer"); + // Loading procedures, trying "EXT" suffix if alias doesn't exist +#define DEFINE_GL_PROC(type, name) \ + name = GetGLProc(hInst, #name); \ + if (name == NULL) \ + name = GetGLProc(hInst, #name ## "EXT"); +#include "gl_procedures.inl" +#undef DEFINE_GL_PROC yg::gl::g_isBufferObjectsSupported = glBindBuffer && glGenBuffers @@ -66,19 +47,6 @@ namespace win32 && glMapBuffer && glUnmapBuffer; -// glActiveTexture = GetGLProc(hInst, "glActiveTexture"); -// glClientActiveTexture = GetGLProc(hInst, "glClientActiveTexture"); - - /// framebuffers extensions - - glBindFramebuffer = GetGLProc(hInst, "glBindFramebuffer"); - glFramebufferTexture2D = GetGLProc(hInst, "glFramebufferTexture2D"); - glFramebufferRenderbuffer = GetGLProc(hInst, "glFramebufferRenderbuffer"); - glGenFramebuffers = GetGLProc(hInst, "glGenFramebuffers"); - glDeleteFramebuffers = GetGLProc(hInst, "glDeleteFramebuffers"); - glCheckFramebufferStatusEXT = GetGLProc(hInst, "glCheckFramebufferStatusEXT"); - glBlitFramebuffer = GetGLProc(hInst, "glBlitFramebuffer"); - yg::gl::g_isFramebufferSupported = glBindFramebuffer && glFramebufferTexture2D && glFramebufferRenderbuffer @@ -87,24 +55,13 @@ namespace win32 && glCheckFramebufferStatusEXT && glBlitFramebuffer; - /// renderbuffer extensions - - glGenRenderbuffers = GetGLProc(hInst, "glGenRenderbuffers"); - glDeleteRenderbuffersEXT = GetGLProc(hInst, "glDeleteRenderbuffersEXT"); - glBindRenderbufferEXT = GetGLProc(hInst, "glBindRenderbufferEXT"); - glRenderbufferStorageEXT = GetGLProc(hInst, "glRenderbufferStorageEXT"); - yg::gl::g_isRenderbufferSupported = glGenRenderbuffers && glDeleteRenderbuffersEXT && glBindRenderbufferEXT && glRenderbufferStorageEXT; - /// multisampling extensions - - glRenderbufferStorageMultisample = GetGLProc(hInst, "glRenderbufferStorageMultisample"); - yg::gl::g_isMultisamplingSupported = (glRenderbufferStorageMultisample != NULL); } -} +} // namespace win32 #endif diff --git a/yg/internal/opengl_win32.hpp b/yg/internal/opengl_win32.hpp index dd883ff6db..980725e99b 100644 --- a/yg/internal/opengl_win32.hpp +++ b/yg/internal/opengl_win32.hpp @@ -8,27 +8,10 @@ #include #include "../../3party/GL/glext.h" -extern PFNGLBINDBUFFERPROC glBindBuffer; -extern PFNGLGENBUFFERSPROC glGenBuffers; -extern PFNGLBUFFERDATAPROC glBufferData; -extern PFNGLBUFFERSUBDATAPROC glBufferSubData; -extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -extern PFNGLACTIVETEXTUREPROC glActiveTexture; -extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; -extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; -extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; -extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; -extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; -extern PFNGLMAPBUFFERPROC glMapBuffer; -extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; -extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; +#define DEFINE_GL_PROC(type, name) \ + extern type name; +#include "gl_procedures.inl" +#undef DEFINE_GL_PROC namespace yg { diff --git a/yg/yg.pro b/yg/yg.pro index d460b06b59..ca3b5c8cec 100644 --- a/yg/yg.pro +++ b/yg/yg.pro @@ -61,6 +61,7 @@ SOURCES += \ HEADERS += \ internal/opengl.hpp \ + internal/gl_procedures.inl \ vertex.hpp \ resource_manager.hpp \ texture.hpp \