summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-04 21:04:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-04 21:04:12 +0300
commit5dbe8005e02b29da820fb4ed09fd3b0645683f70 (patch)
tree8a563efaeb63fa17eaf18466da9a825f9f5f91d1 /src
parentec5b0e17ff735e58de139b7f8ce0598928958bcc (diff)
downloadplus-5dbe8005e02b29da820fb4ed09fd3b0645683f70.tar.gz
plus-5dbe8005e02b29da820fb4ed09fd3b0645683f70.tar.bz2
plus-5dbe8005e02b29da820fb4ed09fd3b0645683f70.tar.xz
plus-5dbe8005e02b29da820fb4ed09fd3b0645683f70.zip
Add shader related OpenGL functions and some other.
Diffstat (limited to 'src')
-rw-r--r--src/graphicsmanager.cpp34
-rw-r--r--src/render/mgl.cpp24
-rw-r--r--src/render/mgl.h73
3 files changed, 131 insertions, 0 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index f7c877c1f..a628c25a7 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -901,6 +901,40 @@ void GraphicsManager::initOpenGLFunctions()
assignFunction(glBindBuffer, "glBindBuffer");
assignFunction(glBufferData, "glBufferData");
}
+ if (checkGLVersion(2, 0))
+ {
+ assignFunction(glCreateShader, "glCreateShader");
+ assignFunction(glDeleteShader, "glDeleteShader");
+ assignFunction(glGetShaderiv, "glGetShaderiv");
+ assignFunction(glGetShaderInfoLog, "glGetShaderInfoLog");
+ assignFunction(glGetShaderSource, "glGetShaderSource");
+ assignFunction(glShaderSource, "glShaderSource");
+ assignFunction(glCompileShader, "glCompileShader");
+ assignFunction(glLinkProgram, "glLinkProgram");
+ assignFunction(glDeleteProgram, "glDeleteProgram");
+ assignFunction(glCreateProgram, "glCreateProgram");
+ assignFunction(glAttachShader, "glAttachShader");
+ assignFunction(glDetachShader, "glDetachShader");
+ assignFunction(glGetAttachedShaders, "glGetAttachedShaders");
+ assignFunction(glGetUniformLocation, "glGetUniformLocation");
+ assignFunction(glGetActiveUniform, "glGetActiveUniform");
+ assignFunction(glGetProgramiv, "glGetProgramiv");
+ assignFunction(glUseProgram, "glUseProgram");
+ assignFunction(glValidateProgram, "glValidateProgram");
+ assignFunction(glGetAttribLocation, "glGetAttribLocation");
+ }
+ if (checkGLVersion(3, 0))
+ {
+ assignFunction(glBindFragDataLocation, "glBindFragDataLocation");
+ }
+ if (checkGLVersion(4, 0)
+ || supportExtension("GL_ARB_separate_shader_objects"))
+ {
+ assignFunction(glUniform1f, "glUniform1f");
+ assignFunction(glUniform2f, "glUniform2f");
+ assignFunction(glUniform3f, "glUniform3f");
+ assignFunction(glUniform4f, "glUniform4f");
+ }
#ifdef WIN32
assignFunction(wglGetExtensionsString, "wglGetExtensionsStringARB");
diff --git a/src/render/mgl.cpp b/src/render/mgl.cpp
index fc6624606..21e2dd274 100644
--- a/src/render/mgl.cpp
+++ b/src/render/mgl.cpp
@@ -58,6 +58,30 @@ defName(glGenBuffers);
defName(glDeleteBuffers);
defName(glBindBuffer);
defName(glBufferData);
+defName(glCreateShader);
+defName(glDeleteShader);
+defName(glGetShaderiv);
+defName(glGetShaderInfoLog);
+defName(glGetShaderSource);
+defName(glShaderSource);
+defName(glCompileShader);
+defName(glLinkProgram);
+defName(glDeleteProgram);
+defName(glCreateProgram);
+defName(glAttachShader);
+defName(glDetachShader);
+defName(glGetAttachedShaders);
+defName(glGetUniformLocation);
+defName(glGetActiveUniform);
+defName(glGetProgramiv);
+defName(glBindFragDataLocation);
+defName(glUseProgram);
+defName(glValidateProgram);
+defName(glGetAttribLocation);
+defName(glUniform1f);
+defName(glUniform2f);
+defName(glUniform3f);
+defName(glUniform4f);
#ifdef WIN32
defName(wglGetExtensionsString);
diff --git a/src/render/mgl.h b/src/render/mgl.h
index 1bc82989b..1eba9a1ef 100644
--- a/src/render/mgl.h
+++ b/src/render/mgl.h
@@ -83,6 +83,17 @@
#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
#endif
+#ifndef GL_ARRAY_BUFFER
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#endif
+
+#ifndef GL_STREAM_DRAW
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STATIC_DRAW 0x88E4
+#define GL_DYNAMIC_DRAW 0x88E8
+#endif
+
#define defNameE(name) extern name##_t m##name
typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *);
@@ -130,6 +141,43 @@ typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers);
typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer);
typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size,
const GLvoid *data, GLenum usage);
+typedef void (APIENTRY *glCreateShader_t) (GLenum shaderType);
+typedef void (APIENTRY *glDeleteShader_t) (GLenum shader);
+typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader,
+ GLenum pname, GLint *params);
+typedef void (APIENTRY *glGetShaderInfoLog_t) (GLuint shader,
+ GLsizei maxLength, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRY *glGetShaderSource_t) (GLuint shader,
+ GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef void (APIENTRY *glShaderSource_t) (GLuint shader,
+ GLsizei count, const GLchar **string, const GLint *length);
+typedef void (APIENTRY *glCompileShader_t) (GLuint shader);
+typedef void (APIENTRY *glLinkProgram_t) (GLuint program);
+typedef void (APIENTRY *glDeleteProgram_t) (GLuint program);
+typedef GLuint (APIENTRY *glCreateProgram_t) (void);
+typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader);
+typedef void (APIENTRY *glDetachShader_t) (GLuint program, GLuint shader);
+typedef void (APIENTRY *glGetAttachedShaders_t) (GLuint program,
+ GLsizei maxCount, GLsizei *count, GLuint *shaders);
+typedef void (APIENTRY *glGetUniformLocation_t) (GLuint program,
+ const GLchar *name);
+typedef void (APIENTRY *glGetActiveUniform_t) (GLuint program, GLuint index,
+ GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRY *glGetProgramiv_t) (GLuint program,
+ GLenum pname, GLint *params);
+typedef GLint (APIENTRY *glBindFragDataLocation_t) (GLuint program,
+ GLuint colorNumber, const char *name);
+typedef void (APIENTRY *glUseProgram_t) (GLuint program);
+typedef void (APIENTRY *glValidateProgram_t) (GLuint program);
+typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program,
+ const GLchar *name);
+typedef void (APIENTRY *glUniform1f_t) (GLint location, GLfloat v0);
+typedef void (APIENTRY *glUniform2f_t) (GLint location,
+ GLfloat v0, GLfloat v1);
+typedef void (APIENTRY *glUniform3f_t) (GLint location,
+ GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRY *glUniform4f_t) (GLint location,
+ GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
// callback
typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id,
@@ -170,6 +218,31 @@ defNameE(glGenBuffers);
defNameE(glDeleteBuffers);
defNameE(glBindBuffer);
defNameE(glBufferData);
+defNameE(glCreateShader);
+defNameE(glDeleteShader);
+defNameE(glGetShaderiv);
+defNameE(glGetShaderInfoLog);
+defNameE(glGetShaderSource);
+defNameE(glShaderSource);
+defNameE(glCompileShader);
+defNameE(glLinkProgram);
+defNameE(glDeleteProgram);
+defNameE(glCreateProgram);
+defNameE(glAttachShader);
+defNameE(glDetachShader);
+defNameE(glGetAttachedShaders);
+defNameE(glGetUniformLocation);
+defNameE(glGetActiveUniform);
+defNameE(glGetProgramiv);
+defNameE(glBindFragDataLocation);
+defNameE(glUseProgram);
+defNameE(glValidateProgram);
+defNameE(glGetAttribLocation);
+defNameE(glActiveTexture);
+defNameE(glUniform1f);
+defNameE(glUniform2f);
+defNameE(glUniform3f);
+defNameE(glUniform4f);
#ifdef WIN32
typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);