From 4654f317ca862a0910c9167eef72599844519cb7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 12 Dec 2018 10:55:18 +1100 Subject: [PATCH] [client] opengl: fixed incorrect colors and added 10-bit RGBA support --- client/decoders/null.c | 12 +++++++++++- client/lg-decoder.h | 4 ++++ client/renderers/opengl.c | 28 ++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/client/decoders/null.c b/client/decoders/null.c index 26da3b5a..89842783 100644 --- a/client/decoders/null.c +++ b/client/decoders/null.c @@ -74,7 +74,17 @@ static void lgd_null_deinitialize(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) diff --git a/client/lg-decoder.h b/client/lg-decoder.h index 0c8bdcbd..714ac5af 100644 --- a/client/lg-decoder.h +++ b/client/lg-decoder.h @@ -29,7 +29,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA typedef enum LG_OutFormat { + LG_OUTPUT_INVALID, + LG_OUTPUT_BGRA, + LG_OUTPUT_RGBA, + LG_OUTPUT_RGBA10, LG_OUTPUT_YUV420 } LG_OutFormat; diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index e4316575..c458879c 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -96,6 +96,7 @@ struct Inst LG_RendererFormat format; GLuint intFormat; GLuint vboFormat; + GLuint dataFormat; size_t texSize; const LG_Decoder* decoder; void * decoderData; @@ -880,6 +881,7 @@ static bool configure(struct Inst * this, SDL_Window *window) { case FRAME_TYPE_BGRA: case FRAME_TYPE_RGBA: + case FRAME_TYPE_RGBA10: this->decoder = &LGD_NULL; break; @@ -912,14 +914,28 @@ static bool configure(struct Inst * this, SDL_Window *window) switch(this->decoder->get_out_format(this->decoderData)) { case LG_OUTPUT_BGRA: - this->intFormat = GL_RGBA8; - this->vboFormat = GL_BGRA; + this->intFormat = GL_RGBA8; + 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; case LG_OUTPUT_YUV420: // fixme - this->intFormat = GL_RGBA8; - this->vboFormat = GL_BGRA; + this->intFormat = GL_RGBA8; + this->vboFormat = GL_BGRA; + this->dataFormat = GL_UNSIGNED_BYTE; break; default: @@ -1029,7 +1045,7 @@ static bool configure(struct Inst * this, SDL_Window *window) this->format.height, 0, this->vboFormat, - GL_UNSIGNED_BYTE, + this->dataFormat, (void*)0 ); if (check_gl_error("glTexImage2D")) @@ -1380,7 +1396,7 @@ static bool draw_frame(struct Inst * this) this->format.width , this->format.height, this->vboFormat, - GL_UNSIGNED_BYTE, + this->dataFormat, (void*)0 ); if (check_gl_error("glTexSubImage2D"))