1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/*
* mapoglcontext.h
*
* Created on: 11/01/2009
* Author: toby
*/
#ifndef MAPOGLCONTEXT_H_
#define MAPOGLCONTEXT_H_
#ifdef USE_OGL
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include "opengl/glext.h"
#include "opengl/wglext.h"
typedef HDC OGL_WINDOW;
typedef HGLRC OGL_CONTEXT;
typedef HGLRC OGL_PBUFFER;
#define CALLBACK __stdcall
#else
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>
typedef Display* OGL_WINDOW;
typedef GLXContext OGL_CONTEXT;
typedef GLXPbuffer OGL_PBUFFER;
#define CALLBACK
#endif
class OglRenderer;
class OglContext {
private:
static OglContext* current;
static bool initWindow();
static bool initSharingContext();
#if defined(_WIN32) && !defined(__CYGWIN__)
static HDC window;
static HGLRC sharingContext;
HDC hPBufferDC;
HGLRC hPBufferRC;
#else
static Display* window;
static GLXContext sharingContext;
static GLXFBConfig* configs;
GLXPbuffer pbuffer;
#endif
public:
static ms_uint32 MAX_MULTISAMPLE_SAMPLES;
static ms_uint32 MAX_ANISOTROPY;
static ms_uint32 MAX_TEXTURE_SIZE;
static ms_uint32 MIN_TEXTURE_SIZE;
OglContext(ms_uint32 width, ms_uint32 height);
~OglContext();
int getHeight() { return height; }
int getWidth() { return width; }
bool makeCurrent();
void bindPBufferToTexture();
private:
bool createPBuffer(ms_uint32 width, ms_uint32 height);
ms_uint32 width;
ms_uint32 height;
int windowPixelFormat;
#if defined(_WIN32) && !defined(__CYGWIN__)
static PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB ;
static PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB ;
static PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB ;
static PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB ;
static PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB ;
static PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB ;
static PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB ;
static PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB ;
static PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB ;
static PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB ;
static PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB ;
static PFNWGLMAKECONTEXTCURRENTARBPROC wglMakeContextCurrentARB;
static PFNWGLGETPIXELFORMATATTRIBIVEXTPROC wglGetPixelFormatAttribivEXT;
static PFNGLGENBUFFERSARBPROC wglGenBuffersARB; // VBO Name Generation Procedure
static PFNGLBINDBUFFERARBPROC wglBindBufferARB; // VBO Bind Procedure
static PFNGLBUFFERDATAARBPROC wglBufferDataARB; // VBO Data Loading Procedure
static PFNGLBUFFERSUBDATAARBPROC wglBufferSubDataARB; // VBO Sub Data Loading Procedure
static PFNGLDELETEBUFFERSARBPROC wglDeleteBuffersARB; // VBO Deletion Procedure
static PFNGLGETBUFFERPARAMETERIVARBPROC wglGetBufferParameterivARB; // return various parameters of VBO
static PFNGLMAPBUFFERARBPROC wglMapBufferARB; // map VBO procedure
static PFNGLUNMAPBUFFERARBPROC wglUnmapBufferARB; // unmap VBO procedure
#endif
};
#endif /* USE_OGL */
#endif /* MAPOGLCONTEXT_H_ */
|