mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Support for OpenGL buffer objects on Windows
This commit is contained in:
parent
e31cc7dfa1
commit
953bd13cf4
@ -1,5 +1,8 @@
|
||||
#ifndef INCOPENGL_HPP___
|
||||
#define INCOPENGL_HPP___
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <mydefs.hpp>
|
||||
|
||||
# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_NSOPENGL)
|
||||
# include <OpenGL/gl.h>
|
||||
@ -17,15 +20,20 @@
|
||||
#include <GL/glxext.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
// part of OpenGL 1.2, but not in Microsoft's OpenGL 1.1 header:
|
||||
// GL version sould be checked at runtime
|
||||
#ifndef GL_CLAMP_TO_EDGE
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
#define GL_ARRAY_BUFFER 0x8892
|
||||
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
|
||||
#define GL_STATIC_DRAW 0x88E4
|
||||
typedef ptrdiff_t GLintptr;
|
||||
typedef ptrdiff_t GLsizeiptr;
|
||||
extern void (*glBindBuffer) (GLenum a, GLuint b);
|
||||
extern void (*glDeleteBuffers) (GLsizei a, const GLuint *b);
|
||||
extern void (*glGenBuffers) (GLsizei a, GLuint *b);
|
||||
extern void (*glBufferData) (GLenum a, GLsizeiptr b, const GLvoid *c, GLenum d);
|
||||
extern void (*glBufferSubData) (GLenum a, GLintptr b, GLsizeiptr c, const GLvoid *d);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DLL_HEADER void LoadOpenGLFunctionPointers();
|
||||
#endif // INCOPENGL_HPP___
|
||||
|
@ -4805,3 +4805,22 @@ void Ng_Redraw (bool blocking)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OPENGL
|
||||
#ifdef WIN32
|
||||
void (*glBindBuffer) (GLenum a, GLuint b);
|
||||
void (*glDeleteBuffers) (GLsizei a, const GLuint *b);
|
||||
void (*glGenBuffers) (GLsizei a, GLuint *b);
|
||||
void (*glBufferData) (GLenum a, GLsizeiptr b, const GLvoid *c, GLenum d);
|
||||
void (*glBufferSubData) (GLenum a, GLintptr b, GLsizeiptr c, const GLvoid *d);
|
||||
DLL_HEADER void LoadOpenGLFunctionPointers() {
|
||||
glBindBuffer = (decltype(glBindBuffer)) wglGetProcAddress("glBindBuffer");
|
||||
glBufferSubData = (decltype(glBufferSubData)) wglGetProcAddress("glBufferSubData");
|
||||
glBufferData = (decltype(glBufferData)) wglGetProcAddress("glBufferData");
|
||||
glDeleteBuffers = (decltype(glDeleteBuffers)) wglGetProcAddress("glDeleteBuffers");
|
||||
glGenBuffers = (decltype(glGenBuffers)) wglGetProcAddress("glGenBuffers");
|
||||
if(!glBindBuffer) throw std::runtime_error("Could not load OpenGL functions!");
|
||||
}
|
||||
#else // WIN32
|
||||
DLL_HEADER void LoadOpenGLFunctionPointers() { }
|
||||
#endif // WIN32
|
||||
#endif // OPENGL
|
||||
|
@ -43,7 +43,7 @@ class DLL_HEADER VisualSceneSolution : public VisualScene
|
||||
Point<3> p;
|
||||
};
|
||||
|
||||
// #define USE_BUFFERS
|
||||
#define USE_BUFFERS
|
||||
#ifdef USE_BUFFERS
|
||||
bool has_surfel_vbo = false;
|
||||
GLuint surfel_vbo[4]; //
|
||||
|
@ -1938,6 +1938,7 @@ namespace netgen
|
||||
if (nodisplay)
|
||||
return;
|
||||
|
||||
LoadOpenGLFunctionPointers();
|
||||
fontbase = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 );
|
||||
Set_OpenGLText_Callback (&MyOpenGLText_GUI);
|
||||
|
||||
@ -2078,6 +2079,8 @@ namespace netgen
|
||||
// possible values: 12,14,16,18,20,22,24,28,32
|
||||
font = selectFont(18);
|
||||
|
||||
LoadOpenGLFunctionPointers();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
Loading…
Reference in New Issue
Block a user