From 9fdf4420d5354c32394246703015a686df8135ce Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 17 Jun 2016 00:29:46 +0200 Subject: [PATCH] Corrected bugs on OpenGL 2.1 --- src/rlgl.c | 13 +++++++++---- src/shapes.c | 6 +++--- src/standard_shader.h | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/rlgl.c b/src/rlgl.c index 99ef4a4f..6d003869 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1214,14 +1214,17 @@ void rlglInitGraphics(int offsetX, int offsetY, int width, int height) // NOTE: External loader function could be passed as a pointer void rlglLoadExtensions(void *loader) { -#if defined(GRAPHICS_API_OPENGL_33) - // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions +#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) + // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions"); else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully"); - + +#if defined(GRAPHICS_API_OPENGL_21) if (GLAD_GL_VERSION_2_1) TraceLog(INFO, "OpenGL 2.1 profile supported"); - else if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported"); +#elif defined(GRAPHICS_API_OPENGL_33) + if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported"); else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported"); +#endif // With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans //if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object @@ -2597,6 +2600,8 @@ void EndOculusDrawing(void) // Blit mirror texture to back buffer BlitOculusMirror(session, mirror); + + rlDisableDepthTest(); } #endif diff --git a/src/shapes.c b/src/shapes.c index 3ccfd660..2a4e19c2 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -135,7 +135,7 @@ void DrawCircleV(Vector2 center, float radius, Color color) } rlEnd(); } - else if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) + else if ((rlGetVersion() == OPENGL_21) || (rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) { rlEnableTexture(GetDefaultTexture().id); // Default white texture @@ -218,7 +218,7 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color) rlVertex2i(position.x + size.x, position.y); rlEnd(); } - else if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) + else if ((rlGetVersion() == OPENGL_21) || (rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) { rlEnableTexture(GetDefaultTexture().id); // Default white texture @@ -264,7 +264,7 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) rlVertex2i(posX + 1, posY + 1); rlEnd(); } - else if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) + else if ((rlGetVersion() == OPENGL_21) || (rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) { DrawRectangle(posX, posY, width, 1, color); DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color); diff --git a/src/standard_shader.h b/src/standard_shader.h index a4bc9694..e1668ae7 100644 --- a/src/standard_shader.h +++ b/src/standard_shader.h @@ -166,9 +166,9 @@ static const char fStandardShaderStr[] = " else if(lights[i].type == 2) lighting += CalcSpotLight(lights[i], n, v, spec);\n" " }\n" " }\n" -#if defined(GRAPHICS_API_OPENGL_33) -" finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); \n" -#elif defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) +#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) " gl_FragColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); \n" +#elif defined(GRAPHICS_API_OPENGL_33) +" finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); \n" #endif "}\n";