aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl/context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics/opengl/context.cpp')
-rw-r--r--backends/graphics/opengl/context.cpp92
1 files changed, 9 insertions, 83 deletions
diff --git a/backends/graphics/opengl/context.cpp b/backends/graphics/opengl/context.cpp
index 89f0ed7910..7402e79ea5 100644
--- a/backends/graphics/opengl/context.cpp
+++ b/backends/graphics/opengl/context.cpp
@@ -23,6 +23,7 @@
#include "backends/graphics/opengl/opengl-sys.h"
#include "backends/graphics/opengl/opengl-graphics.h"
#include "backends/graphics/opengl/shader.h"
+#include "backends/graphics/opengl/pipeline.h"
#include "common/tokenizer.h"
#include "common/debug.h"
@@ -40,94 +41,19 @@ void Context::reset() {
#define GL_FUNC_DEF(ret, name, param) name = nullptr;
#include "backends/graphics/opengl/opengl-func.h"
#undef GL_FUNC_DEF
-}
-
-void Context::initializePipeline() {
-#if !USE_FORCED_GL && !USE_FORCED_GLES && !USE_FORCED_GLES2
- if (g_context.type != kContextGLES2) {
-#endif
-#if !USE_FORCED_GLES2
- GL_CALL(glDisable(GL_LIGHTING));
- GL_CALL(glDisable(GL_FOG));
- GL_CALL(glShadeModel(GL_FLAT));
- GL_CALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST));
-#endif
-#if !USE_FORCED_GL && !USE_FORCED_GLES && !USE_FORCED_GLES2
- }
-#endif
- // Enable rendering with vertex and coord arrays.
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- if (g_context.shadersSupported) {
-#endif
-#if !USE_FORCED_GLES
- GL_CALL(glEnableVertexAttribArray(kPositionAttribLocation));
- GL_CALL(glEnableVertexAttribArray(kTexCoordAttribLocation));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- } else {
-#endif
-#if !USE_FORCED_GLES2
- GL_CALL(glEnableClientState(GL_VERTEX_ARRAY));
- GL_CALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- }
-#endif
-
-#if !USE_FORCED_GL && !USE_FORCED_GLES && !USE_FORCED_GLES2
- if (g_context.type == kContextGLES2) {
-#endif
-#if !USE_FORCED_GL && !USE_FORCED_GLES
- GL_CALL(glActiveTexture(GL_TEXTURE0));
-#endif
-#if !USE_FORCED_GL && !USE_FORCED_GLES && !USE_FORCED_GLES2
- } else {
-#endif
-#if !USE_FORCED_GLES2
- GL_CALL(glEnable(GL_TEXTURE_2D));
-#endif
-#if !USE_FORCED_GL && !USE_FORCED_GLES && !USE_FORCED_GLES2
- }
-#endif
+ activePipeline = nullptr;
}
-void Context::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- if (g_context.shadersSupported) {
-#endif
-#if !USE_FORCED_GLES
- GL_CALL(glVertexAttrib4f(kColorAttribLocation, r, g, b, a));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- } else {
-#endif
-#if !USE_FORCED_GLES2
- GL_CALL(glColor4f(r, g, b, a));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- }
-#endif
-}
+Pipeline *Context::setPipeline(Pipeline *pipeline) {
+ Pipeline *oldPipeline = activePipeline;
-void Context::setDrawCoordinates(const GLfloat *vertices, const GLfloat *texCoords) {
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- if (g_context.shadersSupported) {
-#endif
-#if !USE_FORCED_GLES
- GL_CALL(glVertexAttribPointer(kTexCoordAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, texCoords));
- GL_CALL(glVertexAttribPointer(kPositionAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, vertices));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
- } else {
-#endif
-#if !USE_FORCED_GLES2
- GL_CALL(glTexCoordPointer(2, GL_FLOAT, 0, texCoords));
- GL_CALL(glVertexPointer(2, GL_FLOAT, 0, vertices));
-#endif
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
+ activePipeline = pipeline;
+ if (activePipeline) {
+ activePipeline->activate();
}
-#endif
+
+ return oldPipeline;
}
Context g_context;