mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 21:32:40 +02:00
OpenGL examples: pass correct context creation configuration
This commit is contained in:
parent
012423e429
commit
1643d44dee
@ -121,14 +121,14 @@ static bool initEgl()
|
|||||||
// Get an appropriate EGL framebuffer configuration
|
// Get an appropriate EGL framebuffer configuration
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
static const EGLint attributeList[] =
|
static const EGLint framebufferAttributeList[] =
|
||||||
{
|
{
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
eglChooseConfig(s_display, attributeList, &config, 1, &numConfigs);
|
eglChooseConfig(s_display, framebufferAttributeList, &config, 1, &numConfigs);
|
||||||
if (numConfigs == 0)
|
if (numConfigs == 0)
|
||||||
{
|
{
|
||||||
TRACE("No config found! error: %d", eglGetError());
|
TRACE("No config found! error: %d", eglGetError());
|
||||||
@ -144,7 +144,12 @@ static bool initEgl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an EGL rendering context
|
// Create an EGL rendering context
|
||||||
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, NULL);
|
static const EGLint contextAttributeList[] =
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 2, // request OpenGL ES 2.x
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, contextAttributeList);
|
||||||
if (!s_context)
|
if (!s_context)
|
||||||
{
|
{
|
||||||
TRACE("Context creation failed! error: %d", eglGetError());
|
TRACE("Context creation failed! error: %d", eglGetError());
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include <EGL/egl.h> // EGL library
|
#include <EGL/egl.h> // EGL library
|
||||||
|
#include <EGL/eglext.h> // EGL extensions
|
||||||
#include <glad/glad.h> // glad library (OpenGL loader)
|
#include <glad/glad.h> // glad library (OpenGL loader)
|
||||||
|
|
||||||
// GLM headers
|
// GLM headers
|
||||||
@ -96,14 +97,14 @@ static bool initEgl()
|
|||||||
// Get an appropriate EGL framebuffer configuration
|
// Get an appropriate EGL framebuffer configuration
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
static const EGLint attributeList[] =
|
static const EGLint framebufferAttributeList[] =
|
||||||
{
|
{
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
eglChooseConfig(s_display, attributeList, &config, 1, &numConfigs);
|
eglChooseConfig(s_display, framebufferAttributeList, &config, 1, &numConfigs);
|
||||||
if (numConfigs == 0)
|
if (numConfigs == 0)
|
||||||
{
|
{
|
||||||
TRACE("No config found! error: %d", eglGetError());
|
TRACE("No config found! error: %d", eglGetError());
|
||||||
@ -119,7 +120,14 @@ static bool initEgl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an EGL rendering context
|
// Create an EGL rendering context
|
||||||
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, nullptr);
|
static const EGLint contextAttributeList[] =
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
||||||
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 4,
|
||||||
|
EGL_CONTEXT_MINOR_VERSION_KHR, 3,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, contextAttributeList);
|
||||||
if (!s_context)
|
if (!s_context)
|
||||||
{
|
{
|
||||||
TRACE("Context creation failed! error: %d", eglGetError());
|
TRACE("Context creation failed! error: %d", eglGetError());
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include <EGL/egl.h> // EGL library
|
#include <EGL/egl.h> // EGL library
|
||||||
|
#include <EGL/eglext.h> // EGL extensions
|
||||||
#include <glad/glad.h> // glad library (OpenGL loader)
|
#include <glad/glad.h> // glad library (OpenGL loader)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -83,14 +84,14 @@ static bool initEgl()
|
|||||||
// Get an appropriate EGL framebuffer configuration
|
// Get an appropriate EGL framebuffer configuration
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
static const EGLint attributeList[] =
|
static const EGLint framebufferAttributeList[] =
|
||||||
{
|
{
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
eglChooseConfig(s_display, attributeList, &config, 1, &numConfigs);
|
eglChooseConfig(s_display, framebufferAttributeList, &config, 1, &numConfigs);
|
||||||
if (numConfigs == 0)
|
if (numConfigs == 0)
|
||||||
{
|
{
|
||||||
TRACE("No config found! error: %d", eglGetError());
|
TRACE("No config found! error: %d", eglGetError());
|
||||||
@ -106,7 +107,14 @@ static bool initEgl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an EGL rendering context
|
// Create an EGL rendering context
|
||||||
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, nullptr);
|
static const EGLint contextAttributeList[] =
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
||||||
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 4,
|
||||||
|
EGL_CONTEXT_MINOR_VERSION_KHR, 3,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, contextAttributeList);
|
||||||
if (!s_context)
|
if (!s_context)
|
||||||
{
|
{
|
||||||
TRACE("Context creation failed! error: %d", eglGetError());
|
TRACE("Context creation failed! error: %d", eglGetError());
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include <EGL/egl.h> // EGL library
|
#include <EGL/egl.h> // EGL library
|
||||||
|
#include <EGL/eglext.h> // EGL extensions
|
||||||
#include <glad/glad.h> // glad library (OpenGL loader)
|
#include <glad/glad.h> // glad library (OpenGL loader)
|
||||||
|
|
||||||
// GLM headers
|
// GLM headers
|
||||||
@ -96,14 +97,14 @@ static bool initEgl()
|
|||||||
// Get an appropriate EGL framebuffer configuration
|
// Get an appropriate EGL framebuffer configuration
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
static const EGLint attributeList[] =
|
static const EGLint framebufferAttributeList[] =
|
||||||
{
|
{
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
eglChooseConfig(s_display, attributeList, &config, 1, &numConfigs);
|
eglChooseConfig(s_display, framebufferAttributeList, &config, 1, &numConfigs);
|
||||||
if (numConfigs == 0)
|
if (numConfigs == 0)
|
||||||
{
|
{
|
||||||
TRACE("No config found! error: %d", eglGetError());
|
TRACE("No config found! error: %d", eglGetError());
|
||||||
@ -119,7 +120,14 @@ static bool initEgl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an EGL rendering context
|
// Create an EGL rendering context
|
||||||
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, nullptr);
|
static const EGLint contextAttributeList[] =
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
||||||
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 4,
|
||||||
|
EGL_CONTEXT_MINOR_VERSION_KHR, 3,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, contextAttributeList);
|
||||||
if (!s_context)
|
if (!s_context)
|
||||||
{
|
{
|
||||||
TRACE("Context creation failed! error: %d", eglGetError());
|
TRACE("Context creation failed! error: %d", eglGetError());
|
||||||
|
Loading…
Reference in New Issue
Block a user