glshim updated, added latest changes by ptitSeb

This commit is contained in:
lubomyr
2016-10-22 21:12:58 +03:00
parent e4a8348427
commit a4bf1f1949
32 changed files with 2959 additions and 1286 deletions

View File

@@ -30,6 +30,7 @@ LOCAL_SRC_FILES := \
src/gl/list.c \
src/gl/loader.c \
src/gl/pixel.c \
src/gl/queries.c \
src/gl/raster.c \
src/gl/render.c \
src/gl/stack.c \

View File

@@ -183,3 +183,18 @@ Debug: Hide or Show the Sub / Not found message
* 0 : Default, the messages are shown
* 1 : Silent, don't print the STUB or glXGetProcAddress glXXXXX not found message
##### LIBGL_NOBANNER
Show/Hide initial text
* 0 : Default, print starting message
* 1 : Silent: no LIBGL message at start (combile with LIBGL_SILENTSTUB for more silence)
##### LIBGL_NPOT
Expose NPOT (Non Power of Two) Support
* 0 : Default, don't expose the extension (but npot are still supported)
* 1 : Expose limited NPOT extension
* 2 : Expose GL_ARB_texture_non_power_of_two extension
##### LIBGL_QUERIES
Expose glQueries functions
* 0 : Default, don't expose the function (fake one will be used if called)
* 1 : Expose fake functions (always answer 0)

View File

@@ -238,35 +238,30 @@ GLvoid *copy_gl_array_convert(const GLvoid *src,
return dst;
}
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) {
float filler = 0.0f;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_convert(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
return copy_gl_array_convert(ptr->pointer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count, &filler);
}
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) {
float filler = 1.0f;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_convert(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
return copy_gl_array_convert(ptr->pointer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count, &filler);
}
GLvoid *copy_gl_pointer_bytecolor(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
GLvoid *copy_gl_pointer_bytecolor(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) {
GLubyte filler = 255;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_convert(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
return copy_gl_array_convert(ptr->pointer, ptr->type, ptr->size, ptr->stride,
GL_UNSIGNED_BYTE, width, skip, count, &filler);
}
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) {
return copy_gl_array(ptr->pointer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count);
}
GLvoid *copy_gl_pointer_tex(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
GLvoid *copy_gl_pointer_tex(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) {
float filler = 1.0f;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_texcoord(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
return copy_gl_array_texcoord(ptr->pointer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count, &filler);
}
@@ -274,8 +269,7 @@ GLfloat *gl_pointer_index(pointer_state_t *p, GLint index) {
static GLfloat buf[4];
GLsizei size = gl_sizeof(p->type);
GLsizei stride = p->stride ? p->stride : (size * p->size);
uintptr_t ptr = (uintptr_t)(p->pointer) + (stride * index)
+ (uintptr_t)((glstate.vao->vertex)?glstate.vao->vertex->data:0);
uintptr_t ptr = (uintptr_t)(p->pointer) + (stride * index);
GL_TYPE_SWITCH(src, ptr, p->type,
for (int i = 0; i < p->size; i++) {

View File

@@ -13,11 +13,11 @@ GLvoid *copy_gl_array_convert(const GLvoid *src,
GLenum from, GLsizei width, GLsizei stride,
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count, GLvoid* filler);
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_bytecolor(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_tex(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count);
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count);
GLvoid *copy_gl_pointer_bytecolor(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count);
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count);
GLvoid *copy_gl_pointer_tex(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count);
GLfloat *gl_pointer_index(pointer_state_t *ptr, GLint index);
GLfloat *copy_eval_double(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint vorder, const GLdouble *points);
void normalize_indices(GLushort *indices, GLsizei *max, GLsizei *min, GLsizei count);

View File

@@ -8,16 +8,16 @@ static GLuint lastbuffer = 1;
glbuffer_t** BUFF(GLenum target) {
switch(target) {
case GL_ARRAY_BUFFER:
return &glstate.vao->vertex;
return &glstate->vao->vertex;
break;
case GL_ELEMENT_ARRAY_BUFFER:
return &glstate.vao->elements;
return &glstate->vao->elements;
break;
case GL_PIXEL_PACK_BUFFER:
return &glstate.vao->pack;
return &glstate->vao->pack;
break;
case GL_PIXEL_UNPACK_BUFFER:
return &glstate.vao->unpack;
return &glstate->vao->unpack;
break;
default:
printf("LIBGL: Warning, unknown buffer target 0x%04X\n", target);
@@ -68,15 +68,15 @@ void glshim_glGenBuffers(GLsizei n, GLuint * buffers) {
void glshim_glBindBuffer(GLenum target, GLuint buffer) {
//printf("glBindBuffer(%s, %u)\n", PrintEnum(target), buffer);
if (glstate.gl_batch) {
if (glstate->gl_batch) {
flush();
}
khint_t k;
int ret;
khash_t(buff) *list = glstate.buffers;
khash_t(buff) *list = glstate->buffers;
if (! list) {
list = glstate.buffers = kh_init(buff);
list = glstate->buffers = kh_init(buff);
// segfaults if we don't do a single put
kh_put(buff, list, 1, &ret);
kh_del(buff, list, 1);
@@ -153,11 +153,11 @@ void glshim_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, con
void glshim_glDeleteBuffers(GLsizei n, const GLuint * buffers) {
//printf("glDeleteBuffers(%i, %p)\n", n, buffers);
if (glstate.gl_batch) {
if (glstate->gl_batch) {
flush();
}
khash_t(buff) *list = glstate.buffers;
khash_t(buff) *list = glstate->buffers;
if (list) {
khint_t k;
glbuffer_t *buff;
@@ -167,14 +167,14 @@ void glshim_glDeleteBuffers(GLsizei n, const GLuint * buffers) {
k = kh_get(buff, list, t);
if (k != kh_end(list)) {
buff = kh_value(list, k);
if (glstate.vao->vertex == buff)
glstate.vao->vertex = NULL;
if (glstate.vao->elements == buff)
glstate.vao->elements = NULL;
if (glstate.vao->pack == buff)
glstate.vao->pack = NULL;
if (glstate.vao->unpack == buff)
glstate.vao->unpack = NULL;
if (glstate->vao->vertex == buff)
glstate->vao->vertex = NULL;
if (glstate->vao->elements == buff)
glstate->vao->elements = NULL;
if (glstate->vao->pack == buff)
glstate->vao->pack = NULL;
if (glstate->vao->unpack == buff)
glstate->vao->unpack = NULL;
if (buff->data) free(buff->data);
kh_del(buff, list, k);
free(buff);
@@ -187,7 +187,7 @@ void glshim_glDeleteBuffers(GLsizei n, const GLuint * buffers) {
GLboolean glshim_glIsBuffer(GLuint buffer) {
//printf("glIsBuffer(%u)\n", buffer);
khash_t(buff) *list = glstate.buffers;
khash_t(buff) *list = glstate->buffers;
khint_t k;
noerrorShim();
if (list) {
@@ -349,15 +349,15 @@ void glshim_glGenVertexArrays(GLsizei n, GLuint *arrays) {
}
void glshim_glBindVertexArray(GLuint array) {
//printf("glBindVertexArray(%u)\n", array);
if (glstate.gl_batch) {
if (glstate->gl_batch) {
flush();
}
khint_t k;
int ret;
khash_t(glvao) *list = glstate.vaos;
khash_t(glvao) *list = glstate->vaos;
if (! list) {
list = glstate.vaos = kh_init(glvao);
list = glstate->vaos = kh_init(glvao);
// segfaults if we don't do a single put
kh_put(glvao, list, 1, &ret);
kh_del(glvao, list, 1);
@@ -365,7 +365,7 @@ void glshim_glBindVertexArray(GLuint array) {
// if array = 0 => unbind buffer!
if (array == 0) {
// unbind buffer
glstate.vao = glstate.defaultvao;
glstate->vao = glstate->defaultvao;
} else {
// search for an existing buffer
k = kh_get(glvao, list, array);
@@ -376,10 +376,10 @@ void glshim_glBindVertexArray(GLuint array) {
// new vao is binded to nothing
memset(glvao, 0, sizeof(glvao_t));
/*
glstate.vao->vertex = glstate.defaultvbo;
glstate.vao->elements = glstate.defaultvbo;
glstate.vao->pack = glstate.defaultvbo;
glstate.vao->unpack = glstate.defaultvbo;
glstate->vao->vertex = glstate->defaultvbo;
glstate->vao->elements = glstate->defaultvbo;
glstate->vao->pack = glstate->defaultvbo;
glstate->vao->unpack = glstate->defaultvbo;
*/
// just put is number
@@ -387,16 +387,16 @@ void glshim_glBindVertexArray(GLuint array) {
} else {
glvao = kh_value(list, k);
}
glstate.vao = glvao;
glstate->vao = glvao;
}
noerrorShim();
}
void glshim_glDeleteVertexArrays(GLsizei n, const GLuint *arrays) {
//printf("glDeleteVertexArrays(%i, %p)\n", n, arrays);
if (glstate.gl_batch) {
if (glstate->gl_batch) {
flush();
}
khash_t(glvao) *list = glstate.vaos;
khash_t(glvao) *list = glstate->vaos;
if (list) {
khint_t k;
glvao_t *glvao;
@@ -416,7 +416,7 @@ void glshim_glDeleteVertexArrays(GLsizei n, const GLuint *arrays) {
}
GLboolean glshim_glIsVertexArray(GLuint array) {
//printf("glIsVertexArray(%u)\n", array);
khash_t(glvao) *list = glstate.vaos;
khash_t(glvao) *list = glstate->vaos;
khint_t k;
noerrorShim();
if (list) {

View File

@@ -58,7 +58,6 @@ typedef struct {
GLint size;
GLenum type;
GLsizei stride;
glbuffer_t *buffer;
const GLvoid *pointer;
} pointer_state_t;

View File

@@ -111,6 +111,16 @@ const char* PrintEnum(GLenum what) {
p(GL_QUADS);
p(GL_QUAD_STRIP);
p(GL_POLYGON);
// texgen
p(GL_S);
p(GL_T);
p(GL_Q);
p(GL_TEXTURE_GEN_MODE);
p(GL_OBJECT_LINEAR);
p(GL_EYE_LINEAR);
p(GL_SPHERE_MAP);
p(GL_NORMAL_MAP);
p(GL_REFLECTION_MAP);
default:
sprintf(fallback, "0x%04X", what);
}

View File

@@ -19,7 +19,7 @@ void glshim_glClientAttribDefault(GLbitfield mask) {
else glshim_glDisableClientState(pname)
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
int client = glstate.texture.client;
int client = glstate->texture.client;
enable_disable(GL_VERTEX_ARRAY, false);
enable_disable(GL_NORMAL_ARRAY, false);
@@ -30,7 +30,7 @@ void glshim_glClientAttribDefault(GLbitfield mask) {
enable_disable(GL_TEXTURE_COORD_ARRAY, false);
}
#undef enable_disable
if (glstate.texture.client != client) glshim_glClientActiveTexture(GL_TEXTURE0+client);
if (glstate->texture.client != client) glshim_glClientActiveTexture(GL_TEXTURE0+client);
}
}
void glshim_glPushClientAttribDefault(GLbitfield mask) {
@@ -197,12 +197,12 @@ void glshim_glGetCompressedTextureImage(GLuint texture, GLenum target, GLint lev
#undef text
#define text(f) \
GLenum old_tex = glstate.texture.active; \
GLenum old_tex = glstate->texture.active; \
if(texunit != old_tex) glshim_glActiveTexture(texunit); \
glshim_##f; \
if(texunit != old_tex) glshim_glActiveTexture(old_tex)
#define texc(f) \
GLenum old_tex = glstate.texture.client; \
GLenum old_tex = glstate->texture.client; \
if(texunit != old_tex) glshim_glClientActiveTexture(texunit); \
glshim_##f; \
if(texunit != old_tex) glshim_glClientActiveTexture(old_tex)

View File

@@ -6,22 +6,22 @@
static inline map_state_t **get_map_pointer(GLenum target) {
switch (target) {
case GL_MAP1_COLOR_4: return &glstate.map1.color4;
case GL_MAP1_INDEX: return &glstate.map1.index;
case GL_MAP1_TEXTURE_COORD_1: return &glstate.map1.texture1;
case GL_MAP1_TEXTURE_COORD_2: return &glstate.map1.texture2;
case GL_MAP1_TEXTURE_COORD_3: return &glstate.map1.texture3;
case GL_MAP1_TEXTURE_COORD_4: return &glstate.map1.texture4;
case GL_MAP1_VERTEX_3: return &glstate.map1.vertex3;
case GL_MAP1_VERTEX_4: return &glstate.map1.vertex4;
case GL_MAP2_COLOR_4: return &glstate.map2.color4;
case GL_MAP2_INDEX: return &glstate.map2.index;
case GL_MAP2_TEXTURE_COORD_1: return &glstate.map2.texture1;
case GL_MAP2_TEXTURE_COORD_2: return &glstate.map2.texture2;
case GL_MAP2_TEXTURE_COORD_3: return &glstate.map2.texture3;
case GL_MAP2_TEXTURE_COORD_4: return &glstate.map2.texture4;
case GL_MAP2_VERTEX_3: return &glstate.map2.vertex3;
case GL_MAP2_VERTEX_4: return &glstate.map2.vertex4;
case GL_MAP1_COLOR_4: return &glstate->map1.color4;
case GL_MAP1_INDEX: return &glstate->map1.index;
case GL_MAP1_TEXTURE_COORD_1: return &glstate->map1.texture1;
case GL_MAP1_TEXTURE_COORD_2: return &glstate->map1.texture2;
case GL_MAP1_TEXTURE_COORD_3: return &glstate->map1.texture3;
case GL_MAP1_TEXTURE_COORD_4: return &glstate->map1.texture4;
case GL_MAP1_VERTEX_3: return &glstate->map1.vertex3;
case GL_MAP1_VERTEX_4: return &glstate->map1.vertex4;
case GL_MAP2_COLOR_4: return &glstate->map2.color4;
case GL_MAP2_INDEX: return &glstate->map2.index;
case GL_MAP2_TEXTURE_COORD_1: return &glstate->map2.texture1;
case GL_MAP2_TEXTURE_COORD_2: return &glstate->map2.texture2;
case GL_MAP2_TEXTURE_COORD_3: return &glstate->map2.texture3;
case GL_MAP2_TEXTURE_COORD_4: return &glstate->map2.texture4;
case GL_MAP2_VERTEX_3: return &glstate->map2.vertex3;
case GL_MAP2_VERTEX_4: return &glstate->map2.vertex4;
default:
printf("libGL: unknown glMap target 0x%x\n", target);
}
@@ -38,13 +38,13 @@ static inline map_state_t **get_map_pointer(GLenum target) {
#define case_state(dims, magic, name) \
case magic: { \
map->width = get_map_width(magic); \
map_statef_t *m = (map_statef_t *)glstate.map##dims.name; \
map_statef_t *m = (map_statef_t *)glstate->map##dims.name; \
if (m) { \
if (m->free) \
free((void *)m->points); \
free(m); \
} \
glstate.map##dims.name = (map_state_t *)map; \
glstate->map##dims.name = (map_state_t *)map; \
break; \
}
@@ -110,7 +110,7 @@ void glshim_glMap2f(GLenum target, GLfloat u1, GLfloat u2,
#undef map_switch
#define p_map(d, name, func, code) { \
map_state_t *_map = glstate.map##d.name; \
map_state_t *_map = glstate->map##d.name; \
if (_map) { \
if (_map->type == GL_DOUBLE) { \
map_stated_t *map = (map_stated_t *)_map; \
@@ -161,10 +161,10 @@ void glshim_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2) {
noerrorShim();
// TODO: double support?
map_statef_t *map;
if (! glstate.map_grid)
glstate.map_grid = malloc(sizeof(map_statef_t));
if (! glstate->map_grid)
glstate->map_grid = malloc(sizeof(map_statef_t));
map = (map_statef_t *)glstate.map_grid;
map = (map_statef_t *)glstate->map_grid;
map->dims = 1;
map->u.n = un;
map->u._1 = u1;
@@ -176,10 +176,10 @@ void glshim_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2,
noerrorShim();
// TODO: double support?
map_statef_t *map;
if (! glstate.map_grid)
glstate.map_grid = malloc(sizeof(map_statef_t));
if (! glstate->map_grid)
glstate->map_grid = malloc(sizeof(map_statef_t));
map = (map_statef_t *)glstate.map_grid;
map = (map_statef_t *)glstate->map_grid;
map->dims = 2;
map->u.n = un;
map->u._1 = u1;
@@ -190,10 +190,10 @@ void glshim_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2,
}
static inline GLenum eval_mesh_prep(map_statef_t **map, GLenum mode) {
if (glstate.map2.vertex4) {
*map = (map_statef_t *)glstate.map2.vertex4;
} else if (glstate.map2.vertex3) {
*map = (map_statef_t *)glstate.map2.vertex3;
if (glstate->map2.vertex4) {
*map = (map_statef_t *)glstate->map2.vertex4;
} else if (glstate->map2.vertex3) {
*map = (map_statef_t *)glstate->map2.vertex3;
} else {
return 0;
}

View File

@@ -70,7 +70,7 @@ void glshim_glGenFramebuffers(GLsizei n, GLuint *ids) {
void glshim_glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) {
//printf("glDeleteFramebuffers(%i, %p), framebuffers[0]=%u\n", n, framebuffers, framebuffers[0]);
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
if (g_recyclefbo) {
//printf("Recycling %i FBOs\n", n);
noerrorShim();
@@ -93,7 +93,7 @@ void glshim_glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) {
GLboolean glshim_glIsFramebuffer(GLuint framebuffer) {
//printf("glIsFramebuffer(%u)\n", framebuffer);
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glIsFramebuffer);
errorGL();
@@ -103,7 +103,7 @@ GLboolean glshim_glIsFramebuffer(GLuint framebuffer) {
GLenum fb_status;
GLenum glshim_glCheckFramebufferStatus(GLenum target) {
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
//#define BEFORE 1
#ifdef BEFORE
GLenum result = fb_status;
@@ -120,9 +120,9 @@ GLenum glshim_glCheckFramebufferStatus(GLenum target) {
}
void glshim_glBindFramebuffer(GLenum target, GLuint framebuffer) {
//printf("glBindFramebuffer(%s, %u), list=%s\n", PrintEnum(target), framebuffer, glstate.list.active?"active":"none");
//printf("glBindFramebuffer(%s, %u), list=%s\n", PrintEnum(target), framebuffer, glstate->list.active?"active":"none");
//PUSH_IF_COMPILING(glBindFramebuffer);
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glBindFramebuffer);
LOAD_GLES_OES(glCheckFramebufferStatus);
LOAD_GLES(glGetError);
@@ -169,7 +169,7 @@ void glshim_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum text
static int scrap_width = 0;
static int scrap_height = 0;
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glFramebufferTexture2D);
LOAD_GLES(glTexImage2D);
LOAD_GLES(glBindTexture);
@@ -187,9 +187,9 @@ void glshim_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum text
gltexture_t *tex = NULL;
int ret;
khint_t k;
khash_t(tex) *list = glstate.texture.list;
khash_t(tex) *list = glstate->texture.list;
if (! list) {
list = glstate.texture.list = kh_init(tex);
list = glstate->texture.list = kh_init(tex);
// segfaults if we don't do a single put
kh_put(tex, list, 1, &ret);
kh_del(tex, list, 1);
@@ -209,7 +209,7 @@ void glshim_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum text
tex->nwidth = npot(tex->width);
tex->nheight = npot(tex->height);
tex->shrink = 0;
gltexture_t *bound = glstate.texture.bound[glstate.texture.active];
gltexture_t *bound = glstate->texture.bound[glstate->texture.active];
GLuint oldtex = (bound)?bound->glname:0;
if (oldtex!=tex->glname) gles_glBindTexture(GL_TEXTURE_2D, tex->glname);
gles_glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->nwidth, tex->nheight, 0, tex->format, tex->type, NULL);
@@ -222,7 +222,7 @@ void glshim_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum text
tex->nwidth = (tex->nwidth<32)?32:tex->nwidth;
tex->nheight = (tex->nheight<32)?32:tex->nheight;
tex->shrink = 0;
gltexture_t *bound = glstate.texture.bound[glstate.texture.active];
gltexture_t *bound = glstate->texture.bound[glstate->texture.active];
GLuint oldtex = (bound)?bound->glname:0;
if (oldtex!=tex->glname) gles_glBindTexture(GL_TEXTURE_2D, tex->glname);
gles_glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->nwidth, tex->nheight, 0, tex->format, tex->type, NULL);
@@ -257,7 +257,7 @@ void glshim_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum text
if ((scrap_width!=twidth) || (scrap_height!=theight)) {
scrap_width = twidth;
scrap_height = theight;
gltexture_t *bound = glstate.texture.bound[glstate.texture.active];
gltexture_t *bound = glstate->texture.bound[glstate->texture.active];
GLuint oldtex = (bound)?bound->glname:0;
if (oldtex!=scrap_tex) gles_glBindTexture(GL_TEXTURE_2D, scrap_tex);
gles_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, scrap_width, scrap_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
@@ -321,7 +321,7 @@ void glshim_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum r
}
void glshim_glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) {
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glDeleteRenderbuffers);
// check if we delete a depthstencil
@@ -398,7 +398,7 @@ void glshim_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLe
}
void glshim_glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glBindRenderbuffer);
//printf("glBindRenderbuffer(%s, %u), binded Fbo=%u\n", PrintEnum(target), renderbuffer, current_fb);
@@ -410,7 +410,7 @@ void glshim_glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
GLboolean glshim_glIsRenderbuffer(GLuint renderbuffer) {
//printf("glIsRenderbuffer(%u)\n", renderbuffer);
if (glstate.gl_batch) flush();
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glIsRenderbuffer);
errorGL();
@@ -474,9 +474,9 @@ void createMainFBO(int width, int height) {
deleteMainFBO();
}
// switch to texture unit 0 if needed
if (glstate.texture.active != 0)
if (glstate->texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0);
if (glstate.texture.client != 0)
if (glstate->texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0);
mainfbo_width = width;
@@ -536,12 +536,12 @@ void createMainFBO(int width, int height) {
gles_glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
// Put everything back, and active the MainFBO
if (glstate.texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, glstate.texture.bound[0]->glname);
if (glstate.texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0 + glstate.texture.active);
if (glstate.texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0 + glstate.texture.client);
if (glstate->texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, glstate->texture.bound[0]->glname);
if (glstate->texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0 + glstate->texture.active);
if (glstate->texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0 + glstate->texture.client);
}
@@ -561,11 +561,11 @@ void blitMainFBO() {
return;
// switch to texture unit 0 if needed
int old_tex = glstate.texture.active;
int old_client = glstate.texture.client;
if (glstate.texture.active != 0)
int old_tex = glstate->texture.active;
int old_client = glstate->texture.client;
if (glstate->texture.active != 0)
glshim_glActiveTexture(GL_TEXTURE0);
if (glstate.texture.client != 0)
if (glstate->texture.client != 0)
glshim_glClientActiveTexture(GL_TEXTURE0);
// bind the FBO texture
gles_glEnable(GL_TEXTURE_2D);
@@ -625,29 +625,29 @@ void blitMainFBO() {
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if(!glstate.clientstate.vertex_array) {
if(!glstate->clientstate.vertex_array) {
gles_glEnableClientState(GL_VERTEX_ARRAY);
glstate.clientstate.vertex_array = 1;
glstate->clientstate.vertex_array = 1;
}
gles_glVertexPointer(2, GL_FLOAT, 0, vert);
if(!glstate.clientstate.tex_coord_array[0]) {
if(!glstate->clientstate.tex_coord_array[0]) {
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[0] = 1;
glstate->clientstate.tex_coord_array[0] = 1;
}
gles_glTexCoordPointer(2, GL_FLOAT, 0, tex);
for (int a=1; a <MAX_TEX; a++)
if(glstate.clientstate.tex_coord_array[a]) {
if(glstate->clientstate.tex_coord_array[a]) {
glshim_glClientActiveTexture(GL_TEXTURE0 + a);
gles_glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[a] = 0;
glstate->clientstate.tex_coord_array[a] = 0;
}
if(glstate.clientstate.color_array) {
if(glstate->clientstate.color_array) {
gles_glDisableClientState(GL_COLOR_ARRAY);
glstate.clientstate.color_array = 0;
glstate->clientstate.color_array = 0;
}
if(glstate.clientstate.normal_array) {
if(glstate->clientstate.normal_array) {
gles_glDisableClientState(GL_NORMAL_ARRAY);
glstate.clientstate.normal_array = 0;
glstate->clientstate.normal_array = 0;
}
@@ -668,11 +668,11 @@ void blitMainFBO() {
// put back viewport
gles_glViewport(old_vp[0], old_vp[1], old_vp[2], old_vp[3]);
// Put everything back
if (glstate.texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, glstate.texture.bound[0]->glname);
if (glstate->texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, glstate->texture.bound[0]->glname);
else
gles_glBindTexture(GL_TEXTURE_2D, 0);
if (!glstate.enable.texture_2d[0])
if (!glstate->enable.texture_2d[0])
gles_glDisable(GL_TEXTURE_2D);
if (old_tex != 0)
glshim_glActiveTexture(GL_TEXTURE0 + old_tex);

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,29 @@
#define AliasExport(name) __attribute__((alias(name))) __attribute__((visibility("default")))
#endif
#ifndef FASTMATH
#ifdef __GNUC__
#ifdef __arm__
#ifdef __ARM_PCS_VFP
//#warning Arm Hardfloat detected
#define FASTMATH
#else
#if defined(__ARM_FP) && defined(PANDORA)
//#warning Arm SoftFP detected
#define FASTMATH __attribute__((pcs("aapcs-vfp")))
#else
//#warning Arm no FP detected
#define FASTMATH
#endif
#endif
#else
#define FASTMATH
#endif
#else
#define FASTMATH
#endif
#endif
#ifndef GL_H
#define GL_H
@@ -90,6 +113,7 @@ typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLC
#endif
#include "loader.h"
packed_call_t* glCopyPackedCall(const packed_call_t *packed);
#define checkError(code) \
{int error; while ((error = glGetError())) {} \
@@ -153,7 +177,7 @@ typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLC
#define GL_TYPE_SWITCH_MAX(name, var, type, code, extra) \
switch (type) { \
GL_TYPE_CASE_MAX(name, var, GL_DOUBLE, GLdouble, code, 1.0d) \
GL_TYPE_CASE_MAX(name, var, GL_DOUBLE, GLdouble, code, 1.0) \
GL_TYPE_CASE_MAX(name, var, GL_FLOAT, GLfloat, code, 1.0f) \
GL_TYPE_CASE_MAX(name, var, GL_INT, GLint, code, 2147483647l) \
GL_TYPE_CASE_MAX(name, var, GL_SHORT, GLshort, code, 32767) \
@@ -165,8 +189,8 @@ typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLC
}
#define PUSH_IF_COMPILING_EXT(nam, ...) \
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) { \
NewStage(glstate.list.active, STAGE_GLCALL); \
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) { \
NewStage(glstate->list.active, STAGE_GLCALL); \
push_##nam(__VA_ARGS__); \
noerrorShim(); \
return (nam##_RETURN)0; \
@@ -402,16 +426,16 @@ void flush();
void init_batch();
#include "state.h"
extern glstate_t glstate;
extern glstate_t *glstate;
GLuint gl_batch; // 0 = off, 1 = on
static inline void errorGL() { // next glGetError will be from GL
glstate.shim_error = 0;
glstate->shim_error = 0;
}
static inline void errorShim(GLenum error) { // next glGetError will be "error" from glShim
glstate.shim_error = 1;
glstate.last_error = error;
glstate->shim_error = 1;
glstate->last_error = error;
}
static inline void noerrorShim() {
errorShim(GL_NO_ERROR);

View File

@@ -3,7 +3,7 @@
#ifndef USE_ES2
void glshim_glLightModelf(GLenum pname, GLfloat param) {
//printf("%sglLightModelf(%04X, %.2f)\n", (state.list.compiling)?"list":"", pname, param);
if (glstate.list.compiling && glstate.list.active) {
if (glstate->list.compiling && glstate->list.active) {
GLfloat dummy[4];
dummy[0]=param;
glshim_glLightModelfv(pname, dummy);
@@ -25,13 +25,13 @@ void glshim_glLightModelf(GLenum pname, GLfloat param) {
void glshim_glLightModelfv(GLenum pname, const GLfloat* params) {
//printf("%sglLightModelfv(%04X, [%.2f, %.2f, %.2f, %.2f])\n", (state.list.compiling)?"list":"", pname, params[0], params[1], params[2], params[3]);
if (glstate.list.compiling && glstate.list.active) {
NewStage(glstate.list.active, STAGE_LIGHTMODEL);
/* if (glstate.list.active->lightmodel)
glstate.list.active = extend_renderlist(glstate.list.active);*/
glstate.list.active->lightmodelparam = pname;
glstate.list.active->lightmodel = (GLfloat*)malloc(4*sizeof(GLfloat));
memcpy(glstate.list.active->lightmodel, params, 4*sizeof(GLfloat));
if (glstate->list.compiling && glstate->list.active) {
NewStage(glstate->list.active, STAGE_LIGHTMODEL);
/* if (glstate->list.active->lightmodel)
glstate->list.active = extend_renderlist(glstate->list.active);*/
glstate->list.active->lightmodelparam = pname;
glstate->list.active->lightmodel = (GLfloat*)malloc(4*sizeof(GLfloat));
memcpy(glstate->list.active->lightmodel, params, 4*sizeof(GLfloat));
noerrorShim();
return;
}
@@ -50,10 +50,10 @@ void glshim_glLightModelfv(GLenum pname, const GLfloat* params) {
}
void glshim_glLightfv(GLenum light, GLenum pname, const GLfloat* params) {
//printf("%sglLightfv(%04X, %04X, [%.2f, %.2f, %.2f, %.2f])\n", (state.list.compiling)?"list":"", light, pname, params[0], params[1], params[2], params[3]);
if (glstate.list.compiling && glstate.list.active) {
NewStage(glstate.list.active, STAGE_LIGHT);
rlLightfv(glstate.list.active, light, pname, params);
//printf("%sglLightfv(%04X, %04X, %p=[%.2f, %.2f, %.2f, %.2f])\n", (glstate->list.compiling)?"list":"", light, pname, params, (params)?params[0]:0.0f, (params)?params[1]:0.0f, (params)?params[2]:0.0f, (params)?params[3]:0.0f);
if (glstate->list.compiling && glstate->list.active) {
NewStage(glstate->list.active, STAGE_LIGHT);
rlLightfv(glstate->list.active, light, pname, params);
noerrorShim();
return;
}

View File

@@ -19,11 +19,11 @@ renderlist_t *alloc_renderlist() {
list->matrix_val[15] = 1.0f;
list->lightmodelparam = GL_LIGHT_MODEL_AMBIENT;
list->target_texture = GL_TEXTURE_2D;
list->tmu = glstate.texture.active;
list->tmu = glstate->texture.active;
memcpy(list->lastNormal, glstate.normal, 3*sizeof(GLfloat));
memcpy(list->lastSecondaryColors, glstate.secondary, 3*sizeof(GLfloat));
memcpy(list->lastColors, glstate.color, 4*sizeof(GLfloat));
memcpy(list->lastNormal, glstate->normal, 3*sizeof(GLfloat));
memcpy(list->lastSecondaryColors, glstate->secondary, 3*sizeof(GLfloat));
memcpy(list->lastColors, glstate->color, 4*sizeof(GLfloat));
list->open = true;
return list;
@@ -33,8 +33,6 @@ bool ispurerender_renderlist(renderlist_t *list) {
// return true if renderlist contains only rendering command, no state changes
if (list->calls.len)
return false;
if (list->glcall_list)
return false;
if (list->matrix_op)
return false;
if (list->raster_op)
@@ -59,6 +57,10 @@ bool ispurerender_renderlist(renderlist_t *list) {
return true;
}
bool isempty_renderlist(renderlist_t *list) {
return (list->stage == STAGE_NONE);
}
int rendermode_dimensions(GLenum mode) {
// return 1 for points, 2 for any lines, 3 for any triangles, 4 for any Quad and 5 for polygon
switch (mode) {
@@ -222,7 +224,7 @@ void renderlist_quads2triangles(renderlist_t *a) {
a->indices[j+5] = vind(i+3);
}
a->ilen = ilen;
if ((ind) && !a->shared_arrays) free(ind);
if ((ind) && (!a->shared_indices || ((*a->shared_indices)--)==0)) {free(ind); free(a->shared_indices);}
a->mode = GL_TRIANGLES;
}
#undef vind
@@ -266,7 +268,7 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
// lets append all the arrays
unsigned long cap = a->cap;
if (a->len + b->len >= cap) cap += b->cap + DEFAULT_RENDER_LIST_CAPACITY;
if (a->shared_arrays) {
if (a->shared_arrays && ((*a->shared_arrays)--)>0) {
// Unshare if shared (shared array are not used for now)
a->cap = cap;
GLfloat *tmp;
@@ -297,14 +299,6 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
memcpy(a->tex[i], tmp, 4*a->len*sizeof(GLfloat));
}
}
if (a->indices) {
GLushort* tmpi = a->indices;
a->indice_cap = ((ilen_a)?ilen_a:a->len) + ((ilen_b)?ilen_b:b->len);
if (a->indice_cap > 48) a->indice_cap = (a->indice_cap+511)&~511;
a->indices = (GLushort*)malloc(a->indice_cap*sizeof(GLushort));
memcpy(a->indices, tmpi, a->ilen*sizeof(GLushort));
}
a->shared_arrays = false;
} else {
if (a->cap < cap) {
a->cap = cap;
@@ -316,6 +310,17 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
realloc_sublist(a->tex[i], 4, cap);
}
}
if(a->shared_arrays && *a->shared_arrays==0) {free(a->shared_arrays); a->shared_arrays=0;}
if (a->shared_indices && ((*a->shared_indices)--)>0) {
if (a->indices) {
GLushort* tmpi = a->indices;
a->indice_cap = ((ilen_a)?ilen_a:a->len) + ((ilen_b)?ilen_b:b->len);
if (a->indice_cap > 48) a->indice_cap = (a->indice_cap+511)&~511;
a->indices = (GLushort*)malloc(a->indice_cap*sizeof(GLushort));
memcpy(a->indices, tmpi, a->ilen*sizeof(GLushort));
}
}
if(a->shared_indices && *a->shared_indices==0) {free(a->shared_indices); a->shared_indices=0;}
// append arrays
if (a->vert) memcpy(a->vert+a->len*4, b->vert, b->len*4*sizeof(GLfloat));
if (a->normal) memcpy(a->normal+a->len*3, b->normal, b->len*3*sizeof(GLfloat));
@@ -427,6 +432,11 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
// lenghts
a->len += b->len;
a->ilen += ilen_b;
// copy the lastColors if needed
if(b->lastColorsSet) {
a->lastColorsSet = 1;
memcpy(a->lastColors, b->lastColors, 4*sizeof(GLfloat));
}
//all done
a->stage = STAGE_DRAW; // just in case
return;
@@ -443,7 +453,6 @@ renderlist_t *extend_renderlist(renderlist_t *list) {
// just in case
memcpy(new->lastNormal, list->lastNormal, 3*sizeof(GLfloat));
memcpy(new->lastSecondaryColors, list->lastSecondaryColors, 3*sizeof(GLfloat));
memcpy(new->lastColors, list->lastColors, 4*sizeof(GLfloat));
// detach
list->prev = NULL;
// free list now
@@ -458,9 +467,123 @@ renderlist_t *extend_renderlist(renderlist_t *list) {
memcpy(new->lastNormal, list->lastNormal, 3*sizeof(GLfloat));
memcpy(new->lastSecondaryColors, list->lastSecondaryColors, 3*sizeof(GLfloat));
memcpy(new->lastColors, list->lastColors, 4*sizeof(GLfloat));
new->lastColorsSet = list->lastColorsSet;
return new;
}
}
int Cap2BatchState(GLenum cap);
renderlist_t* append_calllist(renderlist_t *list, renderlist_t *a)
{
// go to end of list
while(list->next) list = list->next;
while(a) {
if(ispurerender_renderlist(a) && islistscompatible_renderlist(list, a)) {
// append list!
append_renderlist(list, a);
} else {
// create a new appended list
renderlist_t *new = alloc_renderlist();
// prepared shared stuff...
if(a->len && !a->shared_arrays) {
a->shared_arrays = (int*)malloc(sizeof(int));
*a->shared_arrays = 0;
}
if(a->ilen && !a->shared_indices) {
a->shared_indices = (int*)malloc(sizeof(int));
*a->shared_indices = 0;
}
if(a->calls.cap && !a->shared_calls) {
a->shared_calls = (int*)malloc(sizeof(int));
*a->shared_calls = 0;
}
// batch copy first
memcpy(new, a, sizeof(renderlist_t));
list->next = new;
new->prev = list;
// ok, now on new list
list = new;
// copy the many list arrays
if(glstate->gl_batch) {
if (list->popattribute) {
// invalidate all batchstate
for (int i=0; i<MAX_TEX; i++) {
glstate->statebatch.bound_targ[i] = 0xffff;
glstate->statebatch.bound_tex[i] = 0xffffffff;
}
for (int i=0; i<ENABLED_LAST; i++) {
glstate->statebatch.enabled[i] = 3; //undefined
}
}
}
if (list->calls.cap > 0) {
++(*list->shared_calls);
/*
list->calls.calls = (packed_call_t**)malloc(sizeof(packed_call_t*)*a->calls.cap);
for (int i = 0; i < list->calls.len; i++) {
list->calls.calls[i] = glCopyPackedCall(a->calls.calls[i]);
}*/
// in case of batch mode, need to update the batchstate...
if(glstate->gl_batch) {
for (int i = 0; i < list->calls.len; i++) {
packed_call_t *p = list->calls.calls[i];
if(p->func == &glshim_glEnable) {
int wich_cap = Cap2BatchState(((glEnable_PACKED*)p)->args.a1);
if(wich_cap!=ENABLED_LAST) glstate->statebatch.enabled[wich_cap] = 1;
}
if(p->func == &glshim_glDisable) {
int wich_cap = Cap2BatchState(((glDisable_PACKED*)p)->args.a1);
if(wich_cap!=ENABLED_LAST) glstate->statebatch.enabled[wich_cap] = 0;
}
}
}
}
if(list->len) {
++(*list->shared_arrays);
}
#undef PROCESS
if(list->ilen) {
++(*list->shared_indices);
}
#define PROCESS(W, T, C) if(list->W) { \
list->W = kh_init(W); \
T *m, *m2; \
khint_t k; \
int ret; \
kh_foreach_value(a->W, m, \
k = kh_put(W, list->W, C, &ret); \
m2= kh_value(list->W, k) = malloc(sizeof(T)); \
memcpy(m2, m, sizeof(T)); \
); \
}
PROCESS(material, rendermaterial_t, m->pname);
PROCESS(light, renderlight_t, m->pname | ((m->which-GL_LIGHT0)<<16));
PROCESS(texgen, rendertexgen_t, m->pname | ((m->coord-GL_S)<<16));
#undef PROCESS
if (list->lightmodel) {
list->lightmodel = (GLfloat*)malloc(4*sizeof(GLfloat));
memcpy(list->lightmodel, a->lightmodel, 4*sizeof(GLfloat));
}
if (list->raster) {
(*list->raster->shared)++;
}
// Update other batchstate states
if(glstate->gl_batch) {
if (list->set_tmu) {
glstate->statebatch.active_tex = GL_TEXTURE0 + list->tmu;
glstate->statebatch.active_tex_changed = 1;
}
if (list->set_texture) {
const int batch_activetex = glstate->statebatch.active_tex_changed?(glstate->statebatch.active_tex-GL_TEXTURE0):glstate->texture.active;
glstate->statebatch.bound_targ[batch_activetex] = list->target_texture;
glstate->statebatch.bound_tex[batch_activetex] = list->texture;
}
}
}
a = a->next;
}
return list;
}
void free_renderlist(renderlist_t *list) {
// test if list is NULL
@@ -472,20 +595,25 @@ void free_renderlist(renderlist_t *list) {
renderlist_t *next;
do {
if (list->calls.len > 0) {
if ((list->calls.cap > 0) && (!list->shared_calls || ((*list->shared_calls)--)==0)) {
if(list->shared_calls) free(list->shared_calls);
for (int i = 0; i < list->calls.len; i++) {
free(list->calls.calls[i]);
}
free(list->calls.calls);
}
int a;
if (!list->shared_arrays) {
if (!list->shared_arrays || ((*list->shared_arrays)--)==0) {
if (list->shared_arrays) free(list->shared_arrays);
if (list->vert) free(list->vert);
if (list->normal) free(list->normal);
if (list->color) free(list->color);
if (list->secondary) free(list->secondary);
for (a=0; a<MAX_TEX; a++)
if (list->tex[a]) free(list->tex[a]);
}
if (!list->shared_indices || ((*list->shared_indices)--)==0) {
if (list->shared_indices) free(list->shared_indices);
if (list->indices)
free(list->indices);
}
@@ -514,7 +642,7 @@ void free_renderlist(renderlist_t *list) {
if (list->lightmodel)
free(list->lightmodel);
if (list->raster) {
if (list->raster && !(*(list->raster->shared)--)) {
if (list->raster->texture)
glshim_glDeleteTextures(1, &list->raster->texture);
free(list->raster);
@@ -525,7 +653,6 @@ void free_renderlist(renderlist_t *list) {
} while ((list = next));
}
static inline
void resize_renderlist(renderlist_t *list) {
if (list->len >= list->cap) {
list->cap += DEFAULT_RENDER_LIST_CAPACITY;
@@ -545,7 +672,7 @@ void adjust_renderlist(renderlist_t *list) {
list->stage = STAGE_LAST;
list->open = false;
for (int a=0; a<MAX_TEX; a++) {
gltexture_t *bound = glstate.texture.bound[a];
gltexture_t *bound = glstate->texture.bound[a];
// in case of Texture bounding inside a list
if (list->set_texture && (list->tmu == a))
bound = glshim_getTexture(list->target_texture, list->texture);
@@ -554,15 +681,15 @@ void adjust_renderlist(renderlist_t *list) {
tex_coord_npot(list->tex[a], list->len, bound->width, bound->height, bound->nwidth, bound->nheight);
}
// GL_ARB_texture_rectangle
if ((list->tex[a]) && glstate.texture.rect_arb[a] && (bound)) {
if ((list->tex[a]) && glstate->texture.rect_arb[a] && (bound)) {
tex_coord_rect_arb(list->tex[a], list->len, bound->width, bound->height);
}
}
}
void end_renderlist(renderlist_t *list) {
renderlist_t* end_renderlist(renderlist_t *list) {
if (!list || ! list->open)
return;
return list;
adjust_renderlist(list);
@@ -581,6 +708,15 @@ void end_renderlist(renderlist_t *list) {
list->mode = GL_TRIANGLE_STRIP;
break;
}
if(list->prev && isempty_renderlist(list)) {
renderlist_t *p = list;
list = list->prev;
list->next = NULL;
p->prev = NULL;
free_renderlist(p);
}
return list;
}
void draw_renderlist(renderlist_t *list) {
@@ -588,7 +724,7 @@ void draw_renderlist(renderlist_t *list) {
// go to 1st...
while (list->prev) list = list->prev;
// ok, go on now, draw everything
//printf("draw_renderlist %p, gl_batch=%i, size=%i, mode=%s(%s), ilen=%d, next=%p, color=%p, secondarycolor=%p\n", list, glstate.gl_batch, list->len, PrintEnum(list->mode), PrintEnum(list->mode_init), list->ilen, list->next, list->color, list->secondary);
//printf("draw_renderlist %p, gl_batch=%i, size=%i, mode=%s(%s), ilen=%d, next=%p, color=%p, secondarycolor=%p\n", list, glstate->gl_batch, list->len, PrintEnum(list->mode), PrintEnum(list->mode_init), list->ilen, list->next, list->color, list->secondary);
LOAD_GLES(glDrawArrays);
LOAD_GLES(glDrawElements);
#ifdef USE_ES2
@@ -611,15 +747,12 @@ void draw_renderlist(renderlist_t *list) {
do {
// close if needed!
if (list->open)
end_renderlist(list);
list = end_renderlist(list);
// push/pop attributes
if (list->pushattribute)
glshim_glPushAttrib(list->pushattribute);
if (list->popattribute)
glshim_glPopAttrib();
// do call_list
if (list->glcall_list)
glshim_glCallList(list->glcall_list);
call_list_t *cl = &list->calls;
if (cl->len > 0) {
for (int i = 0; i < cl->len; i++) {
@@ -650,7 +783,7 @@ void draw_renderlist(renderlist_t *list) {
glshim_glBindTexture(list->target_texture, list->texture);
}
// raster
old_tex = glstate.texture.active;
old_tex = glstate->texture.active;
if (list->raster_op) {
if (list->raster_op==1) {
glshim_glRasterPos3f(list->raster_xyz[0], list->raster_xyz[1], list->raster_xyz[2]);
@@ -719,19 +852,19 @@ void draw_renderlist(renderlist_t *list) {
if (list->vert) {
gles_glEnableClientState(GL_VERTEX_ARRAY);
gles_glVertexPointer(4, GL_FLOAT, 0, list->vert);
glstate.clientstate.vertex_array = 1;
glstate->clientstate.vertex_array = 1;
} else {
gles_glDisableClientState(GL_VERTEX_ARRAY);
glstate.clientstate.vertex_array = false;
glstate->clientstate.vertex_array = false;
}
if (list->normal) {
gles_glEnableClientState(GL_NORMAL_ARRAY);
gles_glNormalPointer(GL_FLOAT, 0, list->normal);
glstate.clientstate.normal_array = 1;
glstate->clientstate.normal_array = 1;
} else {
gles_glDisableClientState(GL_NORMAL_ARRAY);
glstate.clientstate.normal_array = 0;
glstate->clientstate.normal_array = 0;
}
indices = list->indices;
@@ -739,8 +872,8 @@ void draw_renderlist(renderlist_t *list) {
final_colors = NULL;
if (list->color) {
gles_glEnableClientState(GL_COLOR_ARRAY);
glstate.clientstate.color_array = 1;
if (glstate.enable.color_sum && (list->secondary)) {
glstate->clientstate.color_array = 1;
if (glstate->enable.color_sum && (list->secondary)) {
final_colors=(GLfloat*)malloc(list->len * 4 * sizeof(GLfloat));
if (indices) {
for (int i=0; i<list->ilen; i++)
@@ -759,14 +892,14 @@ void draw_renderlist(renderlist_t *list) {
}
} else {
gles_glDisableClientState(GL_COLOR_ARRAY);
glstate.clientstate.color_array = 0;
glstate->clientstate.color_array = 0;
}
GLuint texture;
bool stipple;
stipple = false;
if (! list->tex[0]) {
// TODO: do we need to support GL_LINE_STRIP?
if (list->mode == GL_LINES && glstate.enable.line_stipple) {
if (list->mode == GL_LINES && glstate->enable.line_stipple) {
stipple = true;
glshim_glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT);
glshim_glEnable(GL_BLEND);
@@ -780,55 +913,54 @@ void draw_renderlist(renderlist_t *list) {
for (int a=0; a<MAX_TEX; a++) {
texgened[a]=NULL;
needclean[a]=0;
if ((glstate.enable.texgen_s[a] || glstate.enable.texgen_t[a] || glstate.enable.texgen_r[a])) {
if ((glstate->enable.texgen_s[a] || glstate->enable.texgen_t[a] || glstate->enable.texgen_r[a])) {
gen_tex_coords(list->vert, list->normal, &texgened[a], list->len, &needclean[a], a, (list->ilen<list->len)?indices:NULL, (list->ilen<list->len)?list->ilen:0);
} else if (glstate.enable.texture_2d[a] && (list->tex[a]==NULL)) {
} else if (glstate->enable.texture_2d[a] && (list->tex[a]==NULL)) {
gen_tex_coords(list->vert, list->normal, &texgened[a], list->len, &needclean[a], a, (list->ilen<list->len)?indices:NULL, (list->ilen<list->len)?list->ilen:0);
}
}
old_tex = glstate.texture.client;
old_tex = glstate->texture.client;
GLuint cur_tex = old_tex;
#define TEXTURE(A) if (cur_tex!=A) {glshim_glClientActiveTexture(A+GL_TEXTURE0); cur_tex=A;}
for (int a=0; a<MAX_TEX; a++) {
if ((list->tex[a] || texgened[a])/* && glstate.enable.texture_2d[a]*/) {
glshim_glClientActiveTexture(GL_TEXTURE0+a);
if ((list->tex[a] || texgened[a])/* && glstate->enable.texture_2d[a]*/) {
TEXTURE(a);
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[a] = 1;
glstate->clientstate.tex_coord_array[a] = 1;
gles_glTexCoordPointer(4, GL_FLOAT, 0, (texgened[a])?texgened[a]:list->tex[a]);
} else {
if (glstate.clientstate.tex_coord_array[a]) {
glshim_glClientActiveTexture(GL_TEXTURE0+a);
if (glstate->clientstate.tex_coord_array[a]) {
TEXTURE(a);
gles_glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[a] = 0;
glstate->clientstate.tex_coord_array[a] = 0;
}
//else if (!glstate.enable.texgen_s[a] && glstate.enable.texture_2d[a]) printf("LIBGL: texture_2d[%i] without TexCoord, mode=0x%04X (init=0x%04X), listlen=%i\n", a, list->mode, list->mode_init, list->len);
//else if (!glstate->enable.texgen_s[a] && glstate->enable.texture_2d[a]) printf("LIBGL: texture_2d[%i] without TexCoord, mode=0x%04X (init=0x%04X), listlen=%i\n", a, list->mode, list->mode_init, list->len);
}
}
for (int aa=0; aa<MAX_TEX; aa++) {
if (!glstate.enable.texture_2d[aa] && (glstate.enable.texture_1d[aa] || glstate.enable.texture_3d[aa])) {
glshim_glClientActiveTexture(aa+GL_TEXTURE0);
if (!glstate->enable.texture_2d[a] && (glstate->enable.texture_1d[a] || glstate->enable.texture_3d[a])) {
TEXTURE(a);
gles_glEnable(GL_TEXTURE_2D);
}
}
if (glstate.texture.client != old_tex) glshim_glClientActiveTexture(GL_TEXTURE0+old_tex);
if (glstate->texture.client != old_tex) TEXTURE(old_tex);
#undef TEXTURE
GLenum mode;
mode = list->mode;
if ((glstate.polygon_mode == GL_LINE) && (mode>=GL_TRIANGLES))
if ((glstate->polygon_mode == GL_LINE) && (mode>=GL_TRIANGLES))
mode = GL_LINES;
if ((glstate.polygon_mode == GL_POINT) && (mode>=GL_TRIANGLES))
if ((glstate->polygon_mode == GL_POINT) && (mode>=GL_TRIANGLES))
mode = GL_POINTS;
if (indices) {
if (glstate.render_mode == GL_SELECT) {
if (glstate->render_mode == GL_SELECT) {
pointer_state_t vtx;
vtx.pointer = list->vert;
vtx.type = GL_FLOAT;
vtx.size = 4;
vtx.stride = 0;
vtx.buffer = NULL;
select_glDrawElements(&vtx, list->mode, list->ilen, GL_UNSIGNED_SHORT, indices);
} else {
if (glstate.polygon_mode == GL_LINE && list->mode_init>=GL_TRIANGLES) {
if (glstate->polygon_mode == GL_LINE && list->mode_init>=GL_TRIANGLES) {
int n, s;
int ilen = list->ilen;
GLushort ind_line[ilen*4+2];
@@ -911,17 +1043,16 @@ void draw_renderlist(renderlist_t *list) {
}
}
} else {
if (glstate.render_mode == GL_SELECT) {
if (glstate->render_mode == GL_SELECT) {
pointer_state_t vtx;
vtx.pointer = list->vert;
vtx.type = GL_FLOAT;
vtx.size = 4;
vtx.stride = 0;
vtx.buffer = NULL;
select_glDrawArrays(&vtx, list->mode, 0, list->len);
} else {
int len = list->len;
if ((glstate.polygon_mode == GL_LINE) && (list->mode_init>=GL_TRIANGLES)) {
if ((glstate->polygon_mode == GL_LINE) && (list->mode_init>=GL_TRIANGLES)) {
int n, s;
GLushort ind_line[len*4+2];
int k=0;
@@ -1005,22 +1136,24 @@ void draw_renderlist(renderlist_t *list) {
}
}
}
#define TEXTURE(A) if (cur_tex!=A) {glshim_glClientActiveTexture(A+GL_TEXTURE0); cur_tex=A;}
for (int a=0; a<MAX_TEX; a++) {
if (needclean[a])
if (needclean[a]) {
TEXTURE(a);
gen_tex_clean(needclean[a], a);
}
if (texgened[a]) {
free(texgened[a]);
texgened[a] = NULL;
}
}
for (int aa=0; aa<MAX_TEX; aa++) {
if (!glstate.enable.texture_2d[aa] && (glstate.enable.texture_1d[aa] || glstate.enable.texture_3d[aa])) {
glshim_glClientActiveTexture(aa+GL_TEXTURE0);
if (!glstate->enable.texture_2d[a] && (glstate->enable.texture_1d[a] || glstate->enable.texture_3d[a])) {
TEXTURE(a);
gles_glDisable(GL_TEXTURE_2D);
}
}
if (glstate.texture.client!=old_tex)
glshim_glClientActiveTexture(old_tex+GL_TEXTURE0);
if (glstate->texture.client!=old_tex)
TEXTURE(old_tex);
#undef TEXTURE
if (final_colors)
free(final_colors);
@@ -1034,7 +1167,7 @@ void draw_renderlist(renderlist_t *list) {
// gl function wrappers
void rlVertex4f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
void FASTMATH rlVertex4f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
if (list->vert == NULL) {
list->vert = alloc_sublist(4, list->cap);
} else {
@@ -1042,28 +1175,28 @@ void rlVertex4f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
}
if (list->normal) {
GLfloat *normal = list->normal + (list->len * 3);
GLfloat * const normal = list->normal + (list->len * 3);
memcpy(normal, list->lastNormal, sizeof(GLfloat) * 3);
}
if (list->color) {
GLfloat *color = list->color + (list->len * 4);
memcpy(color, glstate.color, sizeof(GLfloat) * 4);
GLfloat * const color = list->color + (list->len * 4);
memcpy(color, glstate->color, sizeof(GLfloat) * 4);
}
if (list->secondary) {
GLfloat *secondary = list->secondary + (list->len * 4);
memcpy(secondary, glstate.secondary, sizeof(GLfloat) * 4);
GLfloat * const secondary = list->secondary + (list->len * 4);
memcpy(secondary, glstate->secondary, sizeof(GLfloat) * 4);
}
for (int a=0; a<MAX_TEX; a++) {
if (list->tex[a]) {
GLfloat *tex = list->tex[a] + (list->len * 4);
memcpy(tex, glstate.texcoord[a], sizeof(GLfloat) * 4);
GLfloat * const tex = list->tex[a] + (list->len * 4);
memcpy(tex, glstate->texcoord[a], sizeof(GLfloat) * 4);
}
}
GLfloat *vert = list->vert + (list->len++ * 4);
GLfloat * const vert = list->vert + (list->len++ * 4);
vert[0] = x; vert[1] = y; vert[2] = z; vert[3] = w;
}
@@ -1084,6 +1217,7 @@ void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) {
void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
if (list->color == NULL) {
list->lastColorsSet = 1;
list->color = alloc_sublist(4, list->cap);
// catch up
int i;
@@ -1096,8 +1230,9 @@ void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
}*/
}
GLfloat *color = glstate.color;
GLfloat *color = glstate->color;
color[0] = r; color[1] = g; color[2] = b; color[3] = a;
memcpy(list->lastColors, color, 4*sizeof(GLfloat));
}
void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b) {
@@ -1111,7 +1246,7 @@ void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b) {
}
}
GLfloat *color = glstate.secondary;
GLfloat *color = glstate->secondary;
color[0] = r; color[1] = g; color[2] = b; color[3] = 0.0f;
}
@@ -1211,11 +1346,11 @@ void rlTexCoord4f(renderlist_t *list, GLfloat s, GLfloat t, GLfloat r, GLfloat q
// catch up
GLfloat *tex = list->tex[0];
if (list->len) for (int i = 0; i < list->len; i++) {
memcpy(tex, glstate.texcoord[0], sizeof(GLfloat) * 4);
memcpy(tex, glstate->texcoord[0], sizeof(GLfloat) * 4);
tex += 4;
}
}
GLfloat *tex = glstate.texcoord[0];
GLfloat *tex = glstate->texcoord[0];
tex[0] = s; tex[1] = t;
tex[2] = r; tex[3] = q;
}
@@ -1227,11 +1362,11 @@ void rlMultiTexCoord4f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t,
// catch up
GLfloat *tex = list->tex[tmu];
if (list->len) for (int i = 0; i < list->len; i++) {
memcpy(tex, glstate.texcoord[tmu], sizeof(GLfloat) * 4);
memcpy(tex, glstate->texcoord[tmu], sizeof(GLfloat) * 4);
tex += 4;
}
}
GLfloat *tex = glstate.texcoord[tmu];
GLfloat *tex = glstate->texcoord[tmu];
tex[0] = s; tex[1] = t;
tex[2] = r; tex[3] = q;
}
@@ -1266,10 +1401,10 @@ void rlPushCall(renderlist_t *list, packed_call_t *data) {
call_list_t *cl = &list->calls;
if (!cl->calls) {
cl->cap = DEFAULT_CALL_LIST_CAPACITY;
cl->calls = malloc(DEFAULT_CALL_LIST_CAPACITY * sizeof(uintptr_t));
cl->calls = malloc(DEFAULT_CALL_LIST_CAPACITY * sizeof(void*));
} else if (list->calls.len == list->calls.cap) {
cl->cap += DEFAULT_CALL_LIST_CAPACITY;
cl->calls = realloc(cl->calls, cl->cap * sizeof(uintptr_t));
cl->calls = realloc(cl->calls, cl->cap * sizeof(void*));
}
cl->calls[cl->len++] = data;
}

View File

@@ -74,6 +74,7 @@ typedef struct {
GLfloat zoomy;
GLboolean bitmap;
GLuint texture;
int *shared;
} rasterlist_t;
KHASH_MAP_INIT_INT(material, rendermaterial_t *)
@@ -94,20 +95,23 @@ typedef struct _renderlist_t {
GLenum mode_init; // initial requested mode
GLfloat lastNormal[3];
GLfloat lastColors[4];
GLfloat lastSecondaryColors[3];
GLfloat lastSecondaryColors[4];
int lastColorsSet;
int* shared_calls;
call_list_t calls;
GLboolean shared_arrays;
int *shared_arrays;
GLfloat *vert;
GLfloat *normal;
GLfloat *color;
GLfloat *secondary;
GLfloat *tex[MAX_TEX];
int *shared_indices;
GLushort *indices;
unsigned int indice_cap;
GLuint glcall_list;
rasterlist_t *raster;
liststage_t stage;
@@ -147,24 +151,24 @@ typedef struct _renderlist_t {
renderlist_t* GetFirst(renderlist_t* list);
extern renderlist_t *alloc_renderlist();
extern renderlist_t *extend_renderlist(renderlist_t *list);
extern void free_renderlist(renderlist_t *list);
extern void draw_renderlist(renderlist_t *list);
extern void end_renderlist(renderlist_t *list);
renderlist_t *alloc_renderlist();
renderlist_t *extend_renderlist(renderlist_t *list);
void free_renderlist(renderlist_t *list);
void draw_renderlist(renderlist_t *list);
renderlist_t* 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);
extern void rlLightfv(renderlist_t *list, GLenum which, GLenum pname, const GLfloat * params);
extern void rlTexGenfv(renderlist_t *list, GLenum coord, GLenum pname, const GLfloat * params);
extern void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z);
extern void rlPushCall(renderlist_t *list, packed_call_t *data);
extern void rlTexCoord4f(renderlist_t *list, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
extern void rlMultiTexCoord4f(renderlist_t *list, GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
extern void rlVertex4f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b);
extern void rlRasterOp(renderlist_t *list, int op, GLfloat x, GLfloat y, GLfloat z);
extern void rlFogOp(renderlist_t *list, int op, const GLfloat* v);
void rlActiveTexture(renderlist_t *list, GLenum texture );
void rlBindTexture(renderlist_t *list, GLenum target, GLuint texture);
void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a) FASTMATH;
void rlMaterialfv(renderlist_t *list, GLenum face, GLenum pname, const GLfloat * params);
void rlLightfv(renderlist_t *list, GLenum which, GLenum pname, const GLfloat * params);
void rlTexGenfv(renderlist_t *list, GLenum coord, GLenum pname, const GLfloat * params);
void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) FASTMATH;
void rlPushCall(renderlist_t *list, packed_call_t *data);
void rlTexCoord4f(renderlist_t *list, GLfloat s, GLfloat t, GLfloat r, GLfloat q) FASTMATH;
void rlMultiTexCoord4f(renderlist_t *list, GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q) FASTMATH;
void rlVertex4f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z, GLfloat w) FASTMATH;
void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b) FASTMATH;
void rlRasterOp(renderlist_t *list, int op, GLfloat x, GLfloat y, GLfloat z) FASTMATH;
void rlFogOp(renderlist_t *list, int op, const GLfloat* v);
#endif

View File

@@ -18,7 +18,7 @@ static const colorlayout_t *get_color_map(GLenum format) {
map(GL_LUMINANCE, 0, 0, 0, -1);
map(GL_ALPHA,-1, -1, -1, 0);
default:
printf("libGL: unknown pixel format %s\n", PrintEnum(format));
printf("LIBGL: unknown pixel format %s\n", PrintEnum(format));
break;
}
static colorlayout_t null = {0};
@@ -126,7 +126,7 @@ bool remap_pixel(const GLvoid *src, GLvoid *dst,
)
default:
// TODO: add glSetError?
printf("libGL: Unsupported source data type: %s\n", PrintEnum(src_type));
printf("LIBGL: Unsupported source data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -179,7 +179,7 @@ bool remap_pixel(const GLvoid *src, GLvoid *dst,
(((GLushort)(color[3] * 15.0) & 0x0f));
)
default:
printf("libGL: Unsupported target data type: %s\n", PrintEnum(dst_type));
printf("LIBGL: Unsupported target data type: %s\n", PrintEnum(dst_type));
return false;
break;
}
@@ -279,7 +279,7 @@ bool transform_pixel(const GLvoid *src, GLvoid *dst,
)
default:
// TODO: add glSetError?
printf("libGL: transform_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
printf("LIBGL: transform_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -327,7 +327,7 @@ bool transform_pixel(const GLvoid *src, GLvoid *dst,
((GLushort)(color[0] * 15.0f) & 0x0f);
)
default:
printf("libGL: Unsupported target data type: %s\n", PrintEnum(src_type));
printf("LIBGL: Unsupported target data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -457,7 +457,7 @@ bool half_pixel(const GLvoid *src0, const GLvoid *src1,
)
default:
// TODO: add glSetError?
printf("libGL: half_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
printf("LIBGL: half_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -505,7 +505,7 @@ bool half_pixel(const GLvoid *src0, const GLvoid *src1,
((GLushort)(color[3] * 15.0f) & 0x0f);
)
default:
printf("libGL: half_pixel: Unsupported target data type: %s\n", PrintEnum(src_type));
printf("LIBGL: half_pixel: Unsupported target data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -611,7 +611,7 @@ bool quarter_pixel(const GLvoid *src[16],
)
default:
// TODO: add glSetError?
printf("libGL: quarter_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
printf("LIBGL: quarter_pixel: Unsupported source data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -647,7 +647,7 @@ bool quarter_pixel(const GLvoid *src[16],
((GLushort)(color[3] * 15.0) & 0x0f);
)
default:
printf("libGL: quarter_pixel Unsupported target data type: %s\n", PrintEnum(src_type));
printf("LIBGL: quarter_pixel Unsupported target data type: %s\n", PrintEnum(src_type));
return false;
break;
}
@@ -889,6 +889,38 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
dst_pos += dst_width;
}
return true;
}
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_BYTE) && (src_type == GL_UNSIGNED_SHORT_4_4_4_4_REV)) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
const GLushort pix = *(GLushort*)src_pos;
((char*)dst_pos)[3] = ((pix>>12)&0x0f)<<4;
((char*)dst_pos)[2] = ((pix>>8)&0x0f)<<4;
((char*)dst_pos)[1] = ((pix>>4)&0x0f)<<4;
((char*)dst_pos)[0] = ((pix)&0x0f)<<4;
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
}
return true;
}
if ((src_format == GL_RGBA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_BYTE) && (src_type == GL_UNSIGNED_SHORT_5_5_5_1)) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
const GLushort pix = *(GLushort*)src_pos;
((char*)dst_pos)[0] = ((pix>>11)&0x1f)<<3;
((char*)dst_pos)[1] = ((pix>>6)&0x1f)<<3;
((char*)dst_pos)[2] = ((pix>>1)&0x1f)<<3;
((char*)dst_pos)[3] = ((pix)&0x01)?255:0;
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
}
return true;
}
if (! remap_pixel((const GLvoid *)src_pos, (GLvoid *)dst_pos,
src_color, src_type, dst_color, dst_type)) {

View File

@@ -0,0 +1,193 @@
#include "queries.h"
static GLuint lastquery = 0;
static glquery_t *active_samples_passed = 0;
extern int glshim_queries;
void glshim_glGenQueries(GLsizei n, GLuint * ids) {
noerrorShim();
if (n<1) {
errorShim(GL_INVALID_VALUE);
return;
}
for (int i=0; i<n; i++) {
ids[i] = ++lastquery;
}
}
GLboolean glshim_glIsQuery(GLuint id) {
khash_t(queries) *list = glstate->queries;
khint_t k;
noerrorShim();
if (list) {
k = kh_get(queries, list, id);
if (k != kh_end(list)) {
return GL_TRUE;
}
}
return GL_FALSE;
}
void glshim_glDeleteQueries(GLsizei n, const GLuint* ids) {
khash_t(queries) *list = glstate->queries;
if (list) {
khint_t k;
glquery_t *query;
for (int i = 0; i < n; i++) {
GLuint t = ids[i];
if (t) { // don't allow to remove default one
k = kh_get(queries, list, t);
if (k != kh_end(list)) {
query = kh_value(list, k);
kh_del(queries, list, k);
free(query);
if(active_samples_passed==query)
active_samples_passed = NULL;
}
}
}
}
noerrorShim();
}
void glshim_glBeginQuery(GLenum target, GLuint id) {
if(target!=GL_SAMPLES_PASSED) {
errorShim(GL_INVALID_ENUM);
return;
}
if (glstate->gl_batch) {
flush();
}
khint_t k;
int ret;
glquery_t *query;
khash_t(queries) *list = glstate->queries;
if (! list) {
list = glstate->queries = kh_init(queries);
// segfaults if we don't do a single put
kh_put(queries, list, 1, &ret);
kh_del(queries, list, 1);
}
k = kh_get(queries, list, id);
if (k != kh_end(list)) {
query = kh_value(list, k);
} else {
k = kh_put(queries, list, id, &ret);
query = kh_value(list, k) = malloc(sizeof(glquery_t));
}
query->target = target;
query->num = 0;
active_samples_passed = query;
noerrorShim();
}
void glshim_glEndQuery(GLenum target) {
if(target!=GL_SAMPLES_PASSED) {
errorShim(GL_INVALID_ENUM);
return;
}
if(!active_samples_passed) {
errorShim(GL_INVALID_OPERATION);
return;
}
if (glstate->gl_batch) {
flush();
}
active_samples_passed = NULL;
noerrorShim();
}
void glshim_glGetQueryiv(GLenum target, GLenum pname, GLint* params) {
if(target!=GL_SAMPLES_PASSED) {
errorShim(GL_INVALID_ENUM);
return;
}
noerrorShim();
switch (pname) {
case GL_CURRENT_QUERY:
*params = (active_samples_passed)?active_samples_passed->id:0;
break;
case GL_QUERY_COUNTER_BITS:
*params = 0; //no counter...
break;
default:
errorShim(GL_INVALID_ENUM);
}
}
void glshim_glGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) {
khint_t k;
int ret;
glquery_t *query = NULL;
khash_t(queries) *list = glstate->queries;
if (! list) {
list = glstate->queries = kh_init(queries);
// segfaults if we don't do a single put
kh_put(queries, list, 1, &ret);
kh_del(queries, list, 1);
}
k = kh_get(queries, list, id);
if (k != kh_end(list)) {
query = kh_value(list, k);
}
if(!query) {
errorShim(GL_INVALID_OPERATION);
return;
}
noerrorShim();
switch (pname) {
case GL_QUERY_RESULT_AVAILABLE:
*params = GL_TRUE;
break;
case GL_QUERY_RESULT:
*params = query->num;
break;
default:
errorShim(GL_INVALID_ENUM);
break;
}
}
void glshim_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
khint_t k;
int ret;
glquery_t *query = NULL;
khash_t(queries) *list = glstate->queries;
if (! list) {
list = glstate->queries = kh_init(queries);
// segfaults if we don't do a single put
kh_put(queries, list, 1, &ret);
kh_del(queries, list, 1);
}
k = kh_get(queries, list, id);
if (k != kh_end(list)) {
query = kh_value(list, k);
}
if(!query) {
errorShim(GL_INVALID_OPERATION);
return;
}
noerrorShim();
switch (pname) {
case GL_QUERY_RESULT_AVAILABLE:
*params = GL_TRUE;
break;
case GL_QUERY_RESULT:
*params = query->num;
break;
default:
errorShim(GL_INVALID_ENUM);
break;
}
}
//Direct wrapper
void glGenQueries(GLsizei n, GLuint * ids) AliasExport("glshim_glGenQueries");
GLboolean glIsQuery(GLuint id) AliasExport("glshim_glIsQuery");
void glDeleteQueries(GLsizei n, const GLuint* ids) AliasExport("glshim_glDeleteQueries");
void glBeginQuery(GLenum target, GLuint id) AliasExport("glshim_glBeginQuery");
void glEndQuery(GLenum target) AliasExport("glshim_glEndQuery");
void glGetQueryiv(GLenum target, GLenum pname, GLint* params) AliasExport("glshim_glGetQueryiv");
void glGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) AliasExport("glshim_glGetQueryObjectiv");
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) AliasExport("glshim_glGetQueryObjectuiv");

View File

@@ -0,0 +1,23 @@
#include "gl.h"
#ifndef GL_QUERIES_H
#define GL_QUERIES_H
void glshim_glBeginQuery(GLenum target, GLuint id);
void glshim_glEndQuery(GLenum target);
void glshim_glGenQueries(GLsizei n, GLuint * ids);
void glshim_glDeleteQueries(GLsizei n, const GLuint* ids);
GLboolean glshim_glIsQuery(GLuint id);
void glshim_glGetQueryiv(GLenum target, GLenum pname, GLint* params);
void glshim_glGetQueryObjectiv(GLuint id, GLenum pname, GLint* params);
void glshim_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params);
typedef struct {
GLuint id;
GLenum target;
int num;
} glquery_t;
KHASH_MAP_INIT_INT(queries, glquery_t *)
#endif

View File

@@ -18,13 +18,13 @@ static GLint raster_x1, raster_x2, raster_y1, raster_y2;
GLfloat raster_scale[4] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat raster_bias[4] = {0.0f, 0.0f, 0.0f, 0.0f};
extern void matrix_column_row(const GLfloat *a, GLfloat *b);
extern void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c);
void matrix_column_row(const GLfloat *a, GLfloat *b);
void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c);
void glshim_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) {
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_RASTER);
rlRasterOp(glstate.list.active, 1, x, y, z);
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_RASTER);
rlRasterOp(glstate->list.active, 1, x, y, z);
noerrorShim();
return;
}
@@ -53,9 +53,9 @@ void glshim_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) {
}
void glshim_glWindowPos3f(GLfloat x, GLfloat y, GLfloat z) {
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_RASTER);
rlRasterOp(glstate.list.active, 2, x, y, z);
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_RASTER);
rlRasterOp(glstate->list.active, 2, x, y, z);
noerrorShim();
return;
}
@@ -74,10 +74,21 @@ void glshim_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
viewport.height = height;
}
// hacky viewport temporary changes
void pushViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
LOAD_GLES(glViewport);
gles_glViewport(x, y, width, height);
}
void popViewport() {
LOAD_GLES(glViewport);
gles_glViewport(viewport.x, viewport.y, viewport.width, viewport.height);
}
void glshim_glPixelZoom(GLfloat xfactor, GLfloat yfactor) {
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_RASTER);
rlRasterOp(glstate.list.active, 3, xfactor, yfactor, 0.0f);
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_RASTER);
rlRasterOp(glstate->list.active, 3, xfactor, yfactor, 0.0f);
noerrorShim();
return;
}
@@ -87,9 +98,9 @@ void glshim_glPixelZoom(GLfloat xfactor, GLfloat yfactor) {
}
void glshim_glPixelTransferf(GLenum pname, GLfloat param) {
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_RASTER);
rlRasterOp(glstate.list.active, pname|0x10000, param, 0.0f, 0.0f);
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_RASTER);
rlRasterOp(glstate->list.active, pname|0x10000, param, 0.0f, 0.0f);
noerrorShim();
return;
}
@@ -148,7 +159,7 @@ GLubyte raster_transform(GLubyte pix, GLubyte number) {
if (a>1.0) a=1.0;
return (GLubyte)(a*255.0f);
}
GLfloat raster_transformf(GLfloat pix, GLubyte number) {
GLfloat FASTMATH raster_transformf(GLfloat pix, GLubyte number) {
pix=pix*raster_scale[number]+raster_bias[number];
if (pix<0.0) pix=0.0;
if (pix>1.0) pix=1.0;
@@ -174,19 +185,19 @@ GLuint raster_to_texture()
LOAD_GLES(glTexParameteriv);
#endif
renderlist_t *old_list = glstate.list.active;
if (old_list) glstate.list.active = NULL; // deactivate list...
GLboolean compiling = glstate.list.compiling;
GLuint state_batch = glstate.gl_batch;
glstate.list.compiling = false;
glstate.gl_batch = 0;
renderlist_t *old_list = glstate->list.active;
if (old_list) glstate->list.active = NULL; // deactivate list...
GLboolean compiling = glstate->list.compiling;
GLuint state_batch = glstate->gl_batch;
glstate->list.compiling = false;
glstate->gl_batch = 0;
glshim_glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT );
GLuint old_tex_unit, old_tex;
glshim_glGetIntegerv(GL_ACTIVE_TEXTURE, &old_tex_unit);
if (old_tex_unit!=GL_TEXTURE0) glshim_glActiveTexture(GL_TEXTURE0);
old_tex = 0;
if (glstate.texture.bound[0])
old_tex = glstate.texture.bound[0]->texture;
if (glstate->texture.bound[0])
old_tex = glstate->texture.bound[0]->texture;
GLuint raster_texture;
glshim_glEnable(GL_TEXTURE_2D);
gles_glGenTextures(1, &raster_texture);
@@ -214,9 +225,9 @@ GLuint raster_to_texture()
if (old_tex_unit!=GL_TEXTURE0)
glshim_glActiveTexture(old_tex_unit);
glshim_glPopAttrib();
if (old_list) glstate.list.active = old_list;
glstate.list.compiling = compiling;
glstate.gl_batch = state_batch;
if (old_list) glstate->list.active = old_list;
glstate->list.compiling = compiling;
glstate->gl_batch = state_batch;
return raster_texture;
}
@@ -228,10 +239,12 @@ void glshim_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig
// TODO: negative width/height mirrors bitmap?
noerrorShim();
if ((!width && !height) || (bitmap==0)) {
if (glstate.list.compiling || glstate.gl_batch) {
if (glstate.list.active->raster)
glstate.list.active = extend_renderlist(glstate.list.active); // already a raster in the list, create a new one
rasterlist_t *r = glstate.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
if (glstate->list.compiling || glstate->gl_batch) {
if (glstate->list.active->raster)
glstate->list.active = extend_renderlist(glstate->list.active); // already a raster in the list, create a new one
rasterlist_t *r = glstate->list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
r->shared = (int*)malloc(sizeof(int));
*r->shared = 0;
r->texture = 0;
r->xorig = 0;
r->yorig = 0;
@@ -285,9 +298,11 @@ void glshim_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig
rasterlist_t rast;
rasterlist_t *r;
if (glstate.list.compiling || glstate.gl_batch) {
NewStage(glstate.list.active, STAGE_RASTER);
r = glstate.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
if (glstate->list.compiling || glstate->gl_batch) {
NewStage(glstate->list.active, STAGE_RASTER);
r = glstate->list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
r->shared = (int*)malloc(sizeof(int));
*r->shared = 0;
} else {
r = &rast;
}
@@ -302,7 +317,7 @@ void glshim_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig
r->zoomx = raster_zoomx;
r->zoomy = raster_zoomy;
LOAD_GLES(glDeleteTextures);
if (!(glstate.list.compiling || glstate.gl_batch)) {
if (!(glstate->list.compiling || glstate->gl_batch)) {
render_raster_list(r);
gles_glDeleteTextures(1, &r->texture);
r->texture = 0;
@@ -327,7 +342,7 @@ void glshim_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
init_raster(width, height);
GLsizei bmp_width = (glstate.texture.unpack_row_length)?glstate.texture.unpack_row_length:width;
GLsizei bmp_width = (glstate->texture.unpack_row_length)?glstate->texture.unpack_row_length:width;
if (! pixel_convert(data, &dst, bmp_width, height,
format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0)) {
@@ -341,7 +356,7 @@ void glshim_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
if (pixtrans) {
for (int y = 0; y < height; y++) {
to = raster + 4 * (GLint)(y * raster_width);
from = pixels + 4 * (glstate.texture.unpack_skip_pixels + (y + glstate.texture.unpack_skip_rows) * bmp_width);
from = pixels + 4 * (glstate->texture.unpack_skip_pixels + (y + glstate->texture.unpack_skip_rows) * bmp_width);
for (int x = 0; x < width; x++) {
*to++ = raster_transform(*from++, 0);
*to++ = raster_transform(*from++, 1);
@@ -352,7 +367,7 @@ void glshim_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
} else {
for (int y = 0; y < height; y++) {
to = raster + 4 * (GLint)(y * raster_width);
from = pixels + 4 * (glstate.texture.unpack_skip_pixels + (y + glstate.texture.unpack_skip_rows) * bmp_width);
from = pixels + 4 * (glstate->texture.unpack_skip_pixels + (y + glstate->texture.unpack_skip_rows) * bmp_width);
for (int x = 0; x < width; x++) {
*to++ = *from++;
*to++ = *from++;
@@ -364,11 +379,13 @@ void glshim_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
if (pixels != data)
free(pixels);
static rasterlist_t rast = {.texture=0};
static rasterlist_t rast = {.texture=0, .shared=NULL};
rasterlist_t *r;
if (glstate.list.compiling || gl_batch) {
NewStage(glstate.list.active, STAGE_RASTER);
rasterlist_t *r = glstate.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
if (glstate->list.compiling || gl_batch) {
NewStage(glstate->list.active, STAGE_RASTER);
rasterlist_t *r = glstate->list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
r->shared = (int*)malloc(sizeof(int));
*r->shared = 0;
} else {
r = &rast;
if(r->texture)
@@ -384,7 +401,7 @@ void glshim_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
r->bitmap = false;
r->zoomx = raster_zoomx;
r->zoomy = raster_zoomy;
if (!(glstate.list.compiling || glstate.gl_batch)) {
if (!(glstate->list.compiling || glstate->gl_batch)) {
render_raster_list(r);
/* gles_glDeleteTextures(1, &r->texture);
r->texture = 0;*/
@@ -409,14 +426,14 @@ void render_raster_list(rasterlist_t* rast) {
LOAD_GLES(glClientActiveTexture);
if (rast->texture) {
GLuint old_tex = glstate.texture.active;
GLuint old_tex = glstate->texture.active;
if (old_tex!=0) gles_glActiveTexture(GL_TEXTURE0);
GLuint old_cli = glstate.texture.client;
GLuint old_cli = glstate->texture.client;
if (old_cli!=0) gles_glClientActiveTexture(GL_TEXTURE0);
#ifdef USE_DRAWTEX
glshim_glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);
gltexture_t *old_bind = glstate.texture.bound[0];
gltexture_t *old_bind = glstate->texture.bound[0];
glshim_glEnable(GL_TEXTURE_2D);
gles_glBindTexture(GL_TEXTURE_2D, rast->texture);
@@ -428,7 +445,7 @@ void render_raster_list(rasterlist_t* rast) {
}
gles_glDrawTexf(rPos.x-rast->xorig, rPos.y-rast->yorig, rPos.z, rast->width * rast->zoomx, rast->height * rast->zoomy);
if (!glstate.enable.texture_2d[0]) glshim_glDisable(GL_TEXTURE_2D);
if (!glstate->enable.texture_2d[0]) glshim_glDisable(GL_TEXTURE_2D);
if (old_tex!=0) gles_glActiveTexture(GL_TEXTURE0+old_tex);
if (old_cli!=0) gles_glClientActiveTexture(GL_TEXTURE0+old_cli);
if (old_bind == NULL)
@@ -485,32 +502,32 @@ void render_raster_list(rasterlist_t* rast) {
gles_glBindTexture(GL_TEXTURE_2D, rast->texture);
glshim_glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if(!glstate.clientstate.vertex_array)
if(!glstate->clientstate.vertex_array)
{
gles_glEnableClientState(GL_VERTEX_ARRAY);
glstate.clientstate.vertex_array = 1;
glstate->clientstate.vertex_array = 1;
}
gles_glVertexPointer(2, GL_FLOAT, 0, rast_vert);
if(!glstate.clientstate.tex_coord_array[0])
if(!glstate->clientstate.tex_coord_array[0])
{
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[0] = 1;
glstate->clientstate.tex_coord_array[0] = 1;
}
gles_glTexCoordPointer(2, GL_FLOAT, 0, rast_tex);
for (int a=1; a <MAX_TEX; a++)
if(glstate.clientstate.tex_coord_array[a]) {
if(glstate->clientstate.tex_coord_array[a]) {
gles_glClientActiveTexture(GL_TEXTURE0 + a);
gles_glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glstate.clientstate.tex_coord_array[a] = 0;
glstate->clientstate.tex_coord_array[a] = 0;
gles_glClientActiveTexture(GL_TEXTURE0);
}
if(glstate.clientstate.color_array) {
if(glstate->clientstate.color_array) {
gles_glDisableClientState(GL_COLOR_ARRAY);
glstate.clientstate.color_array = 0;
glstate->clientstate.color_array = 0;
}
if(glstate.clientstate.normal_array) {
if(glstate->clientstate.normal_array) {
gles_glDisableClientState(GL_NORMAL_ARRAY);
glstate.clientstate.normal_array = 0;
glstate->clientstate.normal_array = 0;
}

View File

@@ -2,31 +2,31 @@
void push_hit() {
// push current hit to hit list, and re-init current hit
if (glstate.selectbuf.hit) {
if (!glstate.selectbuf.overflow) {
if (glstate.selectbuf.zmin<0.0f) glstate.selectbuf.zmin=0.0f; // not really normalized...
if (glstate.selectbuf.zmax>1.0f) glstate.selectbuf.zmax=1.0f; // TODO, normalize for good?
int tocopy = glstate.namestack.top + 3;
if (tocopy+glstate.selectbuf.pos > glstate.selectbuf.size) {
glstate.selectbuf.overflow = 1;
tocopy = glstate.selectbuf.size - glstate.selectbuf.pos;
if (glstate->selectbuf.hit) {
if (!glstate->selectbuf.overflow) {
if (glstate->selectbuf.zmin<0.0f) glstate->selectbuf.zmin=0.0f; // not really normalized...
if (glstate->selectbuf.zmax>1.0f) glstate->selectbuf.zmax=1.0f; // TODO, normalize for good?
int tocopy = glstate->namestack.top + 3;
if (tocopy+glstate->selectbuf.pos > glstate->selectbuf.size) {
glstate->selectbuf.overflow = 1;
tocopy = glstate->selectbuf.size - glstate->selectbuf.pos;
}
if(tocopy>0)
glstate.selectbuf.buffer[glstate.selectbuf.pos+0] = glstate.namestack.top;
glstate->selectbuf.buffer[glstate->selectbuf.pos+0] = glstate->namestack.top;
if(tocopy>1)
glstate.selectbuf.buffer[glstate.selectbuf.pos+1] = (unsigned int)(glstate.selectbuf.zmin * INT_MAX );
glstate->selectbuf.buffer[glstate->selectbuf.pos+1] = (unsigned int)(glstate->selectbuf.zmin * INT_MAX );
if(tocopy>2)
glstate.selectbuf.buffer[glstate.selectbuf.pos+2] = (unsigned int)(glstate.selectbuf.zmax * INT_MAX );
glstate->selectbuf.buffer[glstate->selectbuf.pos+2] = (unsigned int)(glstate->selectbuf.zmax * INT_MAX );
if(tocopy>3)
memcpy(glstate.selectbuf.buffer + glstate.selectbuf.pos + 3, glstate.namestack.names, (tocopy-3) * sizeof(GLuint));
memcpy(glstate->selectbuf.buffer + glstate->selectbuf.pos + 3, glstate->namestack.names, (tocopy-3) * sizeof(GLuint));
glstate.selectbuf.count++;
glstate.selectbuf.pos += tocopy;
glstate->selectbuf.count++;
glstate->selectbuf.pos += tocopy;
}
glstate.selectbuf.hit = 0;
glstate->selectbuf.hit = 0;
}
glstate.selectbuf.zmin = 1.0f;
glstate.selectbuf.zmax = 0.0f;
glstate->selectbuf.zmin = 1.0f;
glstate->selectbuf.zmax = 0.0f;
}
@@ -38,83 +38,83 @@ GLint glshim_glRenderMode(GLenum mode) {
errorShim(GL_INVALID_ENUM);
return 0;
}
if (glstate.render_mode == GL_SELECT) {
if (glstate->render_mode == GL_SELECT) {
push_hit();
ret = glstate.selectbuf.count;
ret = glstate->selectbuf.count;
}
if (mode == GL_SELECT) {
if (glstate.selectbuf.buffer == NULL) {// error, cannot use Select Mode without select buffer
if (glstate->selectbuf.buffer == NULL) {// error, cannot use Select Mode without select buffer
errorShim(GL_INVALID_OPERATION);
return 0;
}
glstate.selectbuf.count = 0;
glstate.selectbuf.pos = 0;
glstate.selectbuf.overflow = 0;
glstate.selectbuf.zmin = 1.0f;
glstate.selectbuf.zmax = 0.0f;
glstate.selectbuf.hit = 0;
glstate->selectbuf.count = 0;
glstate->selectbuf.pos = 0;
glstate->selectbuf.overflow = 0;
glstate->selectbuf.zmin = 1.0f;
glstate->selectbuf.zmax = 0.0f;
glstate->selectbuf.hit = 0;
}
if((mode==GL_SELECT) && (glstate.gl_batch)) {
glstate.gl_batch = 0;
if((mode==GL_SELECT) && (glstate->gl_batch)) {
glstate->gl_batch = 0;
flush();
}
if((mode==GL_RENDER) && (glstate.gl_batch==0) && (gl_batch==1)) {
glstate.gl_batch = 1;
if((mode==GL_RENDER) && (glstate->gl_batch==0) && (gl_batch==1)) {
glstate->gl_batch = 1;
flush();
}
glstate.render_mode = mode;
glstate->render_mode = mode;
return ret;
}
void glshim_glInitNames() {
if (glstate.namestack.names == 0) {
glstate.namestack.names = (GLuint*)malloc(1024*sizeof(GLuint));
if (glstate->namestack.names == 0) {
glstate->namestack.names = (GLuint*)malloc(1024*sizeof(GLuint));
}
glstate.namestack.top = 0;
glstate->namestack.top = 0;
noerrorShim();
}
void glshim_glPopName() {
noerrorShim();
if (glstate.render_mode != GL_SELECT)
if (glstate->render_mode != GL_SELECT)
return;
push_hit();
if (glstate.namestack.top>0)
glstate.namestack.top--;
if (glstate->namestack.top>0)
glstate->namestack.top--;
else
errorShim(GL_STACK_UNDERFLOW);
}
void glshim_glPushName(GLuint name) {
noerrorShim();
if (glstate.render_mode != GL_SELECT)
if (glstate->render_mode != GL_SELECT)
return;
if (glstate.namestack.names==0)
if (glstate->namestack.names==0)
return;
push_hit();
if (glstate.namestack.top < 1024) {
glstate.namestack.names[glstate.namestack.top++] = name;
if (glstate->namestack.top < 1024) {
glstate->namestack.names[glstate->namestack.top++] = name;
}
}
void glshim_glLoadName(GLuint name) {
noerrorShim();
if (glstate.render_mode != GL_SELECT)
if (glstate->render_mode != GL_SELECT)
return;
if (glstate.namestack.names == 0)
if (glstate->namestack.names == 0)
return;
push_hit();
if (glstate.namestack.top == 0)
if (glstate->namestack.top == 0)
return;
glstate.namestack.names[glstate.namestack.top-1] = name;
glstate->namestack.names[glstate->namestack.top-1] = name;
}
void glshim_glSelectBuffer(GLsizei size, GLuint *buffer) {
noerrorShim();
glstate.selectbuf.buffer = buffer;
glstate.selectbuf.size = size;
glstate->selectbuf.buffer = buffer;
glstate->selectbuf.size = size;
}
GLfloat projection[16], modelview[16];
@@ -221,7 +221,7 @@ GLboolean select_triangle_in_viewscreen(const GLfloat *a, const GLfloat *b, cons
void select_glDrawArrays(const pointer_state_t* vtx, GLenum mode, GLuint first, GLuint count) {
if (count == 0) return;
if (vtx->pointer == NULL) return;
if (glstate.selectbuf.buffer == NULL) return;
if (glstate->selectbuf.buffer == NULL) return;
GLfloat *vert = copy_gl_array(vtx->pointer, vtx->type,
vtx->size, vtx->stride,
GL_FLOAT, 4, 0, count+first);
@@ -229,9 +229,9 @@ void select_glDrawArrays(const pointer_state_t* vtx, GLenum mode, GLuint first,
init_select();
#define FOUND() { \
if (zmin<glstate.selectbuf.zmin) glstate.selectbuf.zmin=zmin; \
if (zmax>glstate.selectbuf.zmax) glstate.selectbuf.zmax=zmax; \
glstate.selectbuf.hit = 1; \
if (zmin<glstate->selectbuf.zmin) glstate->selectbuf.zmin=zmin; \
if (zmax>glstate->selectbuf.zmax) glstate->selectbuf.zmax=zmax; \
glstate->selectbuf.hit = 1; \
free(vert); \
return; \
}
@@ -311,9 +311,9 @@ void select_glDrawElements(const pointer_state_t* vtx, GLenum mode, GLuint count
if (zmax>1.0f) zmax = 1.0f;
#define FOUND() { \
if (zmin<glstate.selectbuf.zmin) glstate.selectbuf.zmin=zmin; \
if (zmax>glstate.selectbuf.zmax) glstate.selectbuf.zmax=zmax; \
glstate.selectbuf.hit = 1; \
if (zmin<glstate->selectbuf.zmin) glstate->selectbuf.zmin=zmin; \
if (zmax>glstate->selectbuf.zmax) glstate->selectbuf.zmax=zmax; \
glstate->selectbuf.hit = 1; \
free(vert); \
return; \
}

View File

@@ -1,26 +1,23 @@
#include "stack.h"
glstack_t *stack = NULL;
glclientstack_t *clientStack = NULL;
void glshim_glPushAttrib(GLbitfield mask) {
//printf("glPushAttrib(0x%04X)\n", mask);
noerrorShim();
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_PUSH);
glstate.list.active->pushattribute = mask;
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_PUSH);
glstate->list.active->pushattribute = mask;
return;
}
if (stack == NULL) {
stack = (glstack_t *)malloc(STACK_SIZE * sizeof(glstack_t));
stack->len = 0;
stack->cap = STACK_SIZE;
} else if (stack->len == stack->cap) {
stack->cap += STACK_SIZE;
stack = (glstack_t *)realloc(stack, stack->cap * sizeof(glstack_t));
if (glstate->stack == NULL) {
glstate->stack = (glstack_t *)malloc(STACK_SIZE * sizeof(glstack_t));
glstate->stack->len = 0;
glstate->stack->cap = STACK_SIZE;
} else if (glstate->stack->len == glstate->stack->cap) {
glstate->stack->cap += STACK_SIZE;
glstate->stack = (glstack_t *)realloc(glstate->stack, glstate->stack->cap * sizeof(glstack_t));
}
glstack_t *cur = stack + stack->len;
glstack_t *cur = glstate->stack + glstate->stack->len;
cur->mask = mask;
cur->clip_planes_enabled = NULL;
cur->clip_planes = NULL;
@@ -109,12 +106,12 @@ void glshim_glPushAttrib(GLbitfield mask) {
cur->stencil_test = glshim_glIsEnabled(GL_STENCIL_TEST);
int a;
for (a=0; a<MAX_TEX; a++) {
cur->texture_1d[a] = glstate.enable.texture_1d[a];
cur->texture_2d[a] = glstate.enable.texture_2d[a];
cur->texture_3d[a] = glstate.enable.texture_3d[a];
cur->texgen_s[a] = glstate.enable.texgen_s[a];
cur->texgen_r[a] = glstate.enable.texgen_r[a];
cur->texgen_t[a] = glstate.enable.texgen_t[a];
cur->texture_1d[a] = glstate->enable.texture_1d[a];
cur->texture_2d[a] = glstate->enable.texture_2d[a];
cur->texture_3d[a] = glstate->enable.texture_3d[a];
cur->texgen_s[a] = glstate->enable.texgen_s[a];
cur->texgen_r[a] = glstate->enable.texgen_r[a];
cur->texgen_t[a] = glstate->enable.texgen_t[a];
}
}
@@ -165,7 +162,7 @@ void glshim_glPushAttrib(GLbitfield mask) {
// GL_LIST_BIT
if (mask & GL_LIST_BIT) {
cur->list_base = glstate.list.base;
cur->list_base = glstate->list.base;
}
if (mask & GL_MULTISAMPLE_BIT) {
@@ -220,14 +217,14 @@ void glshim_glPushAttrib(GLbitfield mask) {
}
// GL_TEXTURE_BIT - TODO: incomplete
if (mask & GL_TEXTURE_BIT) {
cur->active=glstate.texture.active;
cur->active=glstate->texture.active;
int a;
for (a=0; a<MAX_TEX; a++) {
cur->texgen_r[a] = glstate.enable.texgen_r[a];
cur->texgen_s[a] = glstate.enable.texgen_s[a];
cur->texgen_t[a] = glstate.enable.texgen_t[a];
cur->texgen[a] = glstate.texgen[a]; // all mode and planes per texture in 1 line
cur->texture[a] = (glstate.texture.bound[a])?glstate.texture.bound[a]->texture:0;
cur->texgen_r[a] = glstate->enable.texgen_r[a];
cur->texgen_s[a] = glstate->enable.texgen_s[a];
cur->texgen_t[a] = glstate->enable.texgen_t[a];
cur->texgen[a] = glstate->texgen[a]; // all mode and planes per texture in 1 line
cur->texture[a] = (glstate->texture.bound[a])?glstate->texture.bound[a]->texture:0;
}
//glActiveTexture(GL_TEXTURE0+cur->active);
}
@@ -253,48 +250,54 @@ void glshim_glPushAttrib(GLbitfield mask) {
glshim_glGetFloatv(GL_DEPTH_RANGE, cur->depth_range);
}
stack->len++;
glstate->stack->len++;
}
void glshim_glPushClientAttrib(GLbitfield mask) {
noerrorShim();
if (clientStack == NULL) {
clientStack = (glclientstack_t *)malloc(STACK_SIZE * sizeof(glclientstack_t));
clientStack->len = 0;
clientStack->cap = STACK_SIZE;
} else if (clientStack->len == clientStack->cap) {
clientStack->cap += STACK_SIZE;
clientStack = (glclientstack_t *)realloc(clientStack, clientStack->cap * sizeof(glclientstack_t));
GLuint old_glbatch = glstate->gl_batch;
if (glstate->gl_batch) {
flush();
glstate->gl_batch = 0;
}
if (glstate->clientStack == NULL) {
glstate->clientStack = (glclientstack_t *)malloc(STACK_SIZE * sizeof(glclientstack_t));
glstate->clientStack->len = 0;
glstate->clientStack->cap = STACK_SIZE;
} else if (glstate->clientStack->len == glstate->clientStack->cap) {
glstate->clientStack->cap += STACK_SIZE;
glstate->clientStack = (glclientstack_t *)realloc(glstate->clientStack, glstate->clientStack->cap * sizeof(glclientstack_t));
}
glclientstack_t *cur = clientStack + clientStack->len;
glclientstack_t *cur = glstate->clientStack + glstate->clientStack->len;
cur->mask = mask;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
glshim_glGetIntegerv(GL_PACK_ALIGNMENT, &cur->pack_align);
glshim_glGetIntegerv(GL_UNPACK_ALIGNMENT, &cur->unpack_align);
cur->unpack_row_length = glstate.texture.unpack_row_length;
cur->unpack_skip_pixels = glstate.texture.unpack_skip_pixels;
cur->unpack_skip_rows = glstate.texture.unpack_skip_rows;
cur->pack_row_length = glstate.texture.pack_row_length;
cur->pack_skip_pixels = glstate.texture.pack_skip_pixels;
cur->pack_skip_rows = glstate.texture.pack_skip_rows;
cur->unpack_row_length = glstate->texture.unpack_row_length;
cur->unpack_skip_pixels = glstate->texture.unpack_skip_pixels;
cur->unpack_skip_rows = glstate->texture.unpack_skip_rows;
cur->pack_row_length = glstate->texture.pack_row_length;
cur->pack_skip_pixels = glstate->texture.pack_skip_pixels;
cur->pack_skip_rows = glstate->texture.pack_skip_rows;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
cur->vert_enable = glstate.vao->vertex_array;
cur->color_enable = glstate.vao->color_array;
cur->secondary_enable = glstate.vao->secondary_array;
cur->normal_enable = glstate.vao->normal_array;
cur->vert_enable = glstate->vao->vertex_array;
cur->color_enable = glstate->vao->color_array;
cur->secondary_enable = glstate->vao->secondary_array;
cur->normal_enable = glstate->vao->normal_array;
int a;
for (a=0; a<MAX_TEX; a++) {
cur->tex_enable[a] = glstate.vao->tex_coord_array[a];
cur->tex_enable[a] = glstate->vao->tex_coord_array[a];
}
memcpy(&(cur->pointers), &glstate.vao->pointers, sizeof(pointer_states_t));
cur->client = glstate.texture.client;
memcpy(&(cur->pointers), &glstate->vao->pointers, sizeof(pointer_states_t));
cur->client = glstate->texture.client;
}
clientStack->len++;
glstate->clientStack->len++;
glstate->gl_batch=old_glbatch;
}
#define maybe_free(x) \
@@ -311,17 +314,17 @@ void glshim_glPushClientAttrib(GLbitfield mask) {
void glshim_glPopAttrib() {
//printf("glPopAttrib()\n");
noerrorShim();
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_POP);
glstate.list.active->popattribute = true;
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_POP);
glstate->list.active->popattribute = true;
return;
}
if (stack == NULL || stack->len == 0) {
if (glstate->stack == NULL || glstate->stack->len == 0) {
errorShim(GL_STACK_UNDERFLOW);
return;
}
glstack_t *cur = stack + stack->len-1;
glstack_t *cur = glstate->stack + glstate->stack->len-1;
if (cur->mask & GL_COLOR_BUFFER_BIT) {
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
@@ -398,25 +401,25 @@ void glshim_glPopAttrib() {
enable_disable(GL_SCISSOR_TEST, cur->scissor_test);
enable_disable(GL_STENCIL_TEST, cur->stencil_test);
int a;
int old_tex = glstate.texture.active;
int old_tex = glstate->texture.active;
for (a=0; a<MAX_TEX; a++) {
if (glstate.enable.texture_1d[a] != cur->texture_1d[a]) {
if (glstate->enable.texture_1d[a] != cur->texture_1d[a]) {
glshim_glActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_1D, cur->texture_1d[a]);
}
if (glstate.enable.texture_2d[a] != cur->texture_2d[a]) {
if (glstate->enable.texture_2d[a] != cur->texture_2d[a]) {
glshim_glActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_2D, cur->texture_2d[a]);
}
if (glstate.enable.texture_3d[a] != cur->texture_3d[a]) {
if (glstate->enable.texture_3d[a] != cur->texture_3d[a]) {
glshim_glActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_3D, cur->texture_3d[a]);
}
glstate.enable.texgen_r[a] = cur->texgen_r[a];
glstate.enable.texgen_s[a] = cur->texgen_s[a];
glstate.enable.texgen_t[a] = cur->texgen_t[a];
glstate->enable.texgen_r[a] = cur->texgen_r[a];
glstate->enable.texgen_s[a] = cur->texgen_s[a];
glstate->enable.texgen_t[a] = cur->texgen_t[a];
}
if (glstate.texture.active != old_tex) glshim_glActiveTexture(GL_TEXTURE0+old_tex);
if (glstate->texture.active != old_tex) glshim_glActiveTexture(GL_TEXTURE0+old_tex);
}
if (cur->mask & GL_FOG_BIT) {
@@ -476,16 +479,16 @@ void glshim_glPopAttrib() {
int a;
//TODO: Enable bit for the 4 texture coordinates
for (a=0; a<MAX_TEX; a++) {
glstate.enable.texgen_r[a] = cur->texgen_r[a];
glstate.enable.texgen_s[a] = cur->texgen_s[a];
glstate.enable.texgen_t[a] = cur->texgen_t[a];
glstate.texgen[a] = cur->texgen[a]; // all mode and planes per texture in 1 line
if ((cur->texture[a]==0 && glstate.texture.bound[a] != 0) || (cur->texture[a]!=0 && glstate.texture.bound[a]==0)) {
glstate->enable.texgen_r[a] = cur->texgen_r[a];
glstate->enable.texgen_s[a] = cur->texgen_s[a];
glstate->enable.texgen_t[a] = cur->texgen_t[a];
glstate->texgen[a] = cur->texgen[a]; // all mode and planes per texture in 1 line
if ((cur->texture[a]==0 && glstate->texture.bound[a] != 0) || (cur->texture[a]!=0 && glstate->texture.bound[a]==0)) {
glshim_glActiveTexture(GL_TEXTURE0+a);
glshim_glBindTexture(GL_TEXTURE_2D, cur->texture[a]);
}
}
if (glstate.texture.active!= cur->active) glshim_glActiveTexture(GL_TEXTURE0+cur->active);
if (glstate->texture.active!= cur->active) glshim_glActiveTexture(GL_TEXTURE0+cur->active);
}
if (cur->mask & GL_PIXEL_MODE_BIT) {
@@ -522,7 +525,7 @@ void glshim_glPopAttrib() {
maybe_free(cur->clip_planes);
maybe_free(cur->lights_enabled);
maybe_free(cur->lights);
stack->len--;
glstate->stack->len--;
}
#undef enable_disable
@@ -532,17 +535,22 @@ void glshim_glPopAttrib() {
void glshim_glPopClientAttrib() {
noerrorShim();
GLuint old_glbatch = glstate->gl_batch;
if (glstate->gl_batch) {
flush();
glstate->gl_batch = 0;
}
//LOAD_GLES(glVertexPointer);
//LOAD_GLES(glColorPointer);
//LOAD_GLES(glNormalPointer);
//LOAD_GLES(glTexCoordPointer);
if (clientStack == NULL || clientStack->len == 0) {
if (glstate->clientStack == NULL || glstate->clientStack->len == 0) {
errorShim(GL_STACK_UNDERFLOW);
return;
}
glclientstack_t *cur = clientStack + clientStack->len-1;
glclientstack_t *cur = glstate->clientStack + glstate->clientStack->len-1;
if (cur->mask & GL_CLIENT_PIXEL_STORE_BIT) {
glshim_glPixelStorei(GL_PACK_ALIGNMENT, cur->pack_align);
glshim_glPixelStorei(GL_UNPACK_ALIGNMENT, cur->unpack_align);
@@ -555,26 +563,27 @@ void glshim_glPopClientAttrib() {
}
if (cur->mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
if (glstate.vao->vertex_array != cur->vert_enable)
if (glstate->vao->vertex_array != cur->vert_enable)
enable_disable(GL_VERTEX_ARRAY, cur->vert_enable);
if (glstate.vao->normal_array != cur->normal_enable)
if (glstate->vao->normal_array != cur->normal_enable)
enable_disable(GL_NORMAL_ARRAY, cur->normal_enable);
if (glstate.vao->color_array != cur->color_enable)
if (glstate->vao->color_array != cur->color_enable)
enable_disable(GL_COLOR_ARRAY, cur->color_enable);
if (glstate.vao->secondary_array != cur->secondary_enable)
if (glstate->vao->secondary_array != cur->secondary_enable)
enable_disable(GL_SECONDARY_COLOR_ARRAY, cur->secondary_enable);
for (int a=0; a<MAX_TEX; a++) {
if (glstate.vao->tex_coord_array[a] != cur->tex_enable[a]) {
if (glstate->vao->tex_coord_array[a] != cur->tex_enable[a]) {
glshim_glClientActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_COORD_ARRAY, cur->tex_enable[a]);
}
}
memcpy(&glstate.vao->pointers, &(cur->pointers), sizeof(pointer_states_t));
if (glstate.texture.client != cur->client) glshim_glClientActiveTexture(GL_TEXTURE0+cur->client);
memcpy(&glstate->vao->pointers, &(cur->pointers), sizeof(pointer_states_t));
if (glstate->texture.client != cur->client) glshim_glClientActiveTexture(GL_TEXTURE0+cur->client);
}
clientStack->len--;
glstate->clientStack->len--;
glstate->gl_batch = old_glbatch;
}
#undef maybe_free

View File

@@ -6,7 +6,7 @@
#define STACK_SIZE 16
typedef struct {
typedef struct _glstack_t {
GLbitfield mask;
// GL_COLOR_BUFFER_BIT
@@ -139,7 +139,7 @@ typedef struct {
unsigned int cap;
} glstack_t;
typedef struct {
typedef struct _glclientstack_t {
GLbitfield mask;
// GL_CLIENT_PIXEL_STORE_BIT

View File

@@ -6,6 +6,10 @@
#include "eval.h"
#include "texture.h"
#include "buffers.h"
#include "queries.h"
typedef struct _glstack_t glstack_t;
typedef struct _glclientstack_t glclientstack_t;
typedef struct {
GLboolean line_stipple,
@@ -160,9 +164,14 @@ typedef struct {
int shim_error;
GLenum last_error;
GLuint gl_batch;
int init_batch;
GLint vp[4];
statebatch_t statebatch;
clientstate_t clientstate;
khash_t(queries) *queries;
glstack_t *stack;
glclientstack_t *clientStack;
int shared_cnt;
} glstate_t;
#endif

View File

@@ -19,10 +19,10 @@ void glshim_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
generation function specified by pname.
*/
//printf("glTexGenfv(0x%04X, 0x%04X, [%.02f, ...]), texture=%i\n", coord, pname, param[0], glstate.texture.active);
if ((glstate.list.compiling || glstate.gl_batch) && glstate.list.active) {
NewStage(glstate.list.active, STAGE_TEXGEN);
rlTexGenfv(glstate.list.active, coord, pname, param);
//printf("glTexGenfv(%s, %s, [%s, ...]), texture=%i\n", PrintEnum(coord), PrintEnum(pname), PrintEnum(param[0]), glstate->texture.active);
if ((glstate->list.compiling || glstate->gl_batch) && glstate->list.active) {
NewStage(glstate->list.active, STAGE_TEXGEN);
rlTexGenfv(glstate->list.active, coord, pname, param);
noerrorShim();
return;
}
@@ -32,9 +32,9 @@ void glshim_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
switch(pname) {
case GL_TEXTURE_GEN_MODE:
switch (coord) {
case GL_S: glstate.texgen[glstate.texture.active].S = param[0]; break;
case GL_T: glstate.texgen[glstate.texture.active].T = param[0]; break;
case GL_R: glstate.texgen[glstate.texture.active].R = param[0]; break;
case GL_S: glstate->texgen[glstate->texture.active].S = param[0]; break;
case GL_T: glstate->texgen[glstate->texture.active].T = param[0]; break;
case GL_R: glstate->texgen[glstate->texture.active].R = param[0]; break;
default:
errorShim(GL_INVALID_ENUM);
return;
@@ -42,13 +42,13 @@ void glshim_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
case GL_OBJECT_PLANE:
switch (coord) {
case GL_S:
memcpy(glstate.texgen[glstate.texture.active].S_O, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].S_O, param, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(glstate.texgen[glstate.texture.active].T_O, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].T_O, param, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(glstate.texgen[glstate.texture.active].R_O, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].R_O, param, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
@@ -57,13 +57,13 @@ void glshim_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
case GL_EYE_PLANE:
switch (coord) {
case GL_S:
memcpy(glstate.texgen[glstate.texture.active].S_E, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].S_E, param, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(glstate.texgen[glstate.texture.active].T_E, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].T_E, param, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(glstate.texgen[glstate.texture.active].R_E, param, 4 * sizeof(GLfloat));
memcpy(glstate->texgen[glstate->texture.active].R_E, param, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
@@ -79,22 +79,22 @@ void glshim_glGetTexGenfv(GLenum coord,GLenum pname,GLfloat *params) {
switch(pname) {
case GL_TEXTURE_GEN_MODE:
switch (coord) {
case GL_S: *params = glstate.texgen[glstate.texture.active].S; break;
case GL_T: *params = glstate.texgen[glstate.texture.active].T; break;
case GL_R: *params = glstate.texgen[glstate.texture.active].R; break;
case GL_S: *params = glstate->texgen[glstate->texture.active].S; break;
case GL_T: *params = glstate->texgen[glstate->texture.active].T; break;
case GL_R: *params = glstate->texgen[glstate->texture.active].R; break;
default: *params = GL_EYE_LINEAR;
}
break;
case GL_OBJECT_PLANE:
switch (coord) {
case GL_S:
memcpy(params, glstate.texgen[glstate.texture.active].S_O, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].S_O, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(params, glstate.texgen[glstate.texture.active].T_O, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].T_O, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(params, glstate.texgen[glstate.texture.active].R_O, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].R_O, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
@@ -102,13 +102,13 @@ void glshim_glGetTexGenfv(GLenum coord,GLenum pname,GLfloat *params) {
case GL_EYE_PLANE:
switch (coord) {
case GL_S:
memcpy(params, glstate.texgen[glstate.texture.active].S_E, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].S_E, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(params, glstate.texgen[glstate.texture.active].T_E, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].T_E, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(params, glstate.texgen[glstate.texture.active].R_E, 4 * sizeof(GLfloat));
memcpy(params, glstate->texgen[glstate->texture.active].R_E, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
@@ -120,34 +120,89 @@ void glshim_glGetTexGenfv(GLenum coord,GLenum pname,GLfloat *params) {
}
GLfloat dot(const GLfloat *a, const GLfloat *b) {
GLfloat FASTMATH dot(const GLfloat *a, const GLfloat *b) {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
}
GLfloat dot4(const GLfloat *a, const GLfloat *b) {
GLfloat FASTMATH dot4(const GLfloat *a, const GLfloat *b) {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3];
}
//TODO: NEONize all thoses functions, maybe also making the vector an array of 4 float can help.
void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c) {
#ifdef __ARM_NEON__
const float* a1 = a+8;
asm volatile (
"vld4.f32 {d0,d2,d4,d6}, [%1] \n"
"vld4.f32 {d1,d3,d5,d7}, [%2] \n" // %q0-%q3 = a(0,4,8,12/1,5,9,13/2,6,10,14/3,7,11,15)
"vld1.f32 {q4}, [%3] \n" // %q4 = b
"vmul.f32 q0, q0, d8[0] \n" // %q0 = a(0,4,8,12)*b[0]
"vmla.f32 q0, q1, d8[1] \n" // %q0 = %q0 + a(1,5,9,13)*b[1]
"vmla.f32 q0, q2, d9[0] \n" // %q0 = %q0 + a(2,6,10,14)*b[2]
"vmla.f32 q0, q3, d9[1] \n" // %q0 = %q0 + a(3,7,11,15)*b[3]
"vst1.f32 {q0}, [%0] \n"
::"r"(c), "r"(a), "r"(a1), "r"(b)
: "q0", "q1", "q2", "q3", "q4", "memory"
);
#else
c[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
c[1] = a[4] * b[0] + a[5] * b[1] + a[6] * b[2] + a[7] * b[3];
c[2] = a[8] * b[0] + a[9] * b[1] + a[10] * b[2] + a[11] * b[3];
c[3] = a[12] * b[0] + a[13] * b[1] + a[14] * b[2] + a[15] * b[3];
#endif
}
void vector_matrix(const GLfloat *a, const GLfloat *b, GLfloat *c) {
#ifdef __ARM_NEON__
const float* b2=b+4;
const float* b3=b+8;
const float* b4=b+12;
asm volatile (
"vld1.f32 {q0}, [%1] \n" // %q0 = a(0..3)
"vld1.f32 {q1}, [%2] \n" // %q1 = b(0..3)
"vmul.f32 q1, q1, d0[0] \n" // %q1 = b(0..3)*a[0]
"vld1.f32 {q2}, [%3] \n" // %q2 = b(4..7)
"vmla.f32 q1, q2, d0[1] \n" // %q1 = %q1 + b(4..7)*a[1]
"vld1.f32 {q2}, [%4] \n" // %q2 = b(8..11)
"vmla.f32 q1, q2, d1[0] \n" // %q1 = %q1 + b(8..11)*a[2]
"vld1.f32 {q2}, [%5] \n" // %q2 = b(12..15)
"vmla.f32 q1, q2, d1[1] \n" // %q1 = %q1 + b(12..15)*a[3]
"vst1.f32 {q1}, [%0] \n"
::"r"(c), "r"(a), "r"(b), "r"(b2), "r"(b3), "r"(b4)
: "%2", "q0", "q1", "q2", "memory"
);
#else
c[0] = a[0] * b[0] + a[1] * b[4] + a[2] * b[8] + a[3] * b[12];
c[1] = a[0] * b[1] + a[1] * b[5] + a[2] * b[9] + a[3] * b[13];
c[2] = a[0] * b[2] + a[1] * b[6] + a[2] * b[10] + a[3] * b[14];
c[3] = a[0] * b[3] + a[1] * b[7] + a[2] * b[11] + a[3] * b[15];
#endif
}
void vector3_matrix(const GLfloat *a, const GLfloat *b, GLfloat *c) {
#ifdef __ARM_NEON__
const float* b2=b+4;
const float* b3=b+8;
const float* b4=b+12;
asm volatile (
"vld1.f32 {q0}, [%1] \n" // %q0 = a(0..3)
"vld1.f32 {q1}, [%2] \n" // %q1 = b(0..3)
"vmul.f32 q1, q1, d0[0] \n" // %q1 = b(0..3)*a[0]
"vld1.f32 {q2}, [%3] \n" // %q2 = b(4..7)
"vmla.f32 q1, q2, d0[1] \n" // %q1 = %q1 + b(4..7)*a[1]
"vld1.f32 {q2}, [%4] \n" // %q2 = b(8..11)
"vmla.f32 q1, q2, d1[0] \n" // %q1 = %q1 + b(8..11)*a[2]
"vld1.f32 {q2}, [%5] \n" // %q2 = b(12..15)
"vadd.f32 q1, q1, q2 \n" // %q1 = %q1 + b(12..15)
"vst1.f32 {q1}, [%0] \n"
::"r"(c), "r"(a), "r"(b), "r"(b2), "r"(b3), "r"(b4)
: "q0", "q1", "q2", "memory"
);
#else
c[0] = a[0] * b[0] + a[1] * b[4] + a[2] * b[8] + b[12];
c[1] = a[0] * b[1] + a[1] * b[5] + a[2] * b[9] + b[13];
c[2] = a[0] * b[2] + a[1] * b[6] + a[2] * b[10] + b[14];
c[3] = a[0] * b[3] + a[1] * b[7] + a[2] * b[11] + b[15];
#endif
}
void vector_normalize(GLfloat *a) {
@@ -264,7 +319,7 @@ void sphere_loop(const GLfloat *verts, const GLfloat *norm, GLfloat *out, GLint
GLushort k = indices?indices[i]:i;
matrix_vector(ModelviewMatrix, verts+k*4, eye);
vector_normalize(eye);
vector3_matrix((norm)?(norm+k*3):glstate.normal, InvModelview, eye_norm);
vector3_matrix((norm)?(norm+k*3):glstate->normal, InvModelview, eye_norm);
vector_normalize(eye_norm);
a=dot(eye, eye_norm)*2.0f;
for (int j=0; j<4; j++)
@@ -313,26 +368,27 @@ static inline void tex_coord_loop(GLfloat *verts, GLfloat *norm, GLfloat *out, G
}
void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count, GLint *needclean, int texture, GLushort *indices, GLuint ilen) {
//printf("gen_tex_coords(%p, %p, %p, %d, %p, %d, %p, %d) texgen = S:%s T:%s R:%s\n", verts, norm, *coords, count, needclean, texture, indices, ilen, (glstate->enable.texgen_s[texture])?PrintEnum(glstate->texgen[texture].S):"-", (glstate->enable.texgen_t[texture])?PrintEnum(glstate->texgen[texture].T):"-", (glstate->enable.texgen_r[texture])?PrintEnum(glstate->texgen[texture].R):"-");
// TODO: do less work when called from glDrawElements?
(*needclean) = 0;
// special case : no texgen but texture activated, create a simple 1 repeated element
if (!glstate.enable.texgen_s[texture] && !glstate.enable.texgen_t[texture] && !glstate.enable.texgen_r[texture]) {
if (!glstate->enable.texgen_s[texture] && !glstate->enable.texgen_t[texture] && !glstate->enable.texgen_r[texture]) {
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
if (indices)
for (int i=0; i<ilen; i++) {
memcpy((*coords)+indices[i]*4, glstate.texcoord[texture], sizeof(GLfloat)*4);
memcpy((*coords)+indices[i]*4, glstate->texcoord[texture], sizeof(GLfloat)*4);
}
else
for (int i=0; i<count*4; i+=4) {
memcpy((*coords)+i, glstate.texcoord[texture], sizeof(GLfloat)*4);
memcpy((*coords)+i, glstate->texcoord[texture], sizeof(GLfloat)*4);
}
return;
}
// special case: SPHERE_MAP needs both texgen to make sense
if ((glstate.enable.texgen_s[texture] && (glstate.texgen[texture].S==GL_SPHERE_MAP)) && (glstate.enable.texgen_t[texture] && (glstate.texgen[texture].T==GL_SPHERE_MAP)))
if ((glstate->enable.texgen_s[texture] && (glstate->texgen[texture].S==GL_SPHERE_MAP)) && (glstate->enable.texgen_t[texture] && (glstate->texgen[texture].T==GL_SPHERE_MAP)))
{
if (!glstate.enable.texture_2d[texture])
if (!glstate->enable.texture_2d[texture])
return;
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
@@ -340,13 +396,13 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
return;
}
// special case: REFLECTION_MAP needs the 3 texgen to make sense
if ((glstate.enable.texgen_s[texture] && (glstate.texgen[texture].S==GL_REFLECTION_MAP))
&& (glstate.enable.texgen_t[texture] && (glstate.texgen[texture].T==GL_REFLECTION_MAP))
&& (glstate.enable.texgen_r[texture] && (glstate.texgen[texture].R==GL_REFLECTION_MAP)))
if ((glstate->enable.texgen_s[texture] && (glstate->texgen[texture].S==GL_REFLECTION_MAP))
&& (glstate->enable.texgen_t[texture] && (glstate->texgen[texture].T==GL_REFLECTION_MAP))
&& (glstate->enable.texgen_r[texture] && (glstate->texgen[texture].R==GL_REFLECTION_MAP)))
{
*needclean=1;
// setup reflection map!
GLuint old_tex=glstate.texture.active;
GLuint old_tex=glstate->texture.active;
if (old_tex!=texture) glshim_glActiveTexture(GL_TEXTURE0 + texture);
LOAD_GLES_OES(glTexGeni);
LOAD_GLES_OES(glTexGenfv);
@@ -363,13 +419,13 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
return;
}
// special case: NORMAL_MAP needs the 3 texgen to make sense
if ((glstate.enable.texgen_s[texture] && (glstate.texgen[texture].S==GL_NORMAL_MAP))
&& (glstate.enable.texgen_t[texture] && (glstate.texgen[texture].T==GL_NORMAL_MAP))
&& (glstate.enable.texgen_r[texture] && (glstate.texgen[texture].R==GL_NORMAL_MAP)))
if ((glstate->enable.texgen_s[texture] && (glstate->texgen[texture].S==GL_NORMAL_MAP))
&& (glstate->enable.texgen_t[texture] && (glstate->texgen[texture].T==GL_NORMAL_MAP))
&& (glstate->enable.texgen_r[texture] && (glstate->texgen[texture].R==GL_NORMAL_MAP)))
{
*needclean=1;
// setup reflection map!
GLuint old_tex=glstate.texture.active;
GLuint old_tex=glstate->texture.active;
if (old_tex!=texture) glshim_glActiveTexture(GL_TEXTURE0 + texture);
LOAD_GLES_OES(glTexGeni);
LOAD_GLES_OES(glTexGenfv);
@@ -385,14 +441,14 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
return;
}
if (!glstate.enable.texture_2d[texture])
if (!glstate->enable.texture_2d[texture])
return;
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
if (glstate.enable.texgen_s[texture])
tex_coord_loop(verts, norm, *coords, (indices)?ilen:count, glstate.texgen[texture].S, glstate.texgen[texture].S_O, glstate.texgen[texture].S_E, indices);
if (glstate.enable.texgen_t[texture])
tex_coord_loop(verts, norm, *coords+1, (indices)?ilen:count, glstate.texgen[texture].T, glstate.texgen[texture].T_O, glstate.texgen[texture].T_E, indices);
if (glstate->enable.texgen_s[texture])
tex_coord_loop(verts, norm, *coords, (indices)?ilen:count, glstate->texgen[texture].S, glstate->texgen[texture].S_O, glstate->texgen[texture].S_E, indices);
if (glstate->enable.texgen_t[texture])
tex_coord_loop(verts, norm, *coords+1, (indices)?ilen:count, glstate->texgen[texture].T, glstate->texgen[texture].T_O, glstate->texgen[texture].T_E, indices);
for (int i=0; i<((indices)?ilen:count); i++) {
GLushort k = indices?indices[i]:i;
(*coords)[k*4+2] = 0.0f;
@@ -404,11 +460,9 @@ void gen_tex_clean(GLint cleancode, int texture) {
if (cleancode == 0)
return;
if (cleancode == 1) {
GLuint old_tex=glstate.texture.active;
if (old_tex!=texture) glshim_glActiveTexture(GL_TEXTURE0 + texture);
GLuint old_tex=glstate->texture.active;
LOAD_GLES(glDisable);
gles_glDisable(GL_TEXTURE_GEN_STR);
if (old_tex!=texture) glshim_glActiveTexture(GL_TEXTURE0 + old_tex);
return;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -100,6 +100,8 @@ typedef struct {
GLboolean mipmap_need;
GLenum min_filter;
GLenum mag_filter;
GLenum wrap_s;
GLenum wrap_t;
GLboolean uploaded;
GLboolean alpha;
GLboolean compressed;
@@ -131,6 +133,6 @@ void glshim_glClientActiveTexture( GLenum texture );
void glshim_glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t );
GLboolean glshim_glIsTexture( GLuint texture );
void tex_setup_texcoord(GLuint texunit, GLuint len);
void tex_setup_texcoord(GLuint len);
#endif

View File

@@ -1902,4 +1902,535 @@ void glPackedCall(const packed_call_t *packed) {
}
}
}
/*
packed_call_t* glCopyPackedCall(const packed_call_t *packed) {
switch (packed->format) {
case FORMAT_void_GLenum: {
int sizeofpacked = sizeof(PACKED_void_GLenum);
PACKED_void_GLenum *newpacked = (PACKED_void_GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLclampf: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLclampf);
PACKED_void_GLenum_GLclampf *newpacked = (PACKED_void_GLenum_GLclampf*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLclampx: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLclampx);
PACKED_void_GLenum_GLclampx *newpacked = (PACKED_void_GLenum_GLclampx*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLuint: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLuint);
PACKED_void_GLenum_GLuint *newpacked = (PACKED_void_GLenum_GLuint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum);
PACKED_void_GLenum_GLenum *newpacked = (PACKED_void_GLenum_GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLsizeiptr_const_GLvoid___GENPT___GLenum: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLsizeiptr_const_GLvoid___GENPT___GLenum);
PACKED_void_GLenum_GLsizeiptr_const_GLvoid___GENPT___GLenum *newpacked = (PACKED_void_GLenum_GLsizeiptr_const_GLvoid___GENPT___GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLintptr_GLsizeiptr_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLintptr_GLsizeiptr_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLintptr_GLsizeiptr_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLintptr_GLsizeiptr_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLbitfield: {
int sizeofpacked = sizeof(PACKED_void_GLbitfield);
PACKED_void_GLbitfield *newpacked = (PACKED_void_GLbitfield*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampf_GLclampf_GLclampf_GLclampf: {
int sizeofpacked = sizeof(PACKED_void_GLclampf_GLclampf_GLclampf_GLclampf);
PACKED_void_GLclampf_GLclampf_GLclampf_GLclampf *newpacked = (PACKED_void_GLclampf_GLclampf_GLclampf_GLclampf*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampx_GLclampx_GLclampx_GLclampx: {
int sizeofpacked = sizeof(PACKED_void_GLclampx_GLclampx_GLclampx_GLclampx);
PACKED_void_GLclampx_GLclampx_GLclampx_GLclampx *newpacked = (PACKED_void_GLclampx_GLclampx_GLclampx_GLclampx*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampf: {
int sizeofpacked = sizeof(PACKED_void_GLclampf);
PACKED_void_GLclampf *newpacked = (PACKED_void_GLclampf*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampx: {
int sizeofpacked = sizeof(PACKED_void_GLclampx);
PACKED_void_GLclampx *newpacked = (PACKED_void_GLclampx*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLint: {
int sizeofpacked = sizeof(PACKED_void_GLint);
PACKED_void_GLint *newpacked = (PACKED_void_GLint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_const_GLfloat___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_const_GLfloat___GENPT__);
PACKED_void_GLenum_const_GLfloat___GENPT__ *newpacked = (PACKED_void_GLenum_const_GLfloat___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_const_GLfixed___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_const_GLfixed___GENPT__);
PACKED_void_GLenum_const_GLfixed___GENPT__ *newpacked = (PACKED_void_GLenum_const_GLfixed___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfloat_GLfloat_GLfloat_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat);
PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat *newpacked = (PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLubyte_GLubyte_GLubyte_GLubyte: {
int sizeofpacked = sizeof(PACKED_void_GLubyte_GLubyte_GLubyte_GLubyte);
PACKED_void_GLubyte_GLubyte_GLubyte_GLubyte *newpacked = (PACKED_void_GLubyte_GLubyte_GLubyte_GLubyte*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfixed_GLfixed_GLfixed_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed);
PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed *newpacked = (PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLboolean_GLboolean_GLboolean_GLboolean: {
int sizeofpacked = sizeof(PACKED_void_GLboolean_GLboolean_GLboolean_GLboolean);
PACKED_void_GLboolean_GLboolean_GLboolean_GLboolean *newpacked = (PACKED_void_GLboolean_GLboolean_GLboolean_GLboolean*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLint_GLenum_GLsizei_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLint_GLenum_GLsizei_const_GLvoid___GENPT__);
PACKED_void_GLint_GLenum_GLsizei_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLint_GLenum_GLsizei_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLenum_GLsizei_GLsizei_GLint_GLsizei_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLenum_GLsizei_GLsizei_GLint_GLsizei_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLint_GLenum_GLsizei_GLsizei_GLint_GLsizei_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLint_GLenum_GLsizei_GLsizei_GLint_GLsizei_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLsizei_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLsizei_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLsizei_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLsizei_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLenum_GLint_GLint_GLsizei_GLsizei_GLint: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLenum_GLint_GLint_GLsizei_GLsizei_GLint);
PACKED_void_GLenum_GLint_GLenum_GLint_GLint_GLsizei_GLsizei_GLint *newpacked = (PACKED_void_GLenum_GLint_GLenum_GLint_GLint_GLsizei_GLsizei_GLint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLint_GLint_GLint_GLint_GLsizei_GLsizei: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLint_GLint_GLint_GLint_GLsizei_GLsizei);
PACKED_void_GLenum_GLint_GLint_GLint_GLint_GLint_GLsizei_GLsizei *newpacked = (PACKED_void_GLenum_GLint_GLint_GLint_GLint_GLint_GLsizei_GLsizei*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLsizei_const_GLuint___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLsizei_const_GLuint___GENPT__);
PACKED_void_GLsizei_const_GLuint___GENPT__ *newpacked = (PACKED_void_GLsizei_const_GLuint___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLboolean: {
int sizeofpacked = sizeof(PACKED_void_GLboolean);
PACKED_void_GLboolean *newpacked = (PACKED_void_GLboolean*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampf_GLclampf: {
int sizeofpacked = sizeof(PACKED_void_GLclampf_GLclampf);
PACKED_void_GLclampf_GLclampf *newpacked = (PACKED_void_GLclampf_GLclampf*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampx_GLclampx: {
int sizeofpacked = sizeof(PACKED_void_GLclampx_GLclampx);
PACKED_void_GLclampx_GLclampx *newpacked = (PACKED_void_GLclampx_GLclampx*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLsizei: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLsizei);
PACKED_void_GLenum_GLint_GLsizei *newpacked = (PACKED_void_GLenum_GLint_GLsizei*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLsizei_GLenum_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLsizei_GLenum_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLsizei_GLenum_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLsizei_GLenum_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void: {
int sizeofpacked = sizeof(PACKED_void);
PACKED_void *newpacked = (PACKED_void*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfloat);
PACKED_void_GLenum_GLfloat *newpacked = (PACKED_void_GLenum_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfixed);
PACKED_void_GLenum_GLfixed *newpacked = (PACKED_void_GLenum_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat);
PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat *newpacked = (PACKED_void_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed);
PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed *newpacked = (PACKED_void_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLsizei_GLuint___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLsizei_GLuint___GENPT__);
PACKED_void_GLsizei_GLuint___GENPT__ *newpacked = (PACKED_void_GLsizei_GLuint___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLboolean___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLboolean___GENPT__);
PACKED_void_GLenum_GLboolean___GENPT__ *newpacked = (PACKED_void_GLenum_GLboolean___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLint___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLint___GENPT__);
PACKED_void_GLenum_GLenum_GLint___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_GLint___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfloat___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfloat___GENPT__);
PACKED_void_GLenum_GLfloat___GENPT__ *newpacked = (PACKED_void_GLenum_GLfloat___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfixed___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfixed___GENPT__);
PACKED_void_GLenum_GLfixed___GENPT__ *newpacked = (PACKED_void_GLenum_GLfixed___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_GLenum: {
int sizeofpacked = sizeof(PACKED_GLenum);
PACKED_GLenum *newpacked = (PACKED_GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint___GENPT__);
PACKED_void_GLenum_GLint___GENPT__ *newpacked = (PACKED_void_GLenum_GLint___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLfloat___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLfloat___GENPT__);
PACKED_void_GLenum_GLenum_GLfloat___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_GLfloat___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLfixed___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLfixed___GENPT__);
PACKED_void_GLenum_GLenum_GLfixed___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_GLfixed___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLvoid___GENPT____GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLvoid___GENPT____GENPT__);
PACKED_void_GLenum_GLvoid___GENPT____GENPT__ *newpacked = (PACKED_void_GLenum_GLvoid___GENPT____GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_const_GLubyte___GENPT___GLenum: {
int sizeofpacked = sizeof(PACKED_const_GLubyte___GENPT___GLenum);
PACKED_const_GLubyte___GENPT___GLenum *newpacked = (PACKED_const_GLubyte___GENPT___GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_GLboolean_GLuint: {
int sizeofpacked = sizeof(PACKED_GLboolean_GLuint);
PACKED_GLboolean_GLuint *newpacked = (PACKED_GLboolean_GLuint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_GLboolean_GLenum: {
int sizeofpacked = sizeof(PACKED_GLboolean_GLenum);
PACKED_GLboolean_GLenum *newpacked = (PACKED_GLboolean_GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLfloat);
PACKED_void_GLenum_GLenum_GLfloat *newpacked = (PACKED_void_GLenum_GLenum_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_const_GLfloat___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_const_GLfloat___GENPT__);
PACKED_void_GLenum_GLenum_const_GLfloat___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_const_GLfloat___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLfixed);
PACKED_void_GLenum_GLenum_GLfixed *newpacked = (PACKED_void_GLenum_GLenum_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_const_GLfixed___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_const_GLfixed___GENPT__);
PACKED_void_GLenum_GLenum_const_GLfixed___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_const_GLfixed___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLfloat);
PACKED_void_GLfloat *newpacked = (PACKED_void_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLfixed);
PACKED_void_GLfixed *newpacked = (PACKED_void_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_const_GLfloat___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_const_GLfloat___GENPT__);
PACKED_void_const_GLfloat___GENPT__ *newpacked = (PACKED_void_const_GLfloat___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_const_GLfixed___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_const_GLfixed___GENPT__);
PACKED_void_const_GLfixed___GENPT__ *newpacked = (PACKED_void_const_GLfixed___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfloat_GLfloat_GLfloat_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfloat_GLfloat_GLfloat_GLfloat);
PACKED_void_GLenum_GLfloat_GLfloat_GLfloat_GLfloat *newpacked = (PACKED_void_GLenum_GLfloat_GLfloat_GLfloat_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLfixed_GLfixed_GLfixed_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLfixed_GLfixed_GLfixed_GLfixed);
PACKED_void_GLenum_GLfixed_GLfixed_GLfixed_GLfixed *newpacked = (PACKED_void_GLenum_GLfixed_GLfixed_GLfixed_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfloat_GLfloat_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLfloat_GLfloat_GLfloat);
PACKED_void_GLfloat_GLfloat_GLfloat *newpacked = (PACKED_void_GLfloat_GLfloat_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfixed_GLfixed_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLfixed_GLfixed_GLfixed);
PACKED_void_GLfixed_GLfixed_GLfixed *newpacked = (PACKED_void_GLfixed_GLfixed_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLsizei_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLsizei_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLsizei_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLsizei_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint);
PACKED_void_GLenum_GLint *newpacked = (PACKED_void_GLenum_GLint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfloat_GLfloat: {
int sizeofpacked = sizeof(PACKED_void_GLfloat_GLfloat);
PACKED_void_GLfloat_GLfloat *newpacked = (PACKED_void_GLfloat_GLfloat*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLfixed_GLfixed: {
int sizeofpacked = sizeof(PACKED_void_GLfixed_GLfixed);
PACKED_void_GLfixed_GLfixed *newpacked = (PACKED_void_GLfixed_GLfixed*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_GLvoid___GENPT__);
PACKED_void_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_GLvoid___GENPT__ *newpacked = (PACKED_void_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampf_GLboolean: {
int sizeofpacked = sizeof(PACKED_void_GLclampf_GLboolean);
PACKED_void_GLclampf_GLboolean *newpacked = (PACKED_void_GLclampf_GLboolean*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLclampx_GLboolean: {
int sizeofpacked = sizeof(PACKED_void_GLclampx_GLboolean);
PACKED_void_GLclampx_GLboolean *newpacked = (PACKED_void_GLclampx_GLboolean*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLint_GLint_GLsizei_GLsizei: {
int sizeofpacked = sizeof(PACKED_void_GLint_GLint_GLsizei_GLsizei);
PACKED_void_GLint_GLint_GLsizei_GLsizei *newpacked = (PACKED_void_GLint_GLint_GLsizei_GLsizei*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLuint: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLuint);
PACKED_void_GLenum_GLint_GLuint *newpacked = (PACKED_void_GLenum_GLint_GLuint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLuint: {
int sizeofpacked = sizeof(PACKED_void_GLuint);
PACKED_void_GLuint *newpacked = (PACKED_void_GLuint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLenum: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLenum);
PACKED_void_GLenum_GLenum_GLenum *newpacked = (PACKED_void_GLenum_GLenum_GLenum*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_GLint: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_GLint);
PACKED_void_GLenum_GLenum_GLint *newpacked = (PACKED_void_GLenum_GLenum_GLint*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLenum_const_GLint___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLenum_const_GLint___GENPT__);
PACKED_void_GLenum_GLenum_const_GLint___GENPT__ *newpacked = (PACKED_void_GLenum_GLenum_const_GLint___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
case FORMAT_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__: {
int sizeofpacked = sizeof(PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__);
PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__ *newpacked = (PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__*)malloc(sizeofpacked);
memcpy(newpacked, packed, sizeofpacked);
return (packed_call_t*)newpacked;
break;
}
}
}
*/
#endif

View File

@@ -1387,6 +1387,7 @@ typedef struct {
extern void glPushCall(void *data);
void glPackedCall(const packed_call_t *packed);
void glIndexedCall(const indexed_call_t *packed, void *ret_v);
/*packed_call_t* glCopyPackedCall(const packed_call_t *packed);*/
#define glActiveTexture_INDEX 1
#define glActiveTexture_RETURN void

File diff suppressed because it is too large Load Diff

View File

@@ -138,6 +138,8 @@ struct __GLXContextRec {
EGLSurface eglSurface;
EGLConfig eglConfigs[1];
EGLContext eglContext;
void* glstate;
int contextType; // 0 = Window, 1 = PBuffer
};
typedef struct __GLXContextRec *GLXContext;
@@ -203,7 +205,7 @@ GLXContext glXCreateContext(Display *dpy,
GLXContext shareList,
Bool direct);
GLXContext glXCreateContextAttribsARB(Display *display, void *config,
GLXContext glXCreateContextAttribsARB(Display *display, GLXFBConfig config,
GLXContext share_context, Bool direct,
const int *attrib_list);

View File

@@ -45,6 +45,7 @@ void glXStub(void *x, ...) {
return;
}
extern int glshim_queries;
EXPORT void *glXGetProcAddressARB(const char *name) {
LOAD_EGL(eglGetProcAddress);
@@ -100,8 +101,8 @@ EXPORT void *glXGetProcAddressARB(const char *name) {
EX(glXCreateWindow);
EX(glXDestroyWindow);
STUB(glXCreatePbuffer); // to do, using Renderbuffers....
STUB(glXDestroyPbuffer);
EX(glXCreatePbuffer);
EX(glXDestroyPbuffer);
STUB(glXCreatePixmap);
STUB(glXDestroyPixmap);
STUB(glXGetCurrentReadDrawable);
@@ -615,6 +616,17 @@ EXPORT void *glXGetProcAddressARB(const char *name) {
_EX(glMatrixMultTransposef);
_EX(glMatrixMultTransposed);
if(glshim_queries) {
_EX(glGenQueries);
_EX(glIsQuery);
_EX(glDeleteQueries);
_EX(glBeginQuery);
_EX(glEndQuery);
_EX(glGetQueryiv);
_EX(glGetQueryObjectiv);
_EX(glGetQueryObjectuiv);
}
if (!export_silentstub) printf("glXGetProcAddress: %s not found.\n", name);
return NULL;
}

View File

@@ -13793,6 +13793,7 @@ typedef struct {
extern void glPushCall(void *data);
void glPackedCall(const packed_call_t *packed);
void glIndexedCall(const indexed_call_t *packed, void *ret_v);
packed_call_t* glCopyPackedCall(const packed_call_t *packed);
#define glAccum_INDEX 1
#define glAccum_RETURN void
@@ -43314,6 +43315,7 @@ typedef struct {
extern void glPushCall(void *data);
void glPackedCall(const packed_call_t *packed);
void glIndexedCall(const indexed_call_t *packed, void *ret_v);
packed_call_t* glCopyPackedCall(const packed_call_t *packed);
#define glAccum_INDEX 1
#define glAccum_RETURN void