Commits

Bryan Kadzban  committed 5578406

Cherrypick parts of https://bitbucket.org/ecsirke/frontier rev 4c46a39924bf, to make future cherrypicks slightly easier. Most of that change is not relevant (yes, it's cleaner the way 4c46a39924bf changed it to, but this matches closer to Shamus's code, so I sorta prefer it this way, plus that commit had a bunch of logical changes all bunched together).

  • Participants
  • Parent commits 6c69e4c

Comments (0)

Files changed (5)

File Terrain/Main.cpp

 #include "Cg.h"
 #include "Env.h"
 #include "Game.h"
+#include "glFunctions.h"
 #include "Sdl.h"
 #ifdef WINDOWS
 #include "il\il.h"
   ilInit ();
   RandomInit (11);
   SdlInit ();
+  gl_functions_init();
   RenderInit ();
   EnvInit ();
   GameInit ();

File Terrain/StdAfx.h

+#ifndef STDAFX_H
+#define STDAFX_H
+
 #define WRAP(x,y)                 ((unsigned)x % y)
 #define SIGN(x)                   (((x) > 0) ? 1 : ((x) < 0) ? -1 : 0)
 #define SIGNF(x)                  (((x) > NEGLIGIBLE) ? 1 : ((x) < -NEGLIGIBLE) ? -1 : 0)
   float water_level;
   float detail;
 };
+
+#endif // STDAFX_H

File Terrain/VBO.cpp

 
 #include "VBO.h"
 
-
-// VBO Extension Definitions, From glext.h
-#ifdef WINDOWS  // Guess what?  We *have* glext.h
-#define GL_ARRAY_BUFFER_ARB 0x8892
-#define GL_STATIC_DRAW_ARB 0x88E4
-typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
-typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
-typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
-typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage);
-#else
-// But we do need glx.h, for glxGetProcAddressARB
-#include <GL/glx.h>
-#endif
-
-// VBO Extension Function Pointers
-PFNGLGENBUFFERSARBPROC    glGenBuffersARB = NULL;					// VBO Name Generation Procedure
-PFNGLBINDBUFFERARBPROC    glBindBufferARB = NULL;					// VBO Bind Procedure
-PFNGLBUFFERDATAARBPROC    glBufferDataARB = NULL;					// VBO Data Loading Procedure
-PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;				// VBO Deletion Procedure
-
-/*-----------------------------------------------------------------------------
-
------------------------------------------------------------------------------*/
-
-static void vbo_init ()
-{
-
-	// Get Pointers To The GL Functions
-#ifdef WINDOWS
-	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
-	glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");
-	glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
-	glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB");
-#else
-	// Awesome, glXGetProcAddressARB takes a const GLubyte pointer, while string literals
-	// turn into a const char array (note: signed!)  Whee.
-	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGenBuffersARB"));
-	glBindBufferARB = (PFNGLBINDBUFFERARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glBindBufferARB"));
-	glBufferDataARB = (PFNGLBUFFERDATAARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glBufferDataARB"));
-	glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glDeleteBuffersARB"));
-#endif
-
-}
-
-/*-----------------------------------------------------------------------------
-
------------------------------------------------------------------------------*/
+#include "glFunctions.h"
 
 VBO::VBO ()
 {
   char*     buffer;
 
   if (glGenBuffersARB == NULL)
-    vbo_init ();
-  if (glGenBuffersARB == NULL)
     return;
   if (_id_vertex)
     glDeleteBuffersARB (1, &_id_vertex);

File Terrain/glFunctions.cpp

+#include "glFunctions.h"
+
+#ifndef WINDOWS
+#include <GL/glx.h>
+#endif
+
+// VBO Extension Function Pointers
+PFNGLGENBUFFERSARBPROC    glGenBuffersARB = NULL;					// VBO Name Generation Procedure
+PFNGLBINDBUFFERARBPROC    glBindBufferARB = NULL;					// VBO Bind Procedure
+PFNGLBUFFERDATAARBPROC    glBufferDataARB = NULL;					// VBO Data Loading Procedure
+PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;				// VBO Deletion Procedure
+
+void gl_functions_init ()
+{
+  // Get Pointers To The GL Functions
+#ifdef WINDOWS
+  glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
+  glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");
+  glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
+  glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB");
+#else
+  // Awesome, glXGetProcAddressARB takes a const GLubyte pointer, while string literals
+  // turn into a const char array (note: signed!)  Whee.
+  glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGenBuffersARB"));
+  glBindBufferARB = (PFNGLBINDBUFFERARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glBindBufferARB"));
+  glBufferDataARB = (PFNGLBUFFERDATAARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glBufferDataARB"));
+  glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glDeleteBuffersARB"));
+#endif
+
+}

File Terrain/glFunctions.h

+#ifndef GLFUNCTIONS_H
+#define GLFUNCTIONS_H
+
+#include "StdAfx.h"
+
+// Extension Definitions, From glext.h
+
+// VBO Extension Function Pointers
+extern PFNGLGENBUFFERSARBPROC    glGenBuffersARB;     // VBO Name Generation Procedure
+extern PFNGLBINDBUFFERARBPROC    glBindBufferARB;     // VBO Bind Procedure
+extern PFNGLBUFFERDATAARBPROC    glBufferDataARB;     // VBO Data Loading Procedure
+extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;  // VBO Deletion Procedure
+
+// Only works after SDL OpenGL initialization
+void gl_functions_init ();
+
+#endif // GLFUNCTIONS_H