Review rlglInitGraphics()
This commit is contained in:
parent
f9f33926f7
commit
369b8532c0
@ -27,6 +27,7 @@ other changes:
|
|||||||
[core] Renamed WorldToScreen() to GetWorldToScreen()
|
[core] Renamed WorldToScreen() to GetWorldToScreen()
|
||||||
[core] Removed function SetCustomCursor()
|
[core] Removed function SetCustomCursor()
|
||||||
[core] Removed functions BeginDrawingEx(), BeginDrawingPro()
|
[core] Removed functions BeginDrawingEx(), BeginDrawingPro()
|
||||||
|
[core] Replaced functions InitDisplay() + InitGraphics() with: InitGraphicsDevice()
|
||||||
[core] Added support for field-of-view Y (fovy) on 3d Camera
|
[core] Added support for field-of-view Y (fovy) on 3d Camera
|
||||||
[core] Added 2D camera mode functions: Begin2dMode() - End2dMode()
|
[core] Added 2D camera mode functions: Begin2dMode() - End2dMode()
|
||||||
[core] Translate mouse inputs to Android touch/gestures internally
|
[core] Translate mouse inputs to Android touch/gestures internally
|
||||||
|
60
src/rlgl.c
60
src/rlgl.c
@ -1176,7 +1176,7 @@ void rlglDraw(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Graphics Device (OpenGL stuff)
|
// Initialize OpenGL states
|
||||||
// NOTE: Stores global variables screenWidth and screenHeight
|
// NOTE: Stores global variables screenWidth and screenHeight
|
||||||
void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
|
void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
|
||||||
{
|
{
|
||||||
@ -1184,45 +1184,49 @@ void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
|
|||||||
screenWidth = width;
|
screenWidth = width;
|
||||||
screenHeight = height;
|
screenHeight = height;
|
||||||
|
|
||||||
// NOTE: Required! viewport must be recalculated if screen resized!
|
// Init state: Viewport
|
||||||
|
// NOTE: Viewport must be recalculated if screen is resized, don't confuse glViewport with the
|
||||||
|
// transformation matrix, glViewport just defines the area of the context that you will actually draw to.
|
||||||
glViewport(offsetX/2, offsetY/2, width - offsetX, height - offsetY); // Set viewport width and height
|
glViewport(offsetX/2, offsetY/2, width - offsetX, height - offsetY); // Set viewport width and height
|
||||||
|
|
||||||
// NOTE: Don't confuse glViewport with the transformation matrix
|
// Init state: Depth Test
|
||||||
// NOTE: glViewport just defines the area of the context that you will actually draw to.
|
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black)
|
|
||||||
//glClearDepth(1.0f); // Clear depth buffer (default)
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear used buffers, depth buffer is used for 3D
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST); // Disable depth testing for 2D (only used for 3D)
|
|
||||||
glDepthFunc(GL_LEQUAL); // Type of depth testing to apply
|
glDepthFunc(GL_LEQUAL); // Type of depth testing to apply
|
||||||
|
glDisable(GL_DEPTH_TEST); // Disable depth testing for 2D (only used for 3D)
|
||||||
|
|
||||||
glEnable(GL_BLEND); // Enable color blending (required to work with transparencies)
|
// Init state: Blending mode
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Color blending function (how colors are mixed)
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Color blending function (how colors are mixed)
|
||||||
|
glEnable(GL_BLEND); // Enable color blending (required to work with transparencies)
|
||||||
|
|
||||||
|
// Init state: Culling
|
||||||
|
// NOTE: All shapes/models triangles are drawn CCW
|
||||||
|
glCullFace(GL_BACK); // Cull the back face (default)
|
||||||
|
glFrontFace(GL_CCW); // Front face are defined counter clockwise (default)
|
||||||
|
glEnable(GL_CULL_FACE); // Enable backface culling
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Improve quality of color and texture coordinate interpolation (Deprecated in OGL 3.0)
|
// Init state: Color hints (deprecated in OpenGL 3.0+)
|
||||||
// Other options: GL_FASTEST, GL_DONT_CARE (default)
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Improve quality of color and texture coordinate interpolation
|
||||||
|
glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Init state: Color/Depth buffers clear
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black)
|
||||||
|
glClearDepth(1.0f); // Set clear depth value (default)
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers (depth buffer required for 3D)
|
||||||
|
|
||||||
|
// Init state: projection and modelview matrices
|
||||||
|
// NOTE: Setup global variables: projection and modelview
|
||||||
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
||||||
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
||||||
|
rlOrtho(0, width - offsetX, height - offsetY, 0, 0.0f, 1.0f); // Orthographic projection mode with top-left corner at (0,0)
|
||||||
rlOrtho(0, width - offsetX, height - offsetY, 0, 0.0f, 1.0f); // Config orthographic mode: top-left corner --> (0,0)
|
|
||||||
|
|
||||||
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
||||||
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
||||||
|
|
||||||
// NOTE: All shapes/models triangles are drawn CCW
|
// NOTE: projection and modelview could be set alternatively using:
|
||||||
|
//Matrix matOrtho = MatrixOrtho(0, width - offsetX, height - offsetY, 0, 0.0f, 1.0f);
|
||||||
glEnable(GL_CULL_FACE); // Enable backface culling (Disabled by default)
|
//MatrixTranspose(&matOrtho);
|
||||||
//glCullFace(GL_BACK); // Cull the Back face (default)
|
//projection = matOrtho; // Global variable
|
||||||
//glFrontFace(GL_CCW); // Front face are defined counter clockwise (default)
|
//modelview = MatrixIdentity(); // Global variable
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
|
||||||
glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation) (Deprecated on OpenGL 3.3+)
|
|
||||||
// Possible options: GL_SMOOTH (Color interpolation) or GL_FLAT (no interpolation)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TraceLog(INFO, "OpenGL graphic device initialized successfully");
|
TraceLog(INFO, "OpenGL graphic device initialized successfully");
|
||||||
}
|
}
|
||||||
@ -2741,7 +2745,7 @@ void EndOculusDrawing(void)
|
|||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(255, 255, 255, 255);
|
rlColor4ub(255, 255, 255, 255);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
// Bottom-left corner for texture and quad
|
// Bottom-left corner for texture and quad
|
||||||
rlTexCoord2f(0.0f, 1.0f);
|
rlTexCoord2f(0.0f, 1.0f);
|
||||||
|
Loading…
Reference in New Issue
Block a user