* commit '1251787f846dd73ff1cc739064947586a98f301f': implement GL_OES_draw_texture
This commit is contained in:
@@ -29,11 +29,11 @@ void GLEScmContext::init() {
|
||||
initExtensionString();
|
||||
}
|
||||
m_texCoords = new GLESpointer[s_glSupport.maxTexUnits];
|
||||
m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_activeTexture];
|
||||
m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture];
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
GLEScmContext::GLEScmContext():GLEScontext(),m_pointsIndex(-1){
|
||||
GLEScmContext::GLEScmContext():GLEScontext(),m_pointsIndex(-1), m_clientActiveTexture(0) {
|
||||
|
||||
m_map[GL_COLOR_ARRAY] = new GLESpointer();
|
||||
m_map[GL_NORMAL_ARRAY] = new GLESpointer();
|
||||
@@ -44,7 +44,11 @@ GLEScmContext::GLEScmContext():GLEScontext(),m_pointsIndex(-1){
|
||||
|
||||
void GLEScmContext::setActiveTexture(GLenum tex) {
|
||||
m_activeTexture = tex - GL_TEXTURE0;
|
||||
m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_activeTexture];
|
||||
}
|
||||
|
||||
void GLEScmContext::setClientActiveTexture(GLenum tex) {
|
||||
m_clientActiveTexture = tex - GL_TEXTURE0;
|
||||
m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture];
|
||||
}
|
||||
|
||||
GLEScmContext::~GLEScmContext(){
|
||||
@@ -90,7 +94,7 @@ void GLEScmContext::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count
|
||||
chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
|
||||
}
|
||||
|
||||
unsigned int activeTexture = m_activeTexture + GL_TEXTURE0;
|
||||
unsigned int activeTexture = m_clientActiveTexture + GL_TEXTURE0;
|
||||
|
||||
s_lock.lock();
|
||||
int maxTexUnits = s_glSupport.maxTexUnits;
|
||||
@@ -100,7 +104,7 @@ void GLEScmContext::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count
|
||||
for(int i=0; i< maxTexUnits;i++) {
|
||||
|
||||
unsigned int tex = GL_TEXTURE0+i;
|
||||
setActiveTexture(tex);
|
||||
setClientActiveTexture(tex);
|
||||
s_glDispatch.glClientActiveTexture(tex);
|
||||
|
||||
GLenum array_id = GL_TEXTURE_COORD_ARRAY;
|
||||
@@ -108,7 +112,7 @@ void GLEScmContext::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count
|
||||
chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
|
||||
}
|
||||
|
||||
setActiveTexture(activeTexture);
|
||||
setClientActiveTexture(activeTexture);
|
||||
s_glDispatch.glClientActiveTexture(activeTexture);
|
||||
}
|
||||
|
||||
@@ -181,7 +185,7 @@ void GLEScmContext::initExtensionString() {
|
||||
"GL_OES_byte_coordinates GL_OES_compressed_paletted_texture GL_OES_point_size_array "
|
||||
"GL_OES_point_sprite GL_OES_single_precision GL_OES_stencil_wrap GL_OES_texture_env_crossbar "
|
||||
"GL_OES_texture_mirored_repeat GL_OES_EGL_image GL_OES_element_index_uint GL_OES_draw_texture "
|
||||
"GL_OES_texture_cube_map ";
|
||||
"GL_OES_texture_cube_map GL_OES_draw_texture ";
|
||||
if (s_glSupport.GL_OES_READ_FORMAT)
|
||||
*s_glExtensions+="GL_OES_read_format ";
|
||||
if (s_glSupport.GL_EXT_FRAMEBUFFER_OBJECT) {
|
||||
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
GLEScmContext();
|
||||
|
||||
void setActiveTexture(GLenum tex);
|
||||
void setClientActiveTexture(GLenum tex);
|
||||
GLenum getActiveTexture() { return GL_TEXTURE0 + m_activeTexture;};
|
||||
GLenum getClientActiveTexture() { return GL_TEXTURE0 + m_clientActiveTexture;};
|
||||
void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct);
|
||||
void drawPointsArrs(GLESFloatArrays& arrs,GLint first,GLsizei count);
|
||||
void drawPointsElems(GLESFloatArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices);
|
||||
@@ -49,6 +52,7 @@ private:
|
||||
|
||||
GLESpointer* m_texCoords;
|
||||
int m_pointsIndex;
|
||||
unsigned int m_clientActiveTexture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#undef GL_API
|
||||
#define GL_API __declspec(dllexport)
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "GLEScmContext.h"
|
||||
#include "GLEScmValidate.h"
|
||||
#include "GLEScmUtils.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
#include <GLcommon/TranslatorIfaces.h>
|
||||
#include <GLcommon/ThreadInfo.h>
|
||||
#include <GLES/gl.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GLES/glext.h>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
@@ -138,6 +138,14 @@ static __translatorMustCastToProperFunctionPointerType getProcAddress(const char
|
||||
(*s_glesExtensions)["glGetFramebufferAttachmentParameterivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetFramebufferAttachmentParameterivOES;
|
||||
(*s_glesExtensions)["glGenerateMipmapOES"] = (__translatorMustCastToProperFunctionPointerType)glGenerateMipmapOES;
|
||||
}
|
||||
(*s_glesExtensions)["glDrawTexsOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsOES;
|
||||
(*s_glesExtensions)["glDrawTexiOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexiOES;
|
||||
(*s_glesExtensions)["glDrawTexfOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfOES;
|
||||
(*s_glesExtensions)["glDrawTexxOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxOES;
|
||||
(*s_glesExtensions)["glDrawTexsvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsvOES;
|
||||
(*s_glesExtensions)["glDrawTexivOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexivOES;
|
||||
(*s_glesExtensions)["glDrawTexfvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfvOES;
|
||||
(*s_glesExtensions)["glDrawTexxvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxvOES;
|
||||
}
|
||||
__translatorMustCastToProperFunctionPointerType ret=NULL;
|
||||
ProcTableMap::iterator val = s_glesExtensions->find(procName);
|
||||
@@ -155,6 +163,22 @@ GLESiface* __translator_getIfaces(EGLiface* eglIface){
|
||||
|
||||
}
|
||||
|
||||
static TextureData* getTextureData(){
|
||||
GET_CTX_RET(NULL);
|
||||
unsigned int tex = ctx->getBindedTexture();
|
||||
if (tex==0)
|
||||
return NULL;
|
||||
TextureData *texData = NULL;
|
||||
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
|
||||
if(!objData.Ptr()){
|
||||
texData = new TextureData();
|
||||
thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
|
||||
} else {
|
||||
texData = (TextureData*)objData.Ptr();
|
||||
}
|
||||
return texData;
|
||||
}
|
||||
|
||||
GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) {
|
||||
GET_CTX_RET(GL_FALSE)
|
||||
|
||||
@@ -222,6 +246,7 @@ GL_API const GLubyte * GL_APIENTRY glGetString( GLenum name) {
|
||||
GL_API void GL_APIENTRY glActiveTexture( GLenum texture) {
|
||||
GET_CTX_CM()
|
||||
SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
|
||||
ctx->setActiveTexture(texture);
|
||||
ctx->dispatcher().glActiveTexture(texture);
|
||||
}
|
||||
|
||||
@@ -267,7 +292,7 @@ GL_API void GL_APIENTRY glBindTexture( GLenum target, GLuint texture) {
|
||||
globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
|
||||
}
|
||||
}
|
||||
ctx->setBindedTexture(globalTextureName);
|
||||
ctx->setBindedTexture(texture);
|
||||
ctx->dispatcher().glBindTexture(target,globalTextureName);
|
||||
}
|
||||
|
||||
@@ -325,7 +350,7 @@ GL_API void GL_APIENTRY glClearStencil( GLint s) {
|
||||
GL_API void GL_APIENTRY glClientActiveTexture( GLenum texture) {
|
||||
GET_CTX_CM()
|
||||
SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
|
||||
ctx->setActiveTexture(texture);
|
||||
ctx->setClientActiveTexture(texture);
|
||||
ctx->dispatcher().glClientActiveTexture(texture);
|
||||
|
||||
}
|
||||
@@ -476,8 +501,11 @@ GL_API void GL_APIENTRY glDisable( GLenum cap) {
|
||||
ctx->dispatcher().glDisable(GL_TEXTURE_GEN_T);
|
||||
ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R);
|
||||
}
|
||||
else
|
||||
ctx->dispatcher().glDisable(cap);
|
||||
if (cap==GL_TEXTURE_2D)
|
||||
ctx->setTextureEnabled(TEXTURE_2D,false);
|
||||
else if (cap==GL_TEXTURE_CUBE_MAP_OES)
|
||||
ctx->setTextureEnabled(TEXTURE_CUBE_MAP,false);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDisableClientState( GLenum array) {
|
||||
@@ -537,6 +565,10 @@ GL_API void GL_APIENTRY glEnable( GLenum cap) {
|
||||
}
|
||||
else
|
||||
ctx->dispatcher().glEnable(cap);
|
||||
if (cap==GL_TEXTURE_2D)
|
||||
ctx->setTextureEnabled(TEXTURE_2D,true);
|
||||
else if (cap==GL_TEXTURE_CUBE_MAP_OES)
|
||||
ctx->setTextureEnabled(TEXTURE_CUBE_MAP,true);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glEnableClientState( GLenum array) {
|
||||
@@ -858,19 +890,43 @@ GL_API void GL_APIENTRY glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *param
|
||||
|
||||
GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) {
|
||||
GET_CTX()
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
params[i] = texData->crop_rect[i];
|
||||
}
|
||||
else {
|
||||
ctx->dispatcher().glGetTexParameterfv(target,pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) {
|
||||
GET_CTX()
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
params[i] = texData->crop_rect[i];
|
||||
}
|
||||
else {
|
||||
ctx->dispatcher().glGetTexParameteriv(target,pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) {
|
||||
GET_CTX()
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
params[i] = F2X(texData->crop_rect[i]);
|
||||
}
|
||||
else {
|
||||
GLfloat tmpParam;
|
||||
ctx->dispatcher().glGetTexParameterfv(target,pname,&tmpParam);
|
||||
params[0] = static_cast<GLfixed>(tmpParam);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glHint( GLenum target, GLenum mode) {
|
||||
@@ -1252,20 +1308,6 @@ GL_API void GL_APIENTRY glTexEnvxv( GLenum target, GLenum pname, const GLfixed
|
||||
ctx->dispatcher().glTexEnvfv(target,pname,tmpParams);
|
||||
}
|
||||
|
||||
static TextureData* getTextureData(){
|
||||
GET_CTX_RET(NULL);
|
||||
unsigned int tex = ctx->getBindedTexture();
|
||||
TextureData *texData = NULL;
|
||||
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
|
||||
if(!objData.Ptr()){
|
||||
texData = new TextureData();
|
||||
thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
|
||||
} else {
|
||||
texData = (TextureData*)objData.Ptr();
|
||||
}
|
||||
return texData;
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
|
||||
GET_CTX()
|
||||
|
||||
@@ -1277,8 +1319,8 @@ GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint interna
|
||||
SET_ERROR_IF(!(GLEScmValidate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION);
|
||||
|
||||
if (thrd->shareGroup.Ptr()){
|
||||
unsigned int tex = ctx->getBindedTexture();
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
if(texData) {
|
||||
texData->width = width;
|
||||
texData->height = height;
|
||||
@@ -1298,7 +1340,15 @@ GL_API void GL_APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat p
|
||||
GL_API void GL_APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params) {
|
||||
GET_CTX()
|
||||
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
texData->crop_rect[i] = params[i];
|
||||
}
|
||||
else {
|
||||
ctx->dispatcher().glTexParameterfv(target,pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param) {
|
||||
@@ -1310,7 +1360,15 @@ GL_API void GL_APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint par
|
||||
GL_API void GL_APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GLint *params) {
|
||||
GET_CTX()
|
||||
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
texData->crop_rect[i] = params[i];
|
||||
}
|
||||
else {
|
||||
ctx->dispatcher().glTexParameteriv(target,pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed param) {
|
||||
@@ -1322,8 +1380,16 @@ GL_API void GL_APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed p
|
||||
GL_API void GL_APIENTRY glTexParameterxv( GLenum target, GLenum pname, const GLfixed *params) {
|
||||
GET_CTX()
|
||||
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
|
||||
if (pname==GL_TEXTURE_CROP_RECT_OES) {
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
for (int i=0;i<4;++i)
|
||||
texData->crop_rect[i] = X2F(params[i]);
|
||||
}
|
||||
else {
|
||||
GLfloat param = static_cast<GLfloat>(params[0]);
|
||||
ctx->dispatcher().glTexParameterfv(target,pname,¶m);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) {
|
||||
@@ -1379,6 +1445,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
|
||||
thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
|
||||
ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
|
||||
TextureData *texData = getTextureData();
|
||||
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
|
||||
texData->sourceEGLImage = (unsigned int)image;
|
||||
texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
|
||||
}
|
||||
@@ -1702,3 +1769,127 @@ GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *p
|
||||
|
||||
params[0] = F2X(tmpParams[1]);
|
||||
}
|
||||
|
||||
template <class T, GLenum TypeName>
|
||||
void glDrawTexOES (T x, T y, T z, T width, T height) {
|
||||
GET_CTX()
|
||||
int numClipPlanes;
|
||||
|
||||
GLint viewport[4];
|
||||
z = (z>1 ? 1 : (z<0 ? 0 : z));
|
||||
|
||||
T vertices[4*3] = {x , y, z,
|
||||
x , y+height, z,
|
||||
x+width, y+height, z,
|
||||
x+width, y, z};
|
||||
GLfloat texels[ctx->getMaxTexUnits()][4*2];
|
||||
|
||||
ctx->dispatcher().glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
|
||||
ctx->dispatcher().glPushAttrib(GL_TRANSFORM_BIT);
|
||||
|
||||
//setup projection matrix to draw in viewport aligned coordinates
|
||||
ctx->dispatcher().glMatrixMode(GL_PROJECTION);
|
||||
ctx->dispatcher().glPushMatrix();
|
||||
ctx->dispatcher().glLoadIdentity();
|
||||
ctx->dispatcher().glGetIntegerv(GL_VIEWPORT,viewport);
|
||||
ctx->dispatcher().glOrtho(viewport[0],viewport[0] + viewport[2],viewport[1],viewport[1]+viewport[3],0,-1);
|
||||
//setup texture matrix
|
||||
ctx->dispatcher().glMatrixMode(GL_TEXTURE);
|
||||
ctx->dispatcher().glPushMatrix();
|
||||
ctx->dispatcher().glLoadIdentity();
|
||||
//setup modelview matrix
|
||||
ctx->dispatcher().glMatrixMode(GL_MODELVIEW);
|
||||
ctx->dispatcher().glPushMatrix();
|
||||
ctx->dispatcher().glLoadIdentity();
|
||||
//backup vbo's
|
||||
int array_buffer,element_array_buffer;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING,&array_buffer);
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING,&element_array_buffer);
|
||||
ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
|
||||
|
||||
//disable clip planes
|
||||
ctx->dispatcher().glGetIntegerv(GL_MAX_CLIP_PLANES,&numClipPlanes);
|
||||
for (int i=0;i<numClipPlanes;++i)
|
||||
ctx->dispatcher().glDisable(GL_CLIP_PLANE0+i);
|
||||
|
||||
for (int i=0;i<ctx->getMaxTexUnits();++i) {
|
||||
if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) {
|
||||
TextureData * texData = NULL;
|
||||
int tex = ctx->getBindedTexture(GL_TEXTURE0+i);
|
||||
ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i);
|
||||
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
|
||||
if (objData.Ptr()) {
|
||||
texData = (TextureData*)objData.Ptr();
|
||||
//calculate texels
|
||||
texels[i][0] = (float)(texData->crop_rect[0])/(float)(texData->width);
|
||||
texels[i][1] = (float)(texData->crop_rect[1])/(float)(texData->height);
|
||||
|
||||
texels[i][2] = (float)(texData->crop_rect[0])/(float)(texData->width);
|
||||
texels[i][3] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height);
|
||||
|
||||
texels[i][4] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width);
|
||||
texels[i][5] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height);
|
||||
|
||||
texels[i][6] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width);
|
||||
texels[i][7] = (float)(texData->crop_rect[1])/(float)(texData->height);
|
||||
|
||||
ctx->dispatcher().glTexCoordPointer(2,GL_FLOAT,0,texels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//draw rectangle
|
||||
ctx->dispatcher().glEnableClientState(GL_VERTEX_ARRAY);
|
||||
ctx->dispatcher().glVertexPointer(3,TypeName,0,vertices);
|
||||
ctx->dispatcher().glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
ctx->dispatcher().glDrawArrays(GL_TRIANGLE_FAN,0,4);
|
||||
|
||||
//restore vbo's
|
||||
ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,array_buffer);
|
||||
ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,element_array_buffer);
|
||||
|
||||
//restore matrix state
|
||||
|
||||
ctx->dispatcher().glMatrixMode(GL_MODELVIEW);
|
||||
ctx->dispatcher().glPopMatrix();
|
||||
ctx->dispatcher().glMatrixMode(GL_TEXTURE);
|
||||
ctx->dispatcher().glPopMatrix();
|
||||
ctx->dispatcher().glMatrixMode(GL_PROJECTION);
|
||||
ctx->dispatcher().glPopMatrix();
|
||||
|
||||
ctx->dispatcher().glPopAttrib();
|
||||
ctx->dispatcher().glPopClientAttrib();
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) {
|
||||
glDrawTexOES<GLshort,GL_SHORT>(x,y,z,width,height);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height) {
|
||||
glDrawTexOES<GLint,GL_INT>(x,y,z,width,height);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) {
|
||||
glDrawTexOES<GLfloat,GL_FLOAT>(x,y,z,width,height);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) {
|
||||
glDrawTexOES<GLfloat,GL_FLOAT>(X2F(x),X2F(y),X2F(z),X2F(width),X2F(height));
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort * coords) {
|
||||
glDrawTexOES<GLshort,GL_SHORT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexivOES (const GLint * coords) {
|
||||
glDrawTexOES<GLint,GL_INT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat * coords) {
|
||||
glDrawTexOES<GLfloat,GL_FLOAT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed * coords) {
|
||||
glDrawTexOES<GLfloat,GL_FLOAT>(X2F(coords[0]),X2F(coords[1]),X2F(coords[2]),X2F(coords[3]),X2F(coords[4]));
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ bool GLEScmValidate::texParams(GLenum target,GLenum pname) {
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
case GL_TEXTURE_WRAP_T:
|
||||
case GL_TEXTURE_CROP_RECT_OES:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -122,6 +122,10 @@ void (GLAPIENTRY *GLDispatch::glTexParameteri)(GLenum,GLenum,GLint) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glTexParameteriv)(GLenum,GLenum,const GLint *) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glTexSubImage2D)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid *) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glViewport)(GLint,GLint,GLsizei,GLsizei) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glPushAttrib) ( GLbitfield mask ) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glPopAttrib) ( void ) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glPushClientAttrib) ( GLbitfield mask ) = NULL;
|
||||
void (GLAPIENTRY *GLDispatch::glPopClientAttrib) ( void ) = NULL;
|
||||
|
||||
/*GLES 1.1*/
|
||||
void (GLAPIENTRY *GLDispatch::glAlphaFunc)(GLenum,GLclampf) = NULL;
|
||||
@@ -363,6 +367,10 @@ void GLDispatch::dispatchFuncs(GLESVersion version){
|
||||
LOAD_GL_FUNC(glTexParameteriv);
|
||||
LOAD_GL_FUNC(glTexSubImage2D);
|
||||
LOAD_GL_FUNC(glViewport);
|
||||
LOAD_GL_FUNC(glPushAttrib);
|
||||
LOAD_GL_FUNC(glPushClientAttrib);
|
||||
LOAD_GL_FUNC(glPopAttrib);
|
||||
LOAD_GL_FUNC(glPopClientAttrib);
|
||||
|
||||
/* Loading OpenGL functions which are needed ONLY for implementing GLES 1.1*/
|
||||
if(version == GLES_1_1){
|
||||
|
||||
@@ -28,7 +28,11 @@ GLEScontext::GLEScontext():
|
||||
m_glError(GL_NO_ERROR) ,
|
||||
m_arrayBuffer(0) ,
|
||||
m_elementBuffer(0) {
|
||||
|
||||
for (int i=0;i<MAX_TEX_UNITS;++i) {
|
||||
m_tex2DBind[i].texture = 0;
|
||||
for (int j=0;j<NUM_TEXTURE_TARGETS;++j)
|
||||
m_tex2DBind[i].enabled[j] = GL_FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
GLenum GLEScontext::getGLerror() {
|
||||
@@ -397,3 +401,11 @@ void GLEScontext::initCapsLocked(const GLubyte * extensionString)
|
||||
s_glExtensions = new std::string("");
|
||||
}
|
||||
|
||||
bool GLEScontext::isTextureUnitEnabled(GLenum unit) {
|
||||
for (int i=0;i<NUM_TEXTURE_TARGETS;++i) {
|
||||
if (m_tex2DBind[unit-GL_TEXTURE0].enabled[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,10 @@ public:
|
||||
static void (GLAPIENTRY *glTexParameteriv) (GLenum target, GLenum pname, const GLint *params);
|
||||
static void (GLAPIENTRY *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
static void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
static void (GLAPIENTRY *glPushAttrib) ( GLbitfield mask );
|
||||
static void (GLAPIENTRY *glPopAttrib) ( void );
|
||||
static void (GLAPIENTRY *glPushClientAttrib) ( GLbitfield mask );
|
||||
static void (GLAPIENTRY *glPopClientAttrib) ( void );
|
||||
|
||||
/* OpenGL functions which are needed ONLY for implementing GLES 1.1*/
|
||||
static void (GLAPIENTRY *glAlphaFunc) (GLenum func, GLclampf ref);
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
|
||||
typedef std::map<GLenum,GLESpointer*> ArraysMap;
|
||||
|
||||
enum TextureTarget {
|
||||
TEXTURE_2D,
|
||||
TEXTURE_CUBE_MAP,
|
||||
NUM_TEXTURE_TARGETS
|
||||
};
|
||||
|
||||
typedef struct _textureUnitState {
|
||||
GLuint texture;
|
||||
GLboolean enabled[NUM_TEXTURE_TARGETS];
|
||||
} textureUnitState;
|
||||
|
||||
struct GLSupport {
|
||||
GLSupport():maxLights(0),maxVertexAttribs(0),maxClipPlane(0),maxTexUnits(0),maxTexSize(0) , \
|
||||
GL_EXT_TEXTURE_FORMAT_BGRA8888(false), GL_EXT_FRAMEBUFFER_OBJECT(false), \
|
||||
@@ -44,8 +55,11 @@ public:
|
||||
void setGLerror(GLenum err);
|
||||
void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
|
||||
virtual void setActiveTexture(GLenum tex);
|
||||
unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture];};
|
||||
void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture] = tex;};
|
||||
unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture].texture;};
|
||||
unsigned int getBindedTexture(GLenum unit) { return m_tex2DBind[unit - GL_TEXTURE0].texture;};
|
||||
void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture].texture = tex;};
|
||||
bool isTextureUnitEnabled(GLenum unit);
|
||||
void setTextureEnabled(TextureTarget target, GLenum enable) {m_tex2DBind[m_activeTexture].enabled[target] = enable; };
|
||||
|
||||
bool isArrEnabled(GLenum);
|
||||
void enableArr(GLenum arr,bool enable);
|
||||
@@ -97,7 +111,7 @@ private:
|
||||
|
||||
ShareGroupPtr m_shareGroup;
|
||||
GLenum m_glError;
|
||||
unsigned int m_tex2DBind[MAX_TEX_UNITS];
|
||||
textureUnitState m_tex2DBind[MAX_TEX_UNITS];
|
||||
unsigned int m_arrayBuffer;
|
||||
unsigned int m_elementBuffer;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define TRANSLATOR_IFACES_H
|
||||
#include <GLcommon/ThreadInfo.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -36,13 +37,16 @@ public:
|
||||
~TextureData() {
|
||||
if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage);
|
||||
}
|
||||
TextureData():width(0),height(0),border(0),internalFormat(GL_RGBA),sourceEGLImage(0){};
|
||||
TextureData():width(0),height(0),border(0),internalFormat(GL_RGBA),sourceEGLImage(0){
|
||||
memset(crop_rect,0,4*sizeof(int));
|
||||
};
|
||||
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int border;
|
||||
unsigned int internalFormat;
|
||||
unsigned int sourceEGLImage;
|
||||
int crop_rect[4];
|
||||
void (*eglImageDetach)(unsigned int imageId);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
typedef double GLclampd; /* double precision float in [0,1] */
|
||||
typedef double GLdouble; /* double precision float */
|
||||
@@ -5,3 +20,6 @@ typedef double GLdouble; /* double precision float */
|
||||
#define GL_TEXTURE_GEN_S 0x0C60
|
||||
#define GL_TEXTURE_GEN_T 0x0C61
|
||||
#define GL_TEXTURE_GEN_R 0x0C62
|
||||
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
|
||||
#define GL_TRANSFORM_BIT 0x00001000
|
||||
#define GL_INT 0x1404
|
||||
|
||||
Reference in New Issue
Block a user