8 #ifndef META_OCEAN_PLATFORM_GL_CONTEXT_H
9 #define META_OCEAN_PLATFORM_GL_CONTEXT_H
40 typedef const GLubyte*(*glGetStringiFunction)(GLenum, GLuint);
45 typedef void (*glGenFramebuffersFunction)(GLsizei, GLuint*);
50 typedef void (*glDeleteFramebuffersFunction)(GLsizei,
const GLuint*);
55 typedef void (*glBindFramebufferFunction)(GLenum, GLuint);
60 typedef void (*glGenRenderbuffersFunction)(GLsizei, GLuint*);
65 typedef void (*glDeleteRenderbuffersFunction)(GLsizei,
const GLuint*);
70 typedef void (*glBindRenderbufferFunction)(GLenum, GLuint);
75 typedef void (*glRenderbufferStorageFunction)(GLenum, GLenum, GLsizei, GLsizei);
80 typedef void (*glRenderbufferStorageMultisampleFunction)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
85 typedef void (*glFramebufferRenderbufferFunction)(GLenum, GLenum, GLenum, GLuint);
90 typedef void(*glBlitFramebufferFunction)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
95 typedef GLenum (*glCheckFramebufferStatusFunction)(GLenum);
100 typedef void (*glGenBuffersFunction)(GLsizei, GLuint*);
105 typedef void (*glDeleteBuffersFunction)(GLsizei,
const GLuint*);
110 typedef void (*glBindBufferFunction)(GLenum, GLuint);
115 typedef void (*glBufferDataFunction)(GLenum, GLsizeiptr,
const GLvoid*, GLenum);
120 typedef GLuint (*glCreateProgramFunction)();
125 typedef void (*glDeleteProgramFunction)(GLuint);
130 typedef GLboolean (*glIsProgramFunction)(GLuint);
135 typedef void (*glAttachShaderFunction)(GLuint, GLuint);
140 typedef void (*glDetachShaderFunction)(GLuint, GLuint);
145 typedef void (*glLinkProgramFunction)(GLuint);
150 typedef void (*glUseProgramFunction)(GLuint);
155 typedef GLuint (*glCreateShaderFunction)(GLenum);
160 typedef void (*glDeleteShaderFunction)(GLuint);
165 typedef void (*glCompileShaderFunction)(GLuint);
170 typedef void (*glShaderSourceFunction)(GLuint, GLsizei,
const GLchar**,
const GLint*);
175 typedef void (*glGetProgramivFunction)(GLuint, GLenum, GLint*);
180 typedef void (*glGetShaderivFunction)(GLuint, GLenum, GLint*);
185 typedef void (*glGetProgramInfoLogFunction)(GLuint, GLsizei, GLsizei*, GLchar*);
190 typedef void (*glGetShaderInfoLogFunction)(GLuint, GLsizei, GLsizei*, GLchar*);
195 typedef GLint (*glGetAttribLocationFunction)(GLuint,
const GLchar*);
200 typedef GLint (*glGetUniformLocationFunction)(GLuint,
const GLchar*);
205 typedef void (*glUniform1iFunction)(GLint, GLint);
210 typedef void (*glUniform1fvFunction)(GLint, GLsizei,
const GLfloat*);
215 typedef void (*glUniform2fvFunction)(GLint, GLsizei,
const GLfloat*);
220 typedef void (*glUniform3fvFunction)(GLint, GLsizei,
const GLfloat*);
225 typedef void (*glUniform4fvFunction)(GLint, GLsizei,
const GLfloat*);
230 typedef void(*glUniformMatrix3fvFunction)(GLint, GLsizei, GLboolean,
const GLfloat*);
235 typedef void (*glUniformMatrix4fvFunction)(GLint, GLsizei, GLboolean,
const GLfloat*);
240 typedef void (*glEnableVertexAttribArrayFunction)(GLuint);
245 typedef void (*glDisableVertexAttribArrayFunction)(GLuint);
250 typedef void (*glVertexAttribPointerFunction)(GLuint, GLint, GLenum, GLboolean, GLsizei,
const GLvoid*);
255 typedef void (*glActiveTextureFunction)(GLenum);
260 typedef void (*glGenerateMipmapFunction)(GLenum);
265 typedef void (*glBlendFuncSeparateFunction)(GLenum, GLenum, GLenum, GLenum);
270 typedef void (*glTexImage2DMultisampleFunction)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLboolean);
275 typedef void (*glFramebufferTexture2DFunction)(GLenum, GLenum, GLenum, GLuint, GLint);
280 typedef void (*glBindFragDataLocationFunction)(GLuint, GLuint,
const char*);
285 typedef void (*glGenVertexArraysFunction)(GLsizei, GLuint*);
290 typedef void (*glDeleteVertexArraysFunction)(GLsizei,
const GLuint*);
295 typedef void(*glBindVertexArrayFunction)(GLuint);
299 typedef HGLRC (*wglCreateContextAttribsARBFunction)(HDC, HGLRC,
const int*);
327 inline unsigned int majorVersion()
const;
334 inline unsigned int minorVersion()
const;
342 inline bool compatibilityProfile()
const;
348 inline const StringSet& supportedExtensions()
const;
355 inline bool isExtensionSupported(
const std::string& extension)
const;
361 inline unsigned int multisamples()
const;
387 virtual bool createOpenGLContext(
const bool initializeOpenGL33 =
true,
const unsigned int multisamples = 1u);
409 glGetStringiFunction glGetStringi =
nullptr;
412 glGenFramebuffersFunction glGenFramebuffers =
nullptr;
415 glDeleteFramebuffersFunction glDeleteFramebuffers =
nullptr;
418 glBindFramebufferFunction glBindFramebuffer =
nullptr;
421 glGenRenderbuffersFunction glGenRenderbuffers =
nullptr;
424 glDeleteRenderbuffersFunction glDeleteRenderbuffers =
nullptr;
427 glBindRenderbufferFunction glBindRenderbuffer =
nullptr;
430 glRenderbufferStorageFunction glRenderbufferStorage =
nullptr;
433 glRenderbufferStorageMultisampleFunction glRenderbufferStorageMultisample =
nullptr;
436 glFramebufferRenderbufferFunction glFramebufferRenderbuffer =
nullptr;
439 glBlitFramebufferFunction glBlitFramebuffer =
nullptr;
442 glCheckFramebufferStatusFunction glCheckFramebufferStatus =
nullptr;
445 glGenBuffersFunction glGenBuffers =
nullptr;
448 glDeleteBuffersFunction glDeleteBuffers =
nullptr;
451 glBindBufferFunction glBindBuffer =
nullptr;
454 glBufferDataFunction glBufferData =
nullptr;
457 glCreateProgramFunction glCreateProgram =
nullptr;
460 glDeleteProgramFunction glDeleteProgram =
nullptr;
463 glIsProgramFunction glIsProgram =
nullptr;
466 glAttachShaderFunction glAttachShader =
nullptr;
469 glDetachShaderFunction glDetachShader =
nullptr;
472 glLinkProgramFunction glLinkProgram =
nullptr;
475 glUseProgramFunction glUseProgram =
nullptr;
478 glCreateShaderFunction glCreateShader =
nullptr;
481 glDeleteShaderFunction glDeleteShader =
nullptr;
484 glCompileShaderFunction glCompileShader =
nullptr;
487 glShaderSourceFunction glShaderSource =
nullptr;
490 glGetProgramivFunction glGetProgramiv =
nullptr;
493 glGetShaderivFunction glGetShaderiv =
nullptr;
496 glGetProgramInfoLogFunction glGetProgramInfoLog =
nullptr;
499 glGetShaderInfoLogFunction glGetShaderInfoLog =
nullptr;
502 glGetAttribLocationFunction glGetAttribLocation =
nullptr;
505 glGetUniformLocationFunction glGetUniformLocation =
nullptr;
508 glUniform1iFunction glUniform1i =
nullptr;
511 glUniform1fvFunction glUniform1fv =
nullptr;
514 glUniform2fvFunction glUniform2fv =
nullptr;
517 glUniform3fvFunction glUniform3fv =
nullptr;
520 glUniform4fvFunction glUniform4fv =
nullptr;
523 glUniformMatrix3fvFunction glUniformMatrix3fv =
nullptr;
526 glUniformMatrix4fvFunction glUniformMatrix4fv =
nullptr;
529 glEnableVertexAttribArrayFunction glEnableVertexAttribArray =
nullptr;
532 glDisableVertexAttribArrayFunction glDisableVertexAttribArray =
nullptr;
535 glVertexAttribPointerFunction glVertexAttribPointer =
nullptr;
538 glActiveTextureFunction glActiveTexture =
nullptr;
541 glGenerateMipmapFunction glGenerateMipmap =
nullptr;
544 glBlendFuncSeparateFunction glBlendFuncSeparate =
nullptr;
547 glTexImage2DMultisampleFunction glTexImage2DMultisample =
nullptr;
550 glFramebufferTexture2DFunction glFramebufferTexture2D =
nullptr;
553 glGenVertexArraysFunction glGenVertexArrays =
nullptr;
556 glDeleteVertexArraysFunction glDeleteVertexArrays =
nullptr;
559 glBindVertexArrayFunction glBindVertexArray =
nullptr;
564 void* handle_ =
nullptr;
567 unsigned int majorVersion_ = 0u;
570 unsigned int minorVersion_ = 0u;
573 bool compatibilityProfile_ =
false;
579 unsigned int multisamples_ = 0u;
This class encapsulates an OpenGL context.
Definition: platform/gl/Context.h:29
virtual bool createOpenGLContext(const bool initializeOpenGL33=true, const unsigned int multisamples=1u)
Creates the OpenGL context for this object.
virtual ~Context()
Releases the context.
bool isExtensionSupported(const std::string &extension) const
Returns whether a specific extension is supported.
Definition: platform/gl/Context.h:607
std::set< std::string > StringSet
Definition of a set holding strings.
Definition: platform/gl/Context.h:35
unsigned int minorVersion_
The minor version of this OpenGL context.
Definition: platform/gl/Context.h:570
virtual bool isValid() const
Returns whether this context is valid.
unsigned int multisamples() const
Returns the number of multi samples that this context supports.
Definition: platform/gl/Context.h:612
unsigned int minorVersion() const
Returns the minor OpenGL version of this context.
Definition: platform/gl/Context.h:592
const StringSet & supportedExtensions() const
Returns the set of supported extensions.
Definition: platform/gl/Context.h:602
unsigned int majorVersion() const
Returns the major OpenGL version of this context.
Definition: platform/gl/Context.h:587
virtual void release()
Releases the context explicitly.
virtual void makeCurrent(const bool state=true)=0
Makes the OpenGL rendering context of this framebuffer the calling thread's current rendering context...
bool compatibilityProfile_
True, if this context provides the compatibility profile.
Definition: platform/gl/Context.h:573
bool compatibilityProfile() const
Returns whether this context provides the compatibility profile or the core profile.
Definition: platform/gl/Context.h:597
StringSet extensions_
The set of supported extensions.
Definition: platform/gl/Context.h:576
Thread::ThreadId threadId_
Definition: platform/gl/Context.h:583
unsigned int majorVersion_
The major version of this OpenGL context.
Definition: platform/gl/Context.h:567
static HGLRC windowsCreateOpenGLContextHandle(HDC dc, const bool initializeOpenGL33, unsigned int &multisamples)
Creates a the OpennGL context handle on Windows platforms.
virtual bool releaseOpenGLContext()
Releases the OpenGL context of this framebuffer.
unsigned int multisamples_
The number of multi samples of this context.
Definition: platform/gl/Context.h:579
virtual bool swapBuffers()
Swaps the foreground and background buffer if this context has two buffers.
Context()=default
Creates a new context.
This class implements a platform independent wrapper for thread ids.
Definition: Thread.h:122
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15