[client] opengl: fixed incorrect colors and added 10-bit RGBA support

This commit is contained in:
Geoffrey McRae 2018-12-12 10:55:18 +11:00
parent d2b83027b4
commit 4654f317ca
3 changed files with 37 additions and 7 deletions

View File

@ -74,7 +74,17 @@ static void lgd_null_deinitialize(void * opaque)
static LG_OutFormat lgd_null_get_out_format(void * opaque) static LG_OutFormat lgd_null_get_out_format(void * opaque)
{ {
return LG_OUTPUT_BGRA; struct Inst * this = (struct Inst *)opaque;
switch(this->format.type)
{
case FRAME_TYPE_BGRA : return LG_OUTPUT_BGRA;
case FRAME_TYPE_RGBA : return LG_OUTPUT_RGBA;
case FRAME_TYPE_RGBA10: return LG_OUTPUT_RGBA10;
default:
DEBUG_ERROR("Unknown frame type");
return LG_OUTPUT_INVALID;
}
} }
static unsigned int lgd_null_get_frame_pitch(void * opaque) static unsigned int lgd_null_get_frame_pitch(void * opaque)

View File

@ -29,7 +29,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
typedef enum LG_OutFormat typedef enum LG_OutFormat
{ {
LG_OUTPUT_INVALID,
LG_OUTPUT_BGRA, LG_OUTPUT_BGRA,
LG_OUTPUT_RGBA,
LG_OUTPUT_RGBA10,
LG_OUTPUT_YUV420 LG_OUTPUT_YUV420
} }
LG_OutFormat; LG_OutFormat;

View File

@ -96,6 +96,7 @@ struct Inst
LG_RendererFormat format; LG_RendererFormat format;
GLuint intFormat; GLuint intFormat;
GLuint vboFormat; GLuint vboFormat;
GLuint dataFormat;
size_t texSize; size_t texSize;
const LG_Decoder* decoder; const LG_Decoder* decoder;
void * decoderData; void * decoderData;
@ -880,6 +881,7 @@ static bool configure(struct Inst * this, SDL_Window *window)
{ {
case FRAME_TYPE_BGRA: case FRAME_TYPE_BGRA:
case FRAME_TYPE_RGBA: case FRAME_TYPE_RGBA:
case FRAME_TYPE_RGBA10:
this->decoder = &LGD_NULL; this->decoder = &LGD_NULL;
break; break;
@ -912,14 +914,28 @@ static bool configure(struct Inst * this, SDL_Window *window)
switch(this->decoder->get_out_format(this->decoderData)) switch(this->decoder->get_out_format(this->decoderData))
{ {
case LG_OUTPUT_BGRA: case LG_OUTPUT_BGRA:
this->intFormat = GL_RGBA8; this->intFormat = GL_RGBA8;
this->vboFormat = GL_BGRA; this->vboFormat = GL_BGRA;
this->dataFormat = GL_UNSIGNED_BYTE;
break;
case LG_OUTPUT_RGBA:
this->intFormat = GL_RGBA8;
this->vboFormat = GL_RGBA;
this->dataFormat = GL_UNSIGNED_BYTE;
break;
case LG_OUTPUT_RGBA10:
this->intFormat = GL_RGB10_A2;
this->vboFormat = GL_RGBA;
this->dataFormat = GL_UNSIGNED_INT_2_10_10_10_REV;
break; break;
case LG_OUTPUT_YUV420: case LG_OUTPUT_YUV420:
// fixme // fixme
this->intFormat = GL_RGBA8; this->intFormat = GL_RGBA8;
this->vboFormat = GL_BGRA; this->vboFormat = GL_BGRA;
this->dataFormat = GL_UNSIGNED_BYTE;
break; break;
default: default:
@ -1029,7 +1045,7 @@ static bool configure(struct Inst * this, SDL_Window *window)
this->format.height, this->format.height,
0, 0,
this->vboFormat, this->vboFormat,
GL_UNSIGNED_BYTE, this->dataFormat,
(void*)0 (void*)0
); );
if (check_gl_error("glTexImage2D")) if (check_gl_error("glTexImage2D"))
@ -1380,7 +1396,7 @@ static bool draw_frame(struct Inst * this)
this->format.width , this->format.width ,
this->format.height, this->format.height,
this->vboFormat, this->vboFormat,
GL_UNSIGNED_BYTE, this->dataFormat,
(void*)0 (void*)0
); );
if (check_gl_error("glTexSubImage2D")) if (check_gl_error("glTexSubImage2D"))