Support GLDirect (D3D9 to OGL1.1 wrapper) in gl1 driver

This commit is contained in:
driver1998 2019-10-01 05:59:31 +08:00 committed by GH Cao
parent 109adf9739
commit 0212567d75

View File

@ -564,9 +564,31 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
glPixelStorei(GL_UNPACK_ROW_LENGTH, pot_width);
glBindTexture(GL_TEXTURE_2D, tex);
/* TODO: We could implement red/blue swap if client GL does not support BGRA... but even MS GDI Generic supports it */
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, pot_width, pot_height, 0, format, type, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, frame_to_copy);
/* For whatever reason you can't send NULL in GLDirect,
so we send the frame as dummy data */
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, pot_width, pot_height, 0, format, type, frame_to_copy);
if (!gl1->supports_bgra) {
uint8_t* frame_rgba = malloc(pot_width * pot_height * 4);
uint8_t* frame_bgra = frame_to_copy;
for (int y = 0; y < pot_height; y++) {
for (int x = 0; x < pot_width; x++) {
int index = (y * pot_width + x) * 4;
frame_rgba[index + 2] = frame_bgra[index + 0];
frame_rgba[index + 1] = frame_bgra[index + 1];
frame_rgba[index + 0] = frame_bgra[index + 2];
frame_rgba[index + 3] = 255;
}
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, type, frame_rgba);
free(frame_rgba);
}
else {
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, frame_to_copy);
}
if (tex == gl1->tex)
{