Browse Source

use get proc address for opengl extension functions

Eduardo Bart 10 years ago
parent
commit
f6dc07022c
3 changed files with 25 additions and 11 deletions
  1. 4
    2
      CMakeLists.txt
  2. 21
    8
      src/framework/framebuffer.cpp
  3. 0
    1
      src/framework/prerequisites.h

+ 4
- 2
CMakeLists.txt View File

@@ -48,16 +48,18 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
48 48
     ADD_DEFINITIONS(-D_DEBUG)
49 49
 ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
50 50
 
51
-# find sources
52 51
 SET(SOURCES
52
+# game sources
53
+    src/main.cpp
53 54
     src/menustate.cpp
55
+    
56
+# framework sources
54 57
     src/framework/framebuffer.cpp
55 58
     src/framework/textureloader.cpp
56 59
     src/framework/texture.cpp
57 60
     src/framework/texturemanager.cpp
58 61
     src/framework/configmanager.cpp
59 62
     src/framework/resourcemanager.cpp
60
-    src/main.cpp
61 63
     src/framework/engine.cpp
62 64
     src/framework/graphics.cpp
63 65
     src/framework/logger.cpp

+ 21
- 8
src/framework/framebuffer.cpp View File

@@ -25,6 +25,12 @@
25 25
 #include "platform.h"
26 26
 #include "graphics.h"
27 27
 
28
+PFNGLGENFRAMEBUFFERSEXTPROC         oglGenFramebuffersEXT = 0;
29
+PFNGLBINDFRAMEBUFFEREXTPROC         oglBindFramebufferEXT = 0;
30
+PFNGLFRAMEBUFFERTEXTURE2DEXTPROC    oglFramebufferTexture2DEXT = 0;
31
+PFNGLDELETEFRAMEBUFFERSEXTPROC      oglDeleteFramebuffersEXT = 0;
32
+PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC  oglCheckFramebufferStatusEXT = 0;
33
+
28 34
 FrameBuffer::FrameBuffer(int width, int height)
29 35
 {
30 36
     m_fbo = 0;
@@ -45,15 +51,22 @@ FrameBuffer::FrameBuffer(int width, int height)
45 51
     // use FBO ext only if supported
46 52
     if(Platform::isExtensionSupported("EXT_framebuffer_object")) {
47 53
         m_fallbackOldImp = false;
48
-
54
+        if(!oglGenFramebuffersEXT) {
55
+            oglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)Platform::getExtensionProcAddress("glGenFramebuffersEXT");
56
+            oglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)Platform::getExtensionProcAddress("glBindFramebufferEXT");
57
+            oglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)Platform::getExtensionProcAddress("glFramebufferTexture2DEXT");
58
+            oglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)Platform::getExtensionProcAddress("glDeleteFramebuffersEXT");
59
+            oglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)Platform::getExtensionProcAddress("glCheckFramebufferStatusEXT");
60
+        }
61
+        
49 62
         // generate FBO
50
-        glGenFramebuffersEXT(1, &m_fbo);
51
-        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
63
+        oglGenFramebuffersEXT(1, &m_fbo);
64
+        oglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
52 65
 
53 66
         // attach 2D texture to this FBO
54
-        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_fboTexture, 0);
67
+        oglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_fboTexture, 0);
55 68
 
56
-        GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
69
+        GLenum status = oglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
57 70
         switch(status) {
58 71
             case GL_FRAMEBUFFER_COMPLETE_EXT:
59 72
                 //ok
@@ -72,14 +85,14 @@ FrameBuffer::~FrameBuffer()
72 85
 {
73 86
     glDeleteTextures(1, &m_fboTexture);
74 87
     if(m_fbo)
75
-        glDeleteFramebuffersEXT(1, &m_fbo);
88
+        oglDeleteFramebuffersEXT(1, &m_fbo);
76 89
 }
77 90
 
78 91
 void FrameBuffer::bind()
79 92
 {
80 93
     if(!m_fallbackOldImp) {
81 94
         // bind framebuffer
82
-        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
95
+        oglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
83 96
     }
84 97
 
85 98
     // setup framebuffer viewport
@@ -101,7 +114,7 @@ void FrameBuffer::unbind()
101 114
 {
102 115
     if(!m_fallbackOldImp) {
103 116
         // bind back buffer again
104
-        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
117
+        oglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
105 118
         glDrawBuffer(GL_BACK);
106 119
         glReadBuffer(GL_BACK);
107 120
 

+ 0
- 1
src/framework/prerequisites.h View File

@@ -81,7 +81,6 @@ typedef int8_t int8;
81 81
 #define foreach BOOST_FOREACH
82 82
 
83 83
 // GL stuff
84
-#define GL_GLEXT_PROTOTYPES
85 84
 #include <GL/gl.h>
86 85
 #include <GL/glu.h>
87 86
 #include <GL/glext.h>

Loading…
Cancel
Save