(GL1) Buildfix + cleanups

This commit is contained in:
twinaphex 2019-10-01 03:14:18 +02:00
parent b0b3abe775
commit 547f8968aa

View File

@ -546,9 +546,11 @@ void gl1_gfx_set_viewport(gl1_t *gl1,
static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int height, GLuint tex, const void *frame_to_copy)
{
uint8_t *frame = NULL;
uint8_t *frame_rgba = NULL;
/* FIXME: For now, everything is uploaded as BGRA8888, I could not get 444 or 555 to work, and there is no 565 support in GL 1.1 either. */
GLint internalFormat = GL_RGB8;
GLenum format = (gl1->supports_bgra ? GL_BGRA_EXT : GL_RGBA);
GLenum format = gl1->supports_bgra ? GL_BGRA_EXT : GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
glDisable(GL_DEPTH_TEST);
@ -557,7 +559,7 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
glDisable(GL_SCISSOR_TEST);
glEnable(GL_TEXTURE_2D);
/* multi-texture not part of GL 1.1 */
/* Multi-texture not part of GL 1.1 */
/*glActiveTexture(GL_TEXTURE0);*/
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@ -568,14 +570,17 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
so we send the frame as dummy data */
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, pot_width, pot_height, 0, format, type, frame_to_copy);
uint8_t *frame = (uint8_t*)frame_to_copy;
uint8_t *frame_rgba = NULL;
if (!gl1->supports_bgra) {
frame = (uint8_t*)frame_to_copy;
if (!gl1->supports_bgra)
{
frame_rgba = (uint8_t*)malloc(pot_width * pot_height * 4);
if (frame_rgba) {
if (frame_rgba)
{
int x, y;
for (y = 0; y < pot_height; y++) {
for (x = 0; x < pot_width; x++) {
for (y = 0; y < pot_height; y++)
{
for (x = 0; x < pot_width; x++)
{
int index = (y * pot_width + x) * 4;
frame_rgba[index + 2] = frame[index + 0];
frame_rgba[index + 1] = frame[index + 1];