Tweaks to support OpenGL ES 2.0 desktop
This commit is contained in:
parent
92f68ac6be
commit
47358fe5ce
2 changed files with 22 additions and 23 deletions
31
src/core.c
31
src/core.c
|
@ -2247,11 +2247,11 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
//glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers
|
//glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers
|
||||||
|
|
||||||
// Check some Window creation flags
|
// Check some Window creation flags
|
||||||
if (configFlags & FLAG_WINDOW_RESIZABLE) glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // Resizable window
|
if (configFlags & FLAG_WINDOW_RESIZABLE) glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // Resizable window
|
||||||
else glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // Avoid window being resizable
|
else glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // Avoid window being resizable
|
||||||
|
|
||||||
if (configFlags & FLAG_WINDOW_UNDECORATED) glfwWindowHint(GLFW_DECORATED, GL_FALSE); // Border and buttons on Window
|
if (configFlags & FLAG_WINDOW_UNDECORATED) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // Border and buttons on Window
|
||||||
else glfwWindowHint(GLFW_DECORATED, GL_TRUE); // Decorated window
|
else glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); // Decorated window
|
||||||
// FLAG_WINDOW_TRANSPARENT not supported on HTML5 and not included in any released GLFW version yet
|
// FLAG_WINDOW_TRANSPARENT not supported on HTML5 and not included in any released GLFW version yet
|
||||||
#if defined(GLFW_TRANSPARENT_FRAMEBUFFER)
|
#if defined(GLFW_TRANSPARENT_FRAMEBUFFER)
|
||||||
if (configFlags & FLAG_WINDOW_TRANSPARENT) glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); // Transparent framebuffer
|
if (configFlags & FLAG_WINDOW_TRANSPARENT) glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); // Transparent framebuffer
|
||||||
|
@ -2267,21 +2267,28 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
// Check selection OpenGL version
|
// Check selection OpenGL version
|
||||||
if (rlGetVersion() == OPENGL_21)
|
if (rlGetVersion() == OPENGL_21)
|
||||||
{
|
{
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); // Choose OpenGL major version (just hint)
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); // Choose OpenGL major version (just hint)
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); // Choose OpenGL minor version (just hint)
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); // Choose OpenGL minor version (just hint)
|
||||||
}
|
}
|
||||||
else if (rlGetVersion() == OPENGL_33)
|
else if (rlGetVersion() == OPENGL_33)
|
||||||
{
|
{
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above!
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above!
|
||||||
// Values: GLFW_OPENGL_CORE_PROFILE, GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
|
// Values: GLFW_OPENGL_CORE_PROFILE, GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // OSX Requires fordward compatibility
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); // OSX Requires fordward compatibility
|
||||||
#else
|
#else
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); // Fordward Compatibility Hint: Only 3.3 and above!
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Fordward Compatibility Hint: Only 3.3 and above!
|
||||||
#endif
|
#endif
|
||||||
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); // Request OpenGL DEBUG context
|
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context
|
||||||
|
}
|
||||||
|
else if (rlGetVersion() == OPENGL_ES_20) // Request OpenGL ES 2.0 context
|
||||||
|
{
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API); // Alternative: GLFW_EGL_CONTEXT_API (ANGLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
|
@ -3145,7 +3152,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
{
|
{
|
||||||
if (key == exitKey && action == GLFW_PRESS)
|
if (key == exitKey && action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
|
||||||
// NOTE: Before closing window, while loop must be left!
|
// NOTE: Before closing window, while loop must be left!
|
||||||
}
|
}
|
||||||
|
|
14
src/rlgl.h
14
src/rlgl.h
|
@ -165,14 +165,6 @@ typedef unsigned char byte;
|
||||||
unsigned char a;
|
unsigned char a;
|
||||||
} Color;
|
} Color;
|
||||||
|
|
||||||
// Rectangle type
|
|
||||||
typedef struct Rectangle {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
} Rectangle;
|
|
||||||
|
|
||||||
// Texture2D type
|
// Texture2D type
|
||||||
// NOTE: Data stored in GPU memory
|
// NOTE: Data stored in GPU memory
|
||||||
typedef struct Texture2D {
|
typedef struct Texture2D {
|
||||||
|
@ -703,9 +695,9 @@ typedef struct DrawCall {
|
||||||
typedef struct VrStereoConfig {
|
typedef struct VrStereoConfig {
|
||||||
RenderTexture2D stereoFbo; // VR stereo rendering framebuffer
|
RenderTexture2D stereoFbo; // VR stereo rendering framebuffer
|
||||||
Shader distortionShader; // VR stereo rendering distortion shader
|
Shader distortionShader; // VR stereo rendering distortion shader
|
||||||
Rectangle eyesViewport[2]; // VR stereo rendering eyes viewports
|
|
||||||
Matrix eyesProjection[2]; // VR stereo rendering eyes projection matrices
|
Matrix eyesProjection[2]; // VR stereo rendering eyes projection matrices
|
||||||
Matrix eyesViewOffset[2]; // VR stereo rendering eyes view offset matrices
|
Matrix eyesViewOffset[2]; // VR stereo rendering eyes view offset matrices
|
||||||
|
int eyesViewport[2][4]; // VR stereo rendering eyes viewports [x, y, w, h]
|
||||||
} VrStereoConfig;
|
} VrStereoConfig;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4268,8 +4260,8 @@ static void SetStereoConfig(VrDeviceInfo hmd)
|
||||||
vrConfig.eyesViewOffset[1] = MatrixTranslate(hmd.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
vrConfig.eyesViewOffset[1] = MatrixTranslate(hmd.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
||||||
|
|
||||||
// Compute eyes Viewports
|
// Compute eyes Viewports
|
||||||
vrConfig.eyesViewport[0] = (Rectangle){ 0.0f, 0.0f, (float)hmd.hResolution/2, (float)hmd.vResolution };
|
//vrConfig.eyesViewport[0] = { 0.0f, 0.0f, (float)hmd.hResolution/2, (float)hmd.vResolution };
|
||||||
vrConfig.eyesViewport[1] = (Rectangle){ hmd.hResolution/2.0f, 0.0f, (float)hmd.hResolution/2, (float) hmd.vResolution };
|
//vrConfig.eyesViewport[1] = { hmd.hResolution/2.0f, 0.0f, (float)hmd.hResolution/2, (float) hmd.vResolution };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set internal projection and modelview matrix depending on eyes tracking data
|
// Set internal projection and modelview matrix depending on eyes tracking data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue