glshim updated added latest changes by ptitSeb

This commit is contained in:
lubomyr
2015-10-08 20:17:48 +03:00
parent a93521173c
commit e432efac27
5 changed files with 75 additions and 40 deletions

View File

@@ -19,6 +19,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) -DBCMHOST
LOCAL_SRC_FILES := \
src/gl/array.c \
src/gl/buffers.c \
src/gl/debug.c \
src/gl/decompress.c \
src/gl/eval.c \
src/gl/framebuffers.c \

View File

@@ -62,6 +62,7 @@ renderlist_t *alloc_renderlist() {
list->set_texture = false;
list->texture = 0;*/
list->target_texture = GL_TEXTURE_2D;
list->tmu = state.texture.active;
/*
list->polygon_mode = 0;
list->fog_op = 0;
@@ -96,6 +97,8 @@ bool ispurerender_renderlist(renderlist_t *list) {
return false;
if (list->mode_init == 0)
return false;
if (list->set_texture || list->set_tmu)
return false;
return true;
}
@@ -494,6 +497,7 @@ renderlist_t *extend_renderlist(renderlist_t *list) {
renderlist_t *new = alloc_renderlist();
list->next = new;
new->prev = list;
new->tmu = list->tmu;
if (list->open)
end_renderlist(list);
return new;
@@ -584,6 +588,10 @@ void adjust_renderlist(renderlist_t *list) {
list->open = false;
for (int a=0; a<MAX_TEX; a++) {
gltexture_t *bound = state.texture.bound[a];
// in case of Texture bounding inside a list
if (list->set_texture && (list->tmu == a))
bound = getTexture(list->target_texture, list->texture);
// adjust the tex_coord now
if ((list->tex[a]) && (bound) && ((bound->width != bound->nwidth) || (bound->height != bound->nheight))) {
tex_coord_npot(list->tex[a], list->len, bound->width, bound->height, bound->nwidth, bound->nheight);
}
@@ -672,11 +680,14 @@ void draw_renderlist(renderlist_t *list) {
break;
}
}
old_tex = state.texture.active;
if (list->set_tmu) {
glActiveTexture(GL_TEXTURE0+list->tmu);
}
if (list->set_texture) {
glBindTexture(list->target_texture, list->texture);
}
// raster
old_tex = state.texture.active;
if (list->raster_op) {
if (list->raster_op==1) {
glRasterPos3f(list->raster_xyz[0], list->raster_xyz[1], list->raster_xyz[2]);
@@ -1251,6 +1262,11 @@ void rlMultiTexCoord2f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t)
tex[0] = s; tex[1] = t;
}
void rlActiveTexture(renderlist_t *list, GLenum texture ) {
list->set_tmu = true;
list->tmu = texture - GL_TEXTURE0;
}
void rlBindTexture(renderlist_t *list, GLenum target, GLuint texture) {
list->texture = texture;
list->target_texture = target;

View File

@@ -11,6 +11,7 @@ typedef enum {
STAGE_GLCALL,
STAGE_FOG,
STAGE_MATRIX,
STAGE_ACTIVETEX,
STAGE_BINDTEX,
STAGE_RASTER,
STAGE_MATERIAL,
@@ -30,6 +31,7 @@ static int StageExclusive[STAGE_LAST] = {
0, // STAGE_GLCALL
1, // STAGE_FOG
1, // STAGE_MATRIX
1, // STAGE_ACTIVETEX
1, // STAGE_BINDTEX
1, // STAGE_RASTER
0, // STAGE_MATERIAL
@@ -126,8 +128,10 @@ typedef struct _renderlist_t {
GLfloat *lightmodel;
GLenum lightmodelparam;
GLenum polygon_mode;
GLuint texture; // I cannot know the active texture inside a list (for now => TODO?)
GLenum target_texture; // to support cube maps...
GLboolean set_tmu; // TRUE is glActiveTexture called
int tmu; // the current TMU...
GLuint texture;
GLenum target_texture;
GLboolean set_texture;
struct _renderlist_t *prev;
struct _renderlist_t *next;
@@ -147,6 +151,7 @@ extern void free_renderlist(renderlist_t *list);
extern void draw_renderlist(renderlist_t *list);
extern void end_renderlist(renderlist_t *list);
extern void rlActiveTexture(renderlist_t *list, GLenum texture );
extern void rlBindTexture(renderlist_t *list, GLenum target, GLuint texture);
extern void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a);
extern void rlMaterialfv(renderlist_t *list, GLenum face, GLenum pname, const GLfloat * params);

View File

@@ -826,28 +826,10 @@ GLboolean glIsTexture( GLuint texture) {
return GL_TRUE;
}
void glBindTexture(GLenum target, GLuint texture) {
noerrorShim();
if ((target!=GL_PROXY_TEXTURE_2D) && (state.list.active && (state.gl_batch && !state.list.compiling))) {
if ((state.statebatch.bound_targ == target) && (state.statebatch.bound_tex == texture))
return; // nothing to do...
if (!state.statebatch.bound_targ) {
state.statebatch.bound_targ = target;
state.statebatch.bound_tex = texture;
} else {
flush();
}
}
if ((target!=GL_PROXY_TEXTURE_2D) && ((state.list.compiling || state.gl_batch) && state.list.active)) {
// check if already a texture binded, if yes, create a new list
NewStage(state.list.active, STAGE_BINDTEX);
rlBindTexture(state.list.active, target, texture);
} else {
int tex_changed = 1;
int streamingID = -1;
gltexture_t* getTexture(GLenum target, GLuint texture) {
// Get a texture based on glID
gltexture_t* tex = NULL;
//printf("glBindTexture(0x%04X, %u), active=%i, client=%i\n", target, texture, state.texture.active, state.texture.client);
if (texture) {
if (texture == 0) return tex;
int ret;
khint_t k;
khash_t(tex) *list = state.texture.list;
@@ -881,6 +863,32 @@ void glBindTexture(GLenum target, GLuint texture) {
} else {
tex = kh_value(list, k);
}
return tex;
}
void glBindTexture(GLenum target, GLuint texture) {
noerrorShim();
if ((target!=GL_PROXY_TEXTURE_2D) && (state.list.active && (state.gl_batch && !state.list.compiling))) {
if ((state.statebatch.bound_targ == target) && (state.statebatch.bound_tex == texture))
return; // nothing to do...
if (!state.statebatch.bound_targ) {
state.statebatch.bound_targ = target;
state.statebatch.bound_tex = texture;
} else {
flush();
}
}
if ((target!=GL_PROXY_TEXTURE_2D) && ((state.list.compiling || state.gl_batch) && state.list.active)) {
// check if already a texture binded, if yes, create a new list
NewStage(state.list.active, STAGE_BINDTEX);
rlBindTexture(state.list.active, target, texture);
} else {
int tex_changed = 1;
int streamingID = -1;
gltexture_t *tex = NULL;
//printf("glBindTexture(0x%04X, %u), active=%i, client=%i\n", target, texture, state.texture.active, state.texture.client);
if (texture) {
tex = getTexture(target, texture);
if (state.texture.bound[state.texture.active] == tex)
tex_changed = 0;
texture = tex->glname;
@@ -1218,7 +1226,11 @@ void glActiveTexture( GLenum texture ) {
flush();
}
}
PUSH_IF_COMPILING(glActiveTexture);
if (state.list.active) {
NewStage(state.list.active, STAGE_ACTIVETEX);
rlActiveTexture(state.list.active, texture);
return;
}
if ((texture < GL_TEXTURE0) || (texture >= GL_TEXTURE0+MAX_TEX)) {
errorShim(GL_INVALID_ENUM);

View File

@@ -118,6 +118,7 @@ static inline GLenum map_tex_target(GLenum target) {
}
return target;
}
gltexture_t* getTexture(GLenum target, GLuint texture);
void glActiveTexture( GLenum texture );
void glClientActiveTexture( GLenum texture );