Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android

This commit is contained in:
pelya
2016-03-27 18:54:23 +03:00
7 changed files with 139 additions and 62 deletions
+35 -19
View File
@@ -30,7 +30,8 @@ GLuint readhack_seq = 0;
GLuint gl_batch = 0;
GLuint gl_mergelist = 1;
int blendhack = 0;
char gl_version[50];
int export_blendcolor = 0;
char glshim_version[50];
int initialized = 0;
int noerror = 0;
@@ -121,7 +122,7 @@ const GLubyte *glshim_glGetString(GLenum name) {
printf("**warning** glGetString(%i) called with bad init\n", name);*/
switch (name) {
case GL_VERSION:
return (GLubyte *)gl_version;
return (GLubyte *)glshim_version;
case GL_EXTENSIONS:
return (const GLubyte *)(char *){
"GL_EXT_abgr "
@@ -654,8 +655,6 @@ static renderlist_t *arrays_to_renderlist(renderlist_t *list, GLenum mode,
list->tex[i] = copy_gl_pointer_tex(&glstate.vao->pointers.tex_coord[i], 4, skip, count, glstate.vao->pointers.tex_coord[i].buffer);
}
}
end_renderlist(list);
return list;
}
@@ -672,7 +671,7 @@ static inline bool should_intercept_render(GLenum mode) {
}
void glshim_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
//printf("glDrawElements(0x%04X, %d, 0x%04X, %p), map=%p\n", mode, count, type, indices, (glstate.buffers.elements)?glstate.buffers.elements->data:NULL);
//printf("glDrawElements(0x%04X, %d, 0x%04X, %p), map=%p\n", mode, count, type, indices, (glstate.vao->elements)?glstate.vao->elements->data:NULL);
// TODO: split for count > 65535?
// special check for QUADS and TRIANGLES that need multiple of 4 or 3 vertex...
if (mode == GL_QUADS) while(count%4) count--;
@@ -914,6 +913,7 @@ void glshim_glDrawArrays(GLenum mode, GLint first, GLsizei count) {
if (glstate.list.active && (glstate.list.compiling || glstate.gl_batch)) {
NewStage(glstate.list.active, STAGE_DRAW);
glstate.list.active = arrays_to_renderlist(glstate.list.active, mode, first, count+first);
end_renderlist(list);
return;
}
@@ -1209,7 +1209,7 @@ void glBegin(GLenum mode) __attribute__((alias("glshim_glBegin")));
void glshim_glEnd() {
if (!glstate.list.active) return;
// check if TEXTUREx is activate and no TexCoord (or texgen), in that cas, create a dummy one base on glstate...
// check if TEXTUREx is activate and no TexCoord (or texgen), in that case, create a dummy one base on glstate...
for (int a=0; a<MAX_TEX; a++)
if (glstate.enable.texture_2d[a] && ((glstate.list.active->tex[a]==0) && (!glstate.enable.texgen_s[a])))
rlMultiTexCoord4f(glstate.list.active, GL_TEXTURE0+a, glstate.texcoord[a][0], glstate.texcoord[a][1], glstate.texcoord[a][2], glstate.texcoord[a][3]);
@@ -1228,7 +1228,6 @@ void glshim_glEnd() {
void glEnd() __attribute__((alias("glshim_glEnd")));
void glshim_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) {
glstate.normal[0] = nx; glstate.normal[1] = ny; glstate.normal[2] = nz;
if (glstate.list.active) {
if (glstate.list.active->stage != STAGE_DRAW) {
if (glstate.list.active->stage != STAGE_DRAW) {
@@ -1246,6 +1245,7 @@ void glshim_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) {
errorGL();
}
#endif
glstate.normal[0] = nx; glstate.normal[1] = ny; glstate.normal[2] = nz;
}
void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) __attribute__((alias("glshim_glNormal3f")));
@@ -1258,9 +1258,6 @@ void glshim_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) __attribute__((alias("glshim_glVertex4f")));
void glshim_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
// change the state first thing
glstate.color[0] = red; glstate.color[1] = green;
glstate.color[2] = blue; glstate.color[3] = alpha;
if (glstate.list.active) {
if (glstate.list.active->stage != STAGE_DRAW) {
PUSH_IF_COMPILING(glColor4f);
@@ -1275,19 +1272,22 @@ void glshim_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
errorGL();
}
#endif
// change the state last thing
glstate.color[0] = red; glstate.color[1] = green;
glstate.color[2] = blue; glstate.color[3] = alpha;
}
void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) __attribute__((alias("glshim_glColor4f")));
void glshim_glSecondaryColor3f(GLfloat r, GLfloat g, GLfloat b) {
// change the state first thing
glstate.secondary[0] = r; glstate.secondary[1] = g;
glstate.secondary[2] = b;
if (glstate.list.active) {
rlSecondary3f(glstate.list.active, r, g, b);
noerrorShim();
} else {
noerrorShim();
}
// change the state last thing
glstate.secondary[0] = r; glstate.secondary[1] = g;
glstate.secondary[2] = b;
}
void glSecondaryColor3f(GLfloat r, GLfloat g, GLfloat b) __attribute__((alias("glshim_glSecondaryColor3f")));
@@ -1329,20 +1329,18 @@ void glMaterialf(GLenum face, GLenum pname, const GLfloat param) __attribute__((
#endif
void glshim_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
glstate.texcoord[0][0] = s; glstate.texcoord[0][1] = t;
glstate.texcoord[0][2] = r; glstate.texcoord[0][3] = q;
if (glstate.list.active) {
rlTexCoord4f(glstate.list.active, s, t, r, q);
noerrorShim();
} else {
noerrorShim();
}
glstate.texcoord[0][0] = s; glstate.texcoord[0][1] = t;
glstate.texcoord[0][2] = r; glstate.texcoord[0][3] = q;
}
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) __attribute__((alias("glshim_glTexCoord4f")));
void glshim_glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
glstate.texcoord[target-GL_TEXTURE0][0] = s; glstate.texcoord[target-GL_TEXTURE0][1] = t;
glstate.texcoord[target-GL_TEXTURE0][2] = r; glstate.texcoord[target-GL_TEXTURE0][3] = q;
// TODO, error if target is unsuported texture....
if (glstate.list.active) {
rlMultiTexCoord4f(glstate.list.active, target, s, t, r, q);
@@ -1350,6 +1348,8 @@ void glshim_glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GL
} else {
noerrorShim();
}
glstate.texcoord[target-GL_TEXTURE0][0] = s; glstate.texcoord[target-GL_TEXTURE0][1] = t;
glstate.texcoord[target-GL_TEXTURE0][2] = r; glstate.texcoord[target-GL_TEXTURE0][3] = q;
}
void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) __attribute__((alias("glshim_glMultiTexCoord4f")));
void glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) __attribute__((alias("glshim_glMultiTexCoord4f")));
@@ -1744,10 +1744,17 @@ void glshim_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf a
LOAD_GLES_OES(glBlendColor);
if (gles_glBlendColor)
gles_glBlendColor(red, green, blue, alpha);
else
printf("stub glBlendColor(%f, %f, %f, %f)\n", red, green, blue, alpha);
else {
static int test = 1;
if (test) {
printf("stub glBlendColor(%f, %f, %f, %f)\n", red, green, blue, alpha);
test = 0;
}
}
}
void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) __attribute__((alias("glshim_glBlendColor")));
void glBlendColorEXT(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) __attribute__((alias("glshim_glBlendColor")));
void glBlendColorARB(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) __attribute__((alias("glshim_glBlendColor")));
void glshim_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
{
@@ -1848,6 +1855,15 @@ void glshim_glBlendFunc(GLenum sfactor, GLenum dfactor) {
}
void glBlendFunc(GLenum sfactor, GLenum dfactor) __attribute__((alias("glshim_glBlendFunc")));
void glshim_glStencilMaskSeparate(GLenum face, GLuint mask) {
// fake function..., call it only for front or front_and_back, just ignore back (crappy, I know)
if ((face==GL_FRONT) || (face==GL_FRONT_AND_BACK))
glshim_glStencilMask(mask);
}
void glStencilMaskSeparate(GLenum face, GLuint mask) __attribute__((alias("glshim_glStencilMaskSeparate")));
void init_statebatch() {
memset(&glstate.statebatch, 0, sizeof(statebatch_t));
}
+2
View File
@@ -384,6 +384,8 @@ void glshim_glLoadMatrixf(const GLfloat * m);
void glshim_glMultMatrixf(const GLfloat * m);
void glshim_glFogfv(GLenum pname, const GLfloat* params);
void glshim_glStencilMaskSeparate(GLenum face, GLuint mask);
void flush();
void init_batch();
+6 -6
View File
@@ -604,7 +604,7 @@ void adjust_renderlist(renderlist_t *list) {
}
void end_renderlist(renderlist_t *list) {
if (! list->open)
if (!list || ! list->open)
return;
adjust_renderlist(list);
@@ -1112,7 +1112,7 @@ void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) {
list->normal = alloc_sublist(3, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
if (list->len) for (i = 0; i < list->len; i++) {
GLfloat *normal = (list->normal + (i * 3));
memcpy(normal, list->lastNormal, sizeof(GLfloat) * 3);
}
@@ -1127,7 +1127,7 @@ void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
list->color = alloc_sublist(4, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
if (list->len) for (i = 0; i < list->len; i++) {
GLfloat *color = (list->color + (i * 4));
memcpy(color, glstate.color, sizeof(GLfloat) * 4);
}/* else {
@@ -1145,7 +1145,7 @@ void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b) {
list->secondary = alloc_sublist(4, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
if (list->len) for (i = 0; i < list->len; i++) {
GLfloat *secondary = (list->secondary + (i * 4));
memcpy(secondary, glstate.secondary, sizeof(GLfloat) * 4);
}
@@ -1250,7 +1250,7 @@ void rlTexCoord4f(renderlist_t *list, GLfloat s, GLfloat t, GLfloat r, GLfloat q
list->tex[0] = alloc_sublist(4, list->cap);
// catch up
GLfloat *tex = list->tex[0];
if (list->len) for (int i = 0; i < list->len-1; i++) {
if (list->len) for (int i = 0; i < list->len; i++) {
memcpy(tex, glstate.texcoord[0], sizeof(GLfloat) * 4);
tex += 4;
}
@@ -1267,7 +1267,7 @@ void rlMultiTexCoord4f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t,
list->tex[tmu] = alloc_sublist(4, list->cap);
// catch up
GLfloat *tex = list->tex[tmu];
if (list->len) for (int i = 0; i < list->len-1; i++) {
if (list->len) for (int i = 0; i < list->len; i++) {
memcpy(tex, glstate.texcoord[tmu], sizeof(GLfloat) * 4);
tex += 4;
}
+19 -7
View File
@@ -713,12 +713,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
}
return true;
}
if ((src_format == GL_BGRA) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_BGRA)||(src_format == GL_RGBA)) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
tmp = *(const GLuint*)src_pos;
*(GLushort*)dst_pos = (tmp&0x0000ff00) | (tmp&0x000000ff);
*(GLushort*)dst_pos = (((((char*)src_pos)[2] + ((char*)src_pos)[1] + ((char*)src_pos)[0])/3)&0xff)<<8 | ((char*)src_pos)[3];
// *(GLushort*)dst_pos = (tmp&0x0000ff00) | (tmp&0x000000ff);
src_pos += src_stride;
dst_pos += dst_stride;
}
@@ -727,8 +728,7 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
}
return true;
}
if ((src_format == GL_BGR) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
if (((src_format == GL_BGR)||(src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
((char*)dst_pos)[0] = ((char*)src_pos)[2];
@@ -742,8 +742,21 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
}
return true;
}
if ((src_format == GL_RGB) && (dst_format == GL_RGB) && (dst_type = GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
if ((src_format == GL_RGBA) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
((char*)dst_pos)[0] = ((char*)src_pos)[0];
((char*)dst_pos)[1] = ((char*)src_pos)[1];
((char*)dst_pos)[2] = ((char*)src_pos)[2];
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
}
return true;
}
if (((src_format == GL_RGB)||(src_format == GL_RGBA)) && (dst_format == GL_RGB) && (dst_type = GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[2]&0xf8)>>(3)) | ((GLushort)(((char*)src_pos)[1]&0xfc)<<(5-2)) | ((GLushort)(((char*)src_pos)[0]&0xf8)<<(11-3));
@@ -756,7 +769,6 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
return true;
}
if (((src_format == GL_BGR) || (src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type = GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[0]&0xf8)>>(3)) | ((GLushort)(((char*)src_pos)[1]&0xfc)<<(5-2)) | ((GLushort)(((char*)src_pos)[2]&0xf8)<<(11-3));
+63 -25
View File
@@ -104,6 +104,21 @@ void tex_setup_texcoord(GLuint texunit, GLuint len) {
int nolumalpha = 0;
static int is_fake_compressed_rgb(GLenum internalformat)
{
if(internalformat==GL_COMPRESSED_RGB) return 1;
if(internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT) return 1;
return 0;
}
static int is_fake_compressed_rgba(GLenum internalformat)
{
if(internalformat==GL_COMPRESSED_RGBA) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) return 1;
return 0;
}
static void *swizzle_texture(GLsizei width, GLsizei height,
GLenum *format, GLenum *type,
GLenum intermediaryformat, GLenum internalformat,
@@ -190,10 +205,10 @@ static void *swizzle_texture(GLsizei width, GLsizei height,
break;
}
// compressed format are not handled here, so mask them....
if (intermediaryformat==GL_COMPRESSED_RGB) intermediaryformat=GL_RGB;
if (intermediaryformat==GL_COMPRESSED_RGBA) intermediaryformat=GL_RGBA;
if (internalformat==GL_COMPRESSED_RGB) internalformat=GL_RGB;
if (internalformat==GL_COMPRESSED_RGBA) internalformat=GL_RGBA;
if (is_fake_compressed_rgb(intermediaryformat)) intermediaryformat=GL_RGB;
if (is_fake_compressed_rgba(intermediaryformat)) intermediaryformat=GL_RGBA;
if (is_fake_compressed_rgb(internalformat)) internalformat=GL_RGB;
if (is_fake_compressed_rgba(internalformat)) internalformat=GL_RGBA;
if(*format != intermediaryformat || intermediaryformat!=internalformat) {
dest_format = intermediaryformat;
@@ -332,10 +347,11 @@ GLenum swizzle_internalformat(GLenum *internalformat) {
ret = GL_COMPRESSED_RGB;
sret = GL_RGB;
break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // not good...
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // not good, but there is no DXT3 compressor
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
ret = GL_COMPRESSED_RGBA;
sret = GL_RGB;
sret = GL_RGBA;
break;
default:
ret = GL_RGBA;
@@ -359,6 +375,7 @@ static int default_tex_mipmap = 0;
static int proxy_width = 0;
static int proxy_height = 0;
static GLint proxy_intformat = 0;
void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border,
@@ -367,8 +384,9 @@ void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
//printf("glTexImage2D on target=%s with unpack_row_length(%i), size(%i,%i) and skip(%i,%i), format(internal)=%s(%s), type=%s, data=%08x, level=%i (mipmap_need=%i, mipmap_auto=%i) => texture=%u (streamed=%i), glstate.list.compiling=%d\n", PrintEnum(target), glstate.texture.unpack_row_length, width, height, glstate.texture.unpack_skip_pixels, glstate.texture.unpack_skip_rows, PrintEnum(format), PrintEnum(internalformat), PrintEnum(type), data, level, (glstate.texture.bound[glstate.texture.active])?glstate.texture.bound[glstate.texture.active]->mipmap_need:0, (glstate.texture.bound[glstate.texture.active])?glstate.texture.bound[glstate.texture.active]->mipmap_auto:0, (glstate.texture.bound[glstate.texture.active])?glstate.texture.bound[glstate.texture.active]->texture:0, (glstate.texture.bound[glstate.texture.active])?glstate.texture.bound[glstate.texture.active]->streamed:0, glstate.list.compiling);
// proxy case
if (target == GL_PROXY_TEXTURE_2D) {
proxy_width = ((width<<level)>(texshrink==8)?8192:2048)?0:width;
proxy_height = ((height<<level)>(texshrink==8)?8192:2048)?0:height;
proxy_width = ((width<<level)>(texshrink>=8)?8192:2048)?0:width;
proxy_height = ((height<<level)>(texshrink>=8)?8192:2048)?0:height;
proxy_intformat = swizzle_internalformat(&internalformat);
return;
}
//PUSH_IF_COMPILING(glTexImage2D);
@@ -399,7 +417,7 @@ void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
bound->mipmap_need = 1;
}
GLenum new_format = swizzle_internalformat(&internalformat);
if (bound) {
if (bound && (level==0)) {
bound->orig_internal = internalformat;
bound->internalformat = new_format;
}
@@ -821,7 +839,7 @@ void glshim_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yof
pixels = (GLvoid *)dst;
const GLubyte *src = (GLubyte *)datab;
src += glstate.texture.unpack_skip_pixels * pixelSize + glstate.texture.unpack_skip_rows * imgWidth;
for (int y = 0; y < height; y += 1) {
for (int y = 0; y < height; y ++) {
memcpy(dst, src, width * pixelSize);
src += imgWidth;
dst += width * pixelSize;
@@ -1369,16 +1387,20 @@ void glshim_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, G
}
break;
case GL_TEXTURE_INTERNAL_FORMAT:
if (bound && bound->compressed)
(*params) = bound->format;
else {
if(bound && ((bound->orig_internal==GL_COMPRESSED_RGB) || (bound->orig_internal==GL_COMPRESSED_RGBA))) {
if(bound->orig_internal==GL_COMPRESSED_RGB)
*(params) = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
else
*(params) = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} else
(*params) = GL_RGBA;
if (target==GL_PROXY_TEXTURE_2D)
(*params) = proxy_intformat;
else {
if (bound && bound->compressed)
(*params) = bound->format;
else {
if(bound && ((bound->orig_internal==GL_COMPRESSED_RGB) || (bound->orig_internal==GL_COMPRESSED_RGBA))) {
if(bound->orig_internal==GL_COMPRESSED_RGB)
*(params) = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
else
*(params) = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} else
(*params) = GL_RGBA;
}
}
break;
case GL_TEXTURE_DEPTH:
@@ -1757,7 +1779,7 @@ void glshim_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalfo
errorShim(GL_INVALID_OPERATION);
return; // no texture bounded...
}
//printf("glCompressedTexImage2D on target=%s with size(%i,%i), internalformat=s, imagesize=%i, upackbuffer=%p\n", PrintEnum(target), width, height, PrintEnum(internalformat), imageSize, glstate.buffers.unpack?glstate.buffers.unpack->data:0);
//printf("glCompressedTexImage2D on target=%s with size(%i,%i), internalformat=%s, imagesize=%i, upackbuffer=%p\n", PrintEnum(target), width, height, PrintEnum(internalformat), imageSize, glstate.vao->unpack?glstate.vao->unpack->data:0);
// hack...
if (internalformat==GL_RGBA8)
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
@@ -1780,6 +1802,9 @@ void glshim_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalfo
GLvoid *datab = (GLvoid*)data;
if (unpack)
datab += (uintptr_t)unpack->data;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
if (isDXTc(internalformat)) {
GLvoid *pixels, *half;
@@ -1803,11 +1828,15 @@ void glshim_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalfo
// automaticaly reduce the pixel size
half=pixels;
glstate.texture.bound[glstate.texture.active]->alpha = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?false:true;
glstate.texture.bound[glstate.texture.active]->format = GL_RGBA; //internalformat;
glstate.texture.bound[glstate.texture.active]->type = GL_UNSIGNED_SHORT_4_4_4_4;
format = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_RGB:GL_RGBA;
glstate.texture.bound[glstate.texture.active]->format = format; //internalformat;
type = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_6_5:GL_UNSIGNED_SHORT_4_4_4_4;
glstate.texture.bound[glstate.texture.active]->type = type;
glstate.texture.bound[glstate.texture.active]->compressed = true;
if (pixel_thirdscale(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE))
fact = 1;
if (pixel_convert(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0))
fact = 0;
// if (pixel_thirdscale(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE))
// fact = 1;
else
glstate.texture.bound[glstate.texture.active]->type = GL_UNSIGNED_BYTE;
} else {
@@ -1818,7 +1847,7 @@ void glshim_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalfo
glshim_glGetIntegerv(GL_UNPACK_ALIGNMENT, &oldalign);
if (oldalign!=1)
glshim_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glshim_glTexImage2D(target, level, GL_RGBA, width>>fact, height>>fact, border, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, half);
glshim_glTexImage2D(target, level, GL_RGBA, width>>fact, height>>fact, border, format, type, half);
if (oldalign!=1)
glshim_glPixelStorei(GL_UNPACK_ALIGNMENT, oldalign);
if (half!=pixels)
@@ -2028,3 +2057,12 @@ void glCopyTexSubImage3DEXT(GLenum target, GLint level, GLint xoffset, GLint yof
//ARB mapper
void glActiveTextureARB(GLenum texture) __attribute__((alias("glshim_glActiveTexture")));
void glClientActiveTextureARB(GLenum texture) __attribute__((alias("glshim_glClientActiveTexture")));
void glTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data) __attribute__((alias("glshim_glTexSubImage3D")));
void glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexImage2D")));
void glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexImage1D")));
void glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexImage3D")));
void glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexSubImage2D")));
void glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexSubImage1D")));
void glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data) __attribute__((alias("glshim_glCompressedTexSubImage3D")));
void glGetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img) __attribute__((alias("glshim_glGetCompressedTexImage")));
void glCopyTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) __attribute__((alias("glshim_glCopyTexSubImage3D")));
+5 -3
View File
@@ -167,8 +167,9 @@ extern int texstream;
extern int copytex;
extern int nolumalpha;
extern int blendhack;
extern int export_blendcolor;
extern int noerror;
extern char gl_version[50];
extern char glshim_version[50];
bool g_recyclefbo = false;
static int g_width=0, g_height=0;
@@ -430,13 +431,14 @@ static void scan_env() {
}
env(LIBGL_BLENDHACK, blendhack, "Change Blend GL_SRC_ALPHA, GL_ONE to GL_ONE, GL_ONE");
env(LIBGL_BLENDCOLOR, export_blendcolor, "Export a (faked) glBlendColor");
env(LIBGL_NOERROR, noerror, "glGetError() always return GL_NOERROR");
char *env_version = getenv("LIBGL_VERSION");
if (env_version) {
printf("LIBGL: Overide version string with \"%s\" (should be in the form of \"1.x\")\n", gl_version);
printf("LIBGL: Overide version string with \"%s\" (should be in the form of \"1.x\")\n", env_version);
}
snprintf(gl_version, 49, "%s glshim wrapper", (env_version)?env_version:"1.5");
snprintf(glshim_version, 49, "%s glshim wrapper", (env_version)?env_version:"1.5");
char cwd[1024];
if (getcwd(cwd, sizeof(cwd))!= NULL)
+9 -2
View File
@@ -6,6 +6,8 @@
#include "../gl/directstate.h"
//#define DEBUG_ADDRESS
extern int export_blendcolor;
#ifdef DEBUG_ADDRESS
#define MAP(func_name, func) \
if(cnt==1) {if ((uint32_t)((void*)func) <0x4000000) printf("glxGetProcAddress %s = %p\n", func_name, (void*)func);} if (strcmp(name, func_name) == 0) return (void *)func;
@@ -309,8 +311,11 @@ void *glXGetProcAddressARB(const char *name) {
_EX(glArrayElement);
_EX(glBegin);
_EX(glBitmap);
/*EXT(glBlendColor);
ARB(glBlendColor);*/
if(export_blendcolor) {
_EX(glBlendColor);
_EXT(glBlendColor);
_ARB(glBlendColor);
}
_EXT(glBlendEquation);
_ARB(glBlendEquation);
_EXT(glBlendFunc);
@@ -327,6 +332,8 @@ void *glXGetProcAddressARB(const char *name) {
_EXT(glBlendFuncSeparatei);
_ARB(glBlendFuncSeparatei);
#endif
_EX(glStencilMaskSeparate);
_EXT(glStencilMaskSeparate);
_EX(glCallList);
_EX(glCallLists);
_EX(glClearDepth);