Browse Source

Corrected bugs on OpenGL 2.1

pull/132/head
Ray 8 years ago
parent
commit
9fdf4420d5
3 changed files with 15 additions and 10 deletions
  1. +9
    -4
      src/rlgl.c
  2. +3
    -3
      src/shapes.c
  3. +3
    -3
      src/standard_shader.h

+ 9
- 4
src/rlgl.c View File

@ -1214,14 +1214,17 @@ void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
// NOTE: External loader function could be passed as a pointer // NOTE: External loader function could be passed as a pointer
void rlglLoadExtensions(void *loader) 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"); if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully"); 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"); 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"); 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 // 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 //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 // Blit mirror texture to back buffer
BlitOculusMirror(session, mirror); BlitOculusMirror(session, mirror);
rlDisableDepthTest();
} }
#endif #endif

+ 3
- 3
src/shapes.c View File

@ -135,7 +135,7 @@ void DrawCircleV(Vector2 center, float radius, Color color)
} }
rlEnd(); 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 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); rlVertex2i(position.x + size.x, position.y);
rlEnd(); 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 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); rlVertex2i(posX + 1, posY + 1);
rlEnd(); 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, posY, width, 1, color);
DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color); DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color);

+ 3
- 3
src/standard_shader.h View File

@ -166,9 +166,9 @@ static const char fStandardShaderStr[] =
" else if(lights[i].type == 2) lighting += CalcSpotLight(lights[i], n, v, spec);\n" " else if(lights[i].type == 2) lighting += CalcSpotLight(lights[i], n, v, spec);\n"
" }\n" " }\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" " 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 #endif
"}\n"; "}\n";

Loading…
Cancel
Save