From 3db2bcf7e532b2f6bb07faf1cf5d0deacc9c0bb3 Mon Sep 17 00:00:00 2001 From: Guy Zadickario Date: Mon, 4 Jul 2011 22:30:58 +0300 Subject: [PATCH] opengl translator: fixed normalized vertex attribs That fixes the alpha and GUI components artifacts in Cordy. The translator has ignored the 'normalized' argument of glVertexAttribPointer function in GLESv2. We now use the supplied value when applying the vertex attributes to the backend OpenGL so that non-float color vertex attributes are now normalized. Change-Id: Idffda33225748276144ed70d2dcf4da17219d1d2 --- .../host/libs/Translator/GLES_CM/GLEScmContext.cpp | 6 +++--- .../opengl/host/libs/Translator/GLES_CM/GLEScmContext.h | 2 +- .../host/libs/Translator/GLES_V2/GLESv2Context.cpp | 9 +++++---- .../opengl/host/libs/Translator/GLES_V2/GLESv2Context.h | 2 +- .../host/libs/Translator/include/GLcommon/GLEScontext.h | 2 +- .../host/libs/Translator/include/GLcommon/GLESpointer.h | 1 + 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp index 1df4b5db1..67aef7904 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp @@ -63,7 +63,7 @@ GLEScmContext::~GLEScmContext(){ //setting client side arr -void GLEScmContext::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,int index){ +void GLEScmContext::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int index){ if( arr == NULL) return; switch(arrayType) { case GL_VERTEX_ARRAY: @@ -92,10 +92,10 @@ void GLEScmContext::setupArrayPointerHelper(GLESConversionArrays& cArrs,GLint fi if(needConvert(cArrs,first,count,type,indices,direct,p,array_id)){ //conversion has occured ArrayData currentArr = cArrs.getCurrentArray(); - setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride,cArrs.getCurrentIndex()); + setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride,GL_FALSE, cArrs.getCurrentIndex()); ++cArrs; } else { - setupArr(p->getData(),array_id,dataType,size,p->getStride()); + setupArr(p->getData(),array_id,dataType,size,p->getStride(), GL_FALSE); } } diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h index 2bc08c0b4..1785877ba 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h @@ -55,7 +55,7 @@ protected: bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id); private: void setupArrayPointerHelper(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLenum array_id,GLESpointer* p); - void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,int pointsIndex = -1); + void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int pointsIndex = -1); void drawPoints(PointSizeIndices* points); void drawPointsData(GLESConversionArrays& arrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw); void initExtensionString(); diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp index 17dd0497a..bd52ee5d6 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp @@ -46,18 +46,19 @@ void GLESv2Context::setupArraysPointers(GLESConversionArrays& cArrs,GLint first, if(needConvert(cArrs,first,count,type,indices,direct,p,array_id)){ //conversion has occured ArrayData currentArr = cArrs.getCurrentArray(); - setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride); + setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride, p->getNormalized()); ++cArrs; } else { - setupArr(p->getData(),array_id,p->getType(),size,p->getStride()); + setupArr(p->getData(),array_id,p->getType(), + size,p->getStride(), p->getNormalized()); } } } //setting client side arr -void GLESv2Context::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,int index){ +void GLESv2Context::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int index){ if(arr == NULL) return; - s_glDispatch.glVertexAttribPointer(arrayType,size,dataType,GL_FALSE,stride,arr); + s_glDispatch.glVertexAttribPointer(arrayType,size,dataType,normalized,stride,arr); } bool GLESv2Context::needConvert(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) { diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h index 28cdbe9c4..a8d7f3a24 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h @@ -33,7 +33,7 @@ public: protected: bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id); private: - void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,int pointsIndex = -1); + void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int pointsIndex = -1); void initExtensionString(); }; diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h index a2d6f9394..3b5400701 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h @@ -159,7 +159,7 @@ protected: private: - virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,int pointsIndex = -1) = 0 ; + virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ; GLuint getBuffer(GLenum target); ShareGroupPtr m_shareGroup; diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h index b39c1032f..851fe451a 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h @@ -30,6 +30,7 @@ public: const GLvoid* getArrayData() const; GLvoid* getBufferData() const; GLuint getBufferName() const; + GLboolean getNormalized() const { return m_normalize ? GL_TRUE : GL_FALSE; } const GLvoid* getData() const; unsigned int getBufferOffset() const; void redirectPointerData();