Fix colors in OpenGL.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
030d6d5a62
commit
b4f6d64034
2 changed files with 11 additions and 10 deletions
|
@ -12,8 +12,9 @@
|
|||
#define SA2_CONTEXT_MAJOR_VERSION 2
|
||||
#define SA2_CONTEXT_MINOR_VERSION 0
|
||||
|
||||
// this is defined in gl2ext.h and nowhere in gl3.h
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
|
||||
// this is defined in gl2ext.h and nowhere in gl3.h
|
||||
#define SA2_IMAGE_FORMAT_INTERNAL GL_BGRA_EXT
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
|
||||
|
||||
// this is used in all cases for GL_BGRA_EXT
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
@ -35,7 +36,8 @@
|
|||
#define SA2_CONTEXT_MINOR_VERSION 0
|
||||
|
||||
// this is defined in gl2ext.h and nowhere in gl3.h
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
|
||||
#define SA2_IMAGE_FORMAT_INTERNAL GL_BGRA_EXT
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
|
||||
|
||||
// "310 es" is accepted on a Pi4, but the imgui shaders do not compile
|
||||
// this is used in all cases for GL_BGRA_EXT
|
||||
|
@ -49,7 +51,8 @@
|
|||
#define SA2_CONTEXT_MAJOR_VERSION 3
|
||||
#define SA2_CONTEXT_MINOR_VERSION 2
|
||||
|
||||
#define SA2_IMAGE_FORMAT GL_RGBA
|
||||
#define SA2_IMAGE_FORMAT_INTERNAL GL_RGBA
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA
|
||||
|
||||
#else
|
||||
|
||||
|
@ -59,7 +62,8 @@
|
|||
#define SA2_CONTEXT_MAJOR_VERSION 3
|
||||
#define SA2_CONTEXT_MINOR_VERSION 2
|
||||
|
||||
#define SA2_IMAGE_FORMAT GL_RGBA
|
||||
#define SA2_IMAGE_FORMAT_INTERNAL GL_RGBA
|
||||
#define SA2_IMAGE_FORMAT GL_BGRA
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,10 +31,8 @@ namespace sa2
|
|||
{
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
const GLenum format = SA2_IMAGE_FORMAT;
|
||||
const GLenum type = GL_UNSIGNED_BYTE;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, type, nullptr);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, SA2_IMAGE_FORMAT_INTERNAL, width, height, 0, SA2_IMAGE_FORMAT, type, nullptr);
|
||||
}
|
||||
|
||||
void loadTextureFromData(GLuint texture, const uint8_t * data, size_t width, size_t height, size_t pitch)
|
||||
|
@ -48,9 +46,8 @@ namespace sa2
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
const GLenum format = SA2_IMAGE_FORMAT;
|
||||
const GLenum type = GL_UNSIGNED_BYTE;
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, data);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, SA2_IMAGE_FORMAT, type, data);
|
||||
// reset to default state
|
||||
glPixelStorei(UGL_UNPACK_LENGTH, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue