glshim updated, added latest changes by ptitSeb
This commit is contained in:
@@ -12,11 +12,6 @@ endif()
|
||||
|
||||
add_library(GL SHARED ${GL_SOURCES})
|
||||
|
||||
if(BCMHOST)
|
||||
set(PI_LIBS bcm_host vcos pthread)
|
||||
target_link_libraries(GL ${PI_LIBS})
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
target_link_libraries(GL X11 m dl)
|
||||
endif()
|
||||
|
||||
@@ -64,6 +64,76 @@ GLvoid *copy_gl_array(const GLvoid *src,
|
||||
return dst;
|
||||
}
|
||||
|
||||
GLvoid *copy_gl_array_texcoord(const GLvoid *src,
|
||||
GLenum from, GLsizei width, GLsizei stride,
|
||||
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count, GLvoid* filler) {
|
||||
if (! src || !count)
|
||||
return NULL;
|
||||
|
||||
if (! stride)
|
||||
stride = width * gl_sizeof(from);
|
||||
|
||||
const char *unknown_str = "libGL: copy_gl_array -> unknown type: %x\n";
|
||||
GLvoid *dst = malloc((count-skip) * to_width * gl_sizeof(to));
|
||||
GLsizei from_size = gl_sizeof(from) * width;
|
||||
GLsizei to_size = gl_sizeof(to) * to_width;
|
||||
GLsizei to_elem = gl_sizeof(to);
|
||||
if (to_width < width) {
|
||||
printf("Warning: copy_gl_array: %i < %i\n", to_width, width);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if stride is weird, we need to be able to arbitrarily shift src
|
||||
// so we leave it in a uintptr_t and cast after incrementing
|
||||
uintptr_t in = (uintptr_t)src;
|
||||
in += stride*skip;
|
||||
if (from == to && to_width >= width) {
|
||||
GL_TYPE_SWITCH(out, dst, to,
|
||||
for (int i = skip; i < count; i++) {
|
||||
memcpy(out, (GLvoid *)in, from_size);
|
||||
for (int j = width; j < to_width; j++) {
|
||||
if(j==to_width-1)
|
||||
memcpy(out+j, filler, to_elem);
|
||||
else
|
||||
out[j] = 0;
|
||||
}
|
||||
out += to_width;
|
||||
in += stride;
|
||||
},
|
||||
default:
|
||||
printf(unknown_str, from);
|
||||
return NULL;
|
||||
)
|
||||
} else {
|
||||
GL_TYPE_SWITCH(out, dst, to,
|
||||
for (int i = skip; i < count; i++) {
|
||||
GL_TYPE_SWITCH(input, in, from,
|
||||
for (int j = 0; j < width; j++) {
|
||||
out[j] = input[j];
|
||||
}
|
||||
for (int j = width; j < to_width; j++) {
|
||||
if(j==to_width-1)
|
||||
memcpy(out+j, filler, to_elem);
|
||||
else
|
||||
out[j] = 0;
|
||||
}
|
||||
out += to_width;
|
||||
in += stride;
|
||||
,
|
||||
default:
|
||||
printf(unknown_str, from);
|
||||
return NULL;
|
||||
)
|
||||
},
|
||||
default:
|
||||
printf(unknown_str, to);
|
||||
return NULL;
|
||||
)
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
GLvoid *copy_gl_array_quickconvert(const GLvoid *src,
|
||||
GLenum from, GLsizei stride,
|
||||
GLsizei skip, GLsizei count) {
|
||||
@@ -196,6 +266,13 @@ GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, G
|
||||
GL_FLOAT, width, skip, count);
|
||||
}
|
||||
|
||||
GLvoid *copy_gl_pointer_tex(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
|
||||
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,
|
||||
GL_FLOAT, width, skip, count, &filler);
|
||||
}
|
||||
|
||||
GLfloat *gl_pointer_index(pointer_state_t *p, GLint index) {
|
||||
static GLfloat buf[4];
|
||||
GLsizei size = gl_sizeof(p->type);
|
||||
|
||||
@@ -17,6 +17,7 @@ GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsiz
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -20,6 +20,7 @@ const char* PrintEnum(GLenum what) {
|
||||
p(GL_DRAW_FRAMEBUFFER);
|
||||
// format
|
||||
p(GL_RED);
|
||||
p(GL_R);
|
||||
p(GL_R3_G3_B2);
|
||||
p(GL_RGB);
|
||||
p(GL_BGR);
|
||||
@@ -81,6 +82,26 @@ const char* PrintEnum(GLenum what) {
|
||||
p(GL_ELEMENT_ARRAY_BUFFER);
|
||||
p(GL_PIXEL_PACK_BUFFER);
|
||||
p(GL_PIXEL_UNPACK_BUFFER);
|
||||
// Texture
|
||||
p(GL_TEXTURE0);
|
||||
p(GL_TEXTURE1);
|
||||
p(GL_TEXTURE2);
|
||||
p(GL_TEXTURE3);
|
||||
p(GL_TEXTURE4);
|
||||
p(GL_TEXTURE5);
|
||||
p(GL_TEXTURE6);
|
||||
p(GL_TEXTURE7);
|
||||
// mode
|
||||
p(GL_POINT);
|
||||
p(GL_LINES);
|
||||
p(GL_LINE_LOOP);
|
||||
p(GL_LINE_STRIP);
|
||||
p(GL_TRIANGLES);
|
||||
p(GL_TRIANGLE_STRIP);
|
||||
p(GL_TRIANGLE_FAN);
|
||||
p(GL_QUADS);
|
||||
p(GL_QUAD_STRIP);
|
||||
p(GL_POLYGON);
|
||||
default:
|
||||
sprintf(fallback, "0x%04X", what);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gl.h"
|
||||
#include "debug.h"
|
||||
/*
|
||||
glstate_t state = {.color = {1.0f, 1.0f, 1.0f, 1.0f},
|
||||
.secondary = {0.0f, 0.0f, 0.0f, 0.0f},
|
||||
@@ -121,6 +122,8 @@ const GLubyte *glGetString(GLenum name) {
|
||||
return (GLubyte *)gl_version;
|
||||
case GL_EXTENSIONS:
|
||||
return (const GLubyte *)(char *){
|
||||
"GL_EXT_abgr "
|
||||
"GL_EXT_packed_pixels "
|
||||
"GL_ARB_vertex_buffer_object "
|
||||
"GL_ARB_vertex_array_object "
|
||||
"GL_ARB_vertex_buffer "
|
||||
@@ -151,6 +154,8 @@ const GLubyte *glGetString(GLenum name) {
|
||||
"GL_ARB_point_parameters "
|
||||
"GL_EXT_point_parameters "
|
||||
"GL_EXT_stencil_wrap "
|
||||
"SGIS_texture_edge_clamp "
|
||||
"GL_EXT_texture_edge_clamp "
|
||||
#ifndef ODROID
|
||||
"GL_EXT_blend_subtract "
|
||||
"GL_EXT_blend_func_separate "
|
||||
@@ -634,7 +639,7 @@ static renderlist_t *arrays_to_renderlist(renderlist_t *list, GLenum mode,
|
||||
}
|
||||
for (int i=0; i<MAX_TEX; i++) {
|
||||
if (state.vao->tex_coord_array[i]) {
|
||||
list->tex[i] = copy_gl_pointer_raw(&state.vao->pointers.tex_coord[i], 2, skip, count, state.vao->pointers.tex_coord[i].buffer);
|
||||
list->tex[i] = copy_gl_pointer_tex(&state.vao->pointers.tex_coord[i], 4, skip, count, state.vao->pointers.tex_coord[i].buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,7 +1186,7 @@ void glEnd() {
|
||||
// check if TEXTUREx is activate and no TexCoord (or texgen), in that cas, create a dummy one base on state...
|
||||
for (int a=0; a<MAX_TEX; a++)
|
||||
if (state.enable.texture_2d[a] && ((state.list.active->tex[a]==0) && (!state.enable.texgen_s[a])))
|
||||
rlMultiTexCoord2f(state.list.active, GL_TEXTURE0+a, state.texcoord[a][0], state.texcoord[a][1]);
|
||||
rlMultiTexCoord4f(state.list.active, GL_TEXTURE0+a, state.texcoord[a][0], state.texcoord[a][1], state.texcoord[a][2], state.texcoord[a][3]);
|
||||
// render if we're not in a display list
|
||||
if (!(state.list.compiling || state.gl_batch)) {
|
||||
renderlist_t *mylist = state.list.active;
|
||||
@@ -1290,21 +1295,23 @@ void glMaterialf(GLenum face, GLenum pname, const GLfloat param) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void glTexCoord2f(GLfloat s, GLfloat t) {
|
||||
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
state.texcoord[0][0] = s; state.texcoord[0][1] = t;
|
||||
state.texcoord[0][2] = r; state.texcoord[0][3] = q;
|
||||
if (state.list.active) {
|
||||
rlTexCoord2f(state.list.active, s, t);
|
||||
rlTexCoord4f(state.list.active, s, t, r, q);
|
||||
noerrorShim();
|
||||
} else {
|
||||
noerrorShim();
|
||||
}
|
||||
}
|
||||
|
||||
void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t) {
|
||||
void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
state.texcoord[target-GL_TEXTURE0][0] = s; state.texcoord[target-GL_TEXTURE0][1] = t;
|
||||
state.texcoord[target-GL_TEXTURE0][2] = r; state.texcoord[target-GL_TEXTURE0][3] = q;
|
||||
// TODO, error if target is unsuported texture....
|
||||
if (state.list.active) {
|
||||
rlMultiTexCoord2f(state.list.active, target, s, t);
|
||||
rlMultiTexCoord4f(state.list.active, target, s, t, r, q);
|
||||
noerrorShim();
|
||||
} else {
|
||||
noerrorShim();
|
||||
@@ -1349,14 +1356,20 @@ void glArrayElement(GLint i) {
|
||||
p = &state.vao->pointers.tex_coord[0];
|
||||
if (state.vao->tex_coord_array[0]) {
|
||||
v = gl_pointer_index(p, i);
|
||||
glTexCoord2fv(v);
|
||||
if (p->size<4)
|
||||
glTexCoord2fv(v);
|
||||
else
|
||||
glTexCoord4fv(v);
|
||||
}
|
||||
int a;
|
||||
for (a=1; a<MAX_TEX; a++) {
|
||||
p = &state.vao->pointers.tex_coord[a];
|
||||
if (state.vao->tex_coord_array[a]) {
|
||||
v = gl_pointer_index(p, i);
|
||||
glMultiTexCoord2fv(GL_TEXTURE0+a, v);
|
||||
if (p->size<4)
|
||||
glMultiTexCoord2fv(GL_TEXTURE0+a, v);
|
||||
else
|
||||
glMultiTexCoord4fv(GL_TEXTURE0+a, v);
|
||||
}
|
||||
}
|
||||
p = &state.vao->pointers.vertex;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "gl.h"
|
||||
#include "list.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define alloc_sublist(n, cap) \
|
||||
(GLfloat *)malloc(n * sizeof(GLfloat) * cap)
|
||||
@@ -337,8 +338,8 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
|
||||
for (int i=0; i<MAX_TEX; i++) {
|
||||
tmp = a->tex[i];
|
||||
if (tmp) {
|
||||
a->tex[i] = alloc_sublist(2, cap);
|
||||
memcpy(a->tex[i], tmp, 2*a->len*sizeof(GLfloat));
|
||||
a->tex[i] = alloc_sublist(4, cap);
|
||||
memcpy(a->tex[i], tmp, 4*a->len*sizeof(GLfloat));
|
||||
}
|
||||
}
|
||||
if (a->indices) {
|
||||
@@ -357,7 +358,7 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
|
||||
realloc_sublist(a->color, 4, cap);
|
||||
realloc_sublist(a->secondary, 4, cap);
|
||||
for (int i=0; i<MAX_TEX; i++)
|
||||
realloc_sublist(a->tex[i], 2, cap);
|
||||
realloc_sublist(a->tex[i], 4, cap);
|
||||
}
|
||||
}
|
||||
// append arrays
|
||||
@@ -366,7 +367,7 @@ void append_renderlist(renderlist_t *a, renderlist_t *b) {
|
||||
if (a->color) memcpy(a->color+a->len*4, b->color, b->len*4*sizeof(GLfloat));
|
||||
if (a->secondary) memcpy(a->secondary+a->len*4, b->secondary, b->len*4*sizeof(GLfloat));
|
||||
for (int i=0; i<MAX_TEX; i++)
|
||||
if (a->tex[i]) memcpy(a->tex[i]+a->len*2, b->tex[i], b->len*2*sizeof(GLfloat));
|
||||
if (a->tex[i]) memcpy(a->tex[i]+a->len*4, b->tex[i], b->len*4*sizeof(GLfloat));
|
||||
|
||||
// indices
|
||||
if (ilen_a + ilen_b)
|
||||
@@ -576,7 +577,7 @@ void resize_renderlist(renderlist_t *list) {
|
||||
realloc_sublist(list->color, 4, list->cap);
|
||||
realloc_sublist(list->secondary, 4, list->cap);
|
||||
for (int a=0; a<MAX_TEX; a++)
|
||||
realloc_sublist(list->tex[a], 2, list->cap);
|
||||
realloc_sublist(list->tex[a], 4, list->cap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,7 +631,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=0x%04X(0x%04X), ilen=%d, next=%p\n", list, state.gl_batch, list->len, list->mode, list->mode_init, list->ilen, list->next);
|
||||
//printf("draw_renderlist %p, gl_batch=%i, size=%i, mode=%s(%s), ilen=%d, next=%p\n", list, state.gl_batch, list->len, PrintEnum(list->mode), PrintEnum(list->mode_init), list->ilen, list->next);
|
||||
LOAD_GLES(glDrawArrays);
|
||||
LOAD_GLES(glDrawElements);
|
||||
#ifdef USE_ES2
|
||||
@@ -829,7 +830,7 @@ void draw_renderlist(renderlist_t *list) {
|
||||
glClientActiveTexture(GL_TEXTURE0+a);
|
||||
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
state.clientstate.tex_coord_array[a] = 1;
|
||||
gles_glTexCoordPointer(2, GL_FLOAT, 0, (texgened[a])?texgened[a]:list->tex[a]);
|
||||
gles_glTexCoordPointer(4, GL_FLOAT, 0, (texgened[a])?texgened[a]:list->tex[a]);
|
||||
} else {
|
||||
if (state.clientstate.tex_coord_array[a]) {
|
||||
glClientActiveTexture(GL_TEXTURE0+a);
|
||||
@@ -1095,8 +1096,8 @@ void rlVertex3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) {
|
||||
|
||||
for (int a=0; a<MAX_TEX; a++) {
|
||||
if (list->tex[a]) {
|
||||
GLfloat *tex = list->tex[a] + (list->len * 2);
|
||||
memcpy(tex, state.texcoord[a], sizeof(GLfloat) * 2);
|
||||
GLfloat *tex = list->tex[a] + (list->len * 4);
|
||||
memcpy(tex, state.texcoord[a], sizeof(GLfloat) * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1242,34 +1243,36 @@ void rlTexGenfv(renderlist_t *list, GLenum coord, GLenum pname, const GLfloat *
|
||||
memcpy(m->color, params, 4*sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void rlTexCoord2f(renderlist_t *list, GLfloat s, GLfloat t) {
|
||||
void rlTexCoord4f(renderlist_t *list, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
if (list->tex[0] == NULL) {
|
||||
list->tex[0] = alloc_sublist(2, list->cap);
|
||||
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++) {
|
||||
memcpy(tex, state.texcoord[0], sizeof(GLfloat) * 2);
|
||||
tex += 2;
|
||||
memcpy(tex, state.texcoord[0], sizeof(GLfloat) * 4);
|
||||
tex += 4;
|
||||
}
|
||||
}
|
||||
|
||||
GLfloat *tex = state.texcoord[0];
|
||||
tex[0] = s; tex[1] = t;
|
||||
tex[2] = r; tex[3] = q;
|
||||
}
|
||||
|
||||
void rlMultiTexCoord2f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t) {
|
||||
void rlMultiTexCoord4f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
const int tmu = target - GL_TEXTURE0;
|
||||
if (list->tex[tmu] == NULL) {
|
||||
list->tex[tmu] = alloc_sublist(2, list->cap);
|
||||
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++) {
|
||||
memcpy(tex, state.texcoord[tmu], sizeof(GLfloat) * 2);
|
||||
tex += 2;
|
||||
memcpy(tex, state.texcoord[tmu], sizeof(GLfloat) * 4);
|
||||
tex += 4;
|
||||
}
|
||||
}
|
||||
GLfloat *tex = state.texcoord[tmu];
|
||||
tex[0] = s; tex[1] = t;
|
||||
tex[2] = r; tex[3] = q;
|
||||
}
|
||||
|
||||
void rlActiveTexture(renderlist_t *list, GLenum texture ) {
|
||||
|
||||
@@ -159,8 +159,8 @@ extern void rlLightfv(renderlist_t *list, GLenum which, GLenum pname, const GLfl
|
||||
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 rlTexCoord2f(renderlist_t *list, GLfloat s, GLfloat t);
|
||||
extern void rlMultiTexCoord2f(renderlist_t *list, GLenum texture, GLfloat s, GLfloat t);
|
||||
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 rlVertex3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z);
|
||||
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);
|
||||
|
||||
@@ -8,14 +8,15 @@ static const colorlayout_t *get_color_map(GLenum format) {
|
||||
return &layout; }
|
||||
switch (format) {
|
||||
map(GL_RED, 0, -1, -1, -1);
|
||||
map(GL_RG, 0, 1, -1, -1);
|
||||
map(GL_RGBA, 0, 1, 2, 3);
|
||||
map(GL_RGB, 0, 1, 2, -1);
|
||||
map(GL_BGRA, 2, 1, 0, 3);
|
||||
map(GL_BGR, 2, 1, 0, -1);
|
||||
map(GL_R, 0, -1, -1, -1);
|
||||
map(GL_RG, 0, 1, -1, -1);
|
||||
map(GL_RGBA,0, 1, 2, 3);
|
||||
map(GL_RGB, 0, 1, 2, -1);
|
||||
map(GL_BGRA,2, 1, 0, 3);
|
||||
map(GL_BGR, 2, 1, 0, -1);
|
||||
map(GL_LUMINANCE_ALPHA, 0, 0, 0, 1);
|
||||
map(GL_LUMINANCE, 0, 0, 0, -1);
|
||||
map(GL_ALPHA, -1, -1, -1, 0);
|
||||
map(GL_ALPHA,-1, -1, -1, 0);
|
||||
default:
|
||||
printf("libGL: unknown pixel format %i\n", format);
|
||||
break;
|
||||
@@ -745,8 +746,7 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
|
||||
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&0x00f80000)>>(16+3)) | ((tmp&0x0000fc00)>>(8+2-5)) | ((tmp&0x000000f8)<<(11-3));
|
||||
*(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));
|
||||
src_pos += src_stride;
|
||||
dst_pos += dst_stride;
|
||||
}
|
||||
@@ -759,8 +759,7 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
|
||||
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&0x00f80000)>>(16+3-11)) | ((tmp&0x0000fc00)>>(8+2-5)) | ((tmp&0x000000f8)>>(3));
|
||||
*(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));
|
||||
src_pos += src_stride;
|
||||
dst_pos += dst_stride;
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ void glPopAttrib() {
|
||||
if (cur->mask & GL_CURRENT_BIT) {
|
||||
glColor4f(v4(cur->color));
|
||||
glNormal3f(v3(cur->normal));
|
||||
glTexCoord2f(v2(cur->tex));
|
||||
glTexCoord4f(v4(cur->tex));
|
||||
}
|
||||
|
||||
if (cur->mask & GL_DEPTH_BUFFER_BIT) {
|
||||
|
||||
@@ -134,7 +134,7 @@ typedef struct {
|
||||
texture_state_t texture;
|
||||
GLfloat color[4];
|
||||
GLfloat secondary[4];
|
||||
GLfloat texcoord[MAX_TEX][2];
|
||||
GLfloat texcoord[MAX_TEX][4];
|
||||
GLfloat normal[3];
|
||||
int render_mode;
|
||||
int polygon_mode;
|
||||
|
||||
@@ -226,7 +226,7 @@ void matrix_mul(const GLfloat *a, const GLfloat *b, GLfloat *c) {
|
||||
void dot_loop(const GLfloat *verts, const GLfloat *params, GLfloat *out, GLint count, GLushort *indices) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
GLushort k = indices?indices[i]:i;
|
||||
out[k*2] = dot(verts+k*3, params) + params[3];
|
||||
out[k*4] = dot(verts+k*3, params) + params[3];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,8 +258,10 @@ void sphere_loop(const GLfloat *verts, const GLfloat *norm, GLfloat *out, GLint
|
||||
reflect[j]=eye[j]-eye_norm[j]*a;
|
||||
reflect[2]+=1.0f;
|
||||
a = 1.0f / (2.0f*sqrtf(dot(reflect, reflect)));
|
||||
out[k*2+0] = reflect[0]*a + 0.5f;
|
||||
out[k*2+1] = reflect[1]*a + 0.5f;
|
||||
out[k*4+0] = reflect[0]*a + 0.5f;
|
||||
out[k*4+1] = reflect[1]*a + 0.5f;
|
||||
out[k*4+2] = 0.0f;
|
||||
out[k*4+3] = 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -278,7 +280,7 @@ void eye_loop(const GLfloat *verts, const GLfloat *param, GLfloat *out, GLint co
|
||||
for (int i=0; i<count; i++) {
|
||||
GLushort k = indices?indices[i]:i;
|
||||
matrix_vector(ModelviewMatrix, verts+k*3, tmp);
|
||||
out[k*2]=dot(plane, tmp);
|
||||
out[k*4]=dot(plane, tmp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -303,14 +305,14 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
|
||||
// special case : no texgen but texture activated, create a simple 1 repeated element
|
||||
if (!state.enable.texgen_s[texture] && !state.enable.texgen_t[texture] && !state.enable.texgen_r[texture]) {
|
||||
if ((*coords)==NULL)
|
||||
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
|
||||
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
|
||||
if (indices)
|
||||
for (int i=0; i<ilen; i++) {
|
||||
memcpy((*coords)+indices[i]*2, state.texcoord[texture], sizeof(GLfloat)*2);
|
||||
memcpy((*coords)+indices[i]*4, state.texcoord[texture], sizeof(GLfloat)*4);
|
||||
}
|
||||
else
|
||||
for (int i=0; i<count*2; i+=2) {
|
||||
memcpy((*coords)+i, state.texcoord[texture], sizeof(GLfloat)*2);
|
||||
for (int i=0; i<count*4; i+=4) {
|
||||
memcpy((*coords)+i, state.texcoord[texture], sizeof(GLfloat)*4);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -320,7 +322,7 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
|
||||
if (!state.enable.texture_2d[texture])
|
||||
return;
|
||||
if ((*coords)==NULL)
|
||||
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
|
||||
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
|
||||
sphere_loop(verts, norm, *coords, (indices)?ilen:count, indices);
|
||||
return;
|
||||
}
|
||||
@@ -373,11 +375,16 @@ void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count
|
||||
if (!state.enable.texture_2d[texture])
|
||||
return;
|
||||
if ((*coords)==NULL)
|
||||
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
|
||||
*coords = (GLfloat *)malloc(count * 4 * sizeof(GLfloat));
|
||||
if (state.enable.texgen_s[texture])
|
||||
tex_coord_loop(verts, norm, *coords, (indices)?ilen:count, state.texgen[texture].S, state.texgen[texture].S_O, state.texgen[texture].S_E, indices);
|
||||
if (state.enable.texgen_t[texture])
|
||||
tex_coord_loop(verts, norm, *coords+1, (indices)?ilen:count, state.texgen[texture].T, state.texgen[texture].T_O, state.texgen[texture].T_E, indices);
|
||||
for (int i=0; i<count; i++) {
|
||||
GLushort k = indices?indices[i]:i;
|
||||
(*coords)[k*4+2] = 0.0f;
|
||||
(*coords)[k*4+3] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void gen_tex_clean(GLint cleancode, int texture) {
|
||||
|
||||
@@ -33,7 +33,7 @@ void tex_coord_rect_arb(GLfloat *tex, GLsizei len,
|
||||
for (int i = 0; i < len; i++) {
|
||||
tex[0] *= iwidth;
|
||||
tex[1] *= iheight;
|
||||
tex += 2;
|
||||
tex += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void tex_coord_npot(GLfloat *tex, GLsizei len,
|
||||
for (int i = 0; i < len; i++) {
|
||||
tex[0] *= wratio;
|
||||
tex[1] *= hratio;
|
||||
tex += 2;
|
||||
tex += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void tex_setup_texcoord(GLuint texunit, GLuint len) {
|
||||
if (old!=texunit) glClientActiveTexture(texunit+GL_TEXTURE0);
|
||||
if (changes) {
|
||||
// first convert to GLfloat, without normalization
|
||||
tex[texunit] = copy_gl_pointer_raw(&state.vao->pointers.tex_coord[texunit], 2, 0, len, state.vao->pointers.tex_coord[texunit].buffer);
|
||||
tex[texunit] = copy_gl_pointer_tex(&state.vao->pointers.tex_coord[texunit], 4, 0, len, state.vao->pointers.tex_coord[texunit].buffer);
|
||||
if (!tex[texunit]) {
|
||||
printf("LibGL: Error with Texture tranform\n");
|
||||
gles_glTexCoordPointer(len, state.vao->pointers.tex_coord[texunit].type, state.vao->pointers.tex_coord[texunit].stride, state.vao->pointers.tex_coord[texunit].pointer);
|
||||
@@ -93,7 +93,7 @@ void tex_setup_texcoord(GLuint texunit, GLuint len) {
|
||||
if ((bound->width!=bound->nwidth) || (bound->height!=bound->nheight))
|
||||
tex_coord_npot(tex[texunit], len, bound->width, bound->height, bound->nwidth, bound->nheight);
|
||||
// All done, setup the texcoord array now
|
||||
gles_glTexCoordPointer(2, GL_FLOAT, 0, tex[texunit]);
|
||||
gles_glTexCoordPointer(4, GL_FLOAT, 0, tex[texunit]);
|
||||
} else {
|
||||
gles_glTexCoordPointer(state.vao->pointers.tex_coord[texunit].size, state.vao->pointers.tex_coord[texunit].type, state.vao->pointers.tex_coord[texunit].stride, state.vao->pointers.tex_coord[texunit].pointer);
|
||||
}
|
||||
@@ -247,11 +247,15 @@ GLenum swizzle_internalformat(GLenum *internalformat) {
|
||||
switch(*internalformat) {
|
||||
case GL_R:
|
||||
case 1:
|
||||
ret = GL_R; sret = GL_RGB;
|
||||
ret = GL_LUMINANCE; sret = GL_LUMINANCE;
|
||||
break;
|
||||
case GL_RG:
|
||||
case 2:
|
||||
ret = GL_RG; sret = GL_RGB;
|
||||
ret = GL_LUMINANCE_ALPHA;
|
||||
if (nolumalpha)
|
||||
sret = GL_RGBA;
|
||||
else
|
||||
sret = GL_LUMINANCE_ALPHA;
|
||||
break;
|
||||
case GL_RGB5:
|
||||
case GL_RGB8:
|
||||
@@ -1031,12 +1035,12 @@ gltexture_t* getTexture(GLenum target, GLuint texture) {
|
||||
tex->width = 0;
|
||||
tex->height = 0;
|
||||
tex->uploaded = false;
|
||||
tex->mipmap_auto = default_tex_mipmap;
|
||||
tex->mipmap_need = 0;
|
||||
tex->mipmap_auto = default_tex_mipmap || (automipmap==1);
|
||||
tex->mipmap_need = (automipmap==1)?1:0;
|
||||
tex->alpha = true;
|
||||
tex->streamed = false;
|
||||
tex->streamingID = -1;
|
||||
tex->min_filter = tex->mag_filter = GL_LINEAR;
|
||||
tex->min_filter = tex->mag_filter = (automipmap==1)?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR;
|
||||
tex->format = GL_RGBA;
|
||||
tex->type = GL_UNSIGNED_BYTE;
|
||||
tex->orig_internal = GL_RGBA;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gl.h"
|
||||
#include "../debug.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define constDoubleToFloat(a, size) \
|
||||
@@ -232,49 +233,52 @@ void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t) {
|
||||
}
|
||||
* */
|
||||
void glMultiTexCoord1f(GLenum target, GLfloat s) {
|
||||
glMultiTexCoord2f(target, s, 0);
|
||||
glMultiTexCoord4f(target, s, 0, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord1fv(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], 0);
|
||||
glMultiTexCoord4f(target, t[0], 0, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t) {
|
||||
glMultiTexCoord4f(target, s, t, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
|
||||
glMultiTexCoord2f(target, s, t);
|
||||
glMultiTexCoord4f(target, s, t, r, 1);
|
||||
}
|
||||
void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
/*void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
glMultiTexCoord2f(target, s, t);
|
||||
}
|
||||
}*/
|
||||
void glMultiTexCoord2fv(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], 0, 1);
|
||||
}
|
||||
void glMultiTexCoord3fv(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], 1);
|
||||
}
|
||||
void glMultiTexCoord4fv(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], t[3]);
|
||||
}
|
||||
void glMultiTexCoord1fARB(GLenum target, GLfloat s) {
|
||||
glMultiTexCoord2f(target, s, 0);
|
||||
glMultiTexCoord4f(target, s, 0, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord1fvARB(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], 0);
|
||||
glMultiTexCoord4f(target, t[0], 0, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) {
|
||||
glMultiTexCoord2f(target, s, t);
|
||||
glMultiTexCoord4f(target, s, t, 0, 1);
|
||||
}
|
||||
void glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
|
||||
glMultiTexCoord2f(target, s, t);
|
||||
glMultiTexCoord4f(target, s, t, r, 1);
|
||||
}
|
||||
void glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
glMultiTexCoord2f(target, s, t);
|
||||
glMultiTexCoord4f(target, s, t, r, q);
|
||||
}
|
||||
void glMultiTexCoord2fvARB(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], 0, 1);
|
||||
}
|
||||
void glMultiTexCoord3fvARB(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], 1);
|
||||
}
|
||||
void glMultiTexCoord4fvARB(GLenum target, GLfloat *t) {
|
||||
glMultiTexCoord2f(target, t[0], t[1]);
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], t[3]);
|
||||
}
|
||||
/*
|
||||
void glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
|
||||
@@ -418,78 +422,78 @@ void glVertex4##suffix##v(type *v) { \
|
||||
} \
|
||||
/* texture */ \
|
||||
void glTexCoord1##suffix(type s) { \
|
||||
glTexCoord2f(s, 0); \
|
||||
glTexCoord4f(s, 0, 0, 1); \
|
||||
} \
|
||||
void glTexCoord1##suffix##v(type *t) { \
|
||||
glTexCoord2f(t[0], 0); \
|
||||
glTexCoord4f(t[0], 0, 0, 1); \
|
||||
} \
|
||||
void glTexCoord2##suffix(type s, type t) { \
|
||||
glTexCoord2f(s, t); \
|
||||
glTexCoord4f(s, t, 0, 1); \
|
||||
} \
|
||||
void glTexCoord2##suffix##v(type *t) { \
|
||||
glTexCoord2f(t[0], t[1]); \
|
||||
glTexCoord4f(t[0], t[1], 0, 1); \
|
||||
} \
|
||||
void glTexCoord3##suffix(type s, type t, type r) { \
|
||||
glTexCoord2f(s, t); \
|
||||
glTexCoord4f(s, t, r, 1); \
|
||||
} \
|
||||
void glTexCoord3##suffix##v(type *t) { \
|
||||
glTexCoord2f(t[0], t[1]); \
|
||||
glTexCoord4f(t[0], t[1], t[2], 1); \
|
||||
} \
|
||||
void glTexCoord4##suffix(type s, type t, type r, type q) { \
|
||||
glTexCoord2f(s, t); \
|
||||
glTexCoord4f(s, t, r, q); \
|
||||
} \
|
||||
void glTexCoord4##suffix##v(type *t) { \
|
||||
glTexCoord2f(t[0], t[1]); \
|
||||
glTexCoord4f(t[0], t[1], t[2], t[3]); \
|
||||
} \
|
||||
/* multi-texture */ \
|
||||
void glMultiTexCoord1##suffix(GLenum target, type s) { \
|
||||
glMultiTexCoord2f(target, s, 0); \
|
||||
glMultiTexCoord4f(target, s, 0, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord1##suffix##v(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], 0); \
|
||||
glMultiTexCoord4f(target, t[0], 0, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord2##suffix(GLenum target, type s, type t) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord2##suffix##v(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord3##suffix(GLenum target, type s, type t, type r) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, r, 1); \
|
||||
} \
|
||||
void glMultiTexCoord3##suffix##v(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], 1); \
|
||||
} \
|
||||
void glMultiTexCoord4##suffix(GLenum target, type s, type t, type r, type q) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, r, q); \
|
||||
} \
|
||||
void glMultiTexCoord4##suffix##v(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], t[3]); \
|
||||
} \
|
||||
/* multi-texture ARB */ \
|
||||
void glMultiTexCoord1##suffix##ARB(GLenum target, type s) { \
|
||||
glMultiTexCoord2f(target, s, 0); \
|
||||
glMultiTexCoord4f(target, s, 0, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord1##suffix##vARB(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], 0); \
|
||||
glMultiTexCoord4f(target, t[0], 0, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord2##suffix##ARB(GLenum target, type s, type t) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord2##suffix##vARB(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], 0, 1); \
|
||||
} \
|
||||
void glMultiTexCoord3##suffix##ARB(GLenum target, type s, type t, type r) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, r, 1); \
|
||||
} \
|
||||
void glMultiTexCoord3##suffix##vARB(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], 1); \
|
||||
} \
|
||||
void glMultiTexCoord4##suffix##ARB(GLenum target, type s, type t, type r, type q) { \
|
||||
glMultiTexCoord2f(target, s, t); \
|
||||
glMultiTexCoord4f(target, s, t, r, q); \
|
||||
} \
|
||||
void glMultiTexCoord4##suffix##vARB(GLenum target, type *t) { \
|
||||
glMultiTexCoord2f(target, t[0], t[1]); \
|
||||
glMultiTexCoord4f(target, t[0], t[1], t[2], t[3]); \
|
||||
}
|
||||
|
||||
|
||||
@@ -655,25 +659,28 @@ void glNormal3fv(GLfloat *v) {
|
||||
|
||||
// textures
|
||||
void glTexCoord1f(GLfloat s) {
|
||||
glTexCoord2f(s, 0);
|
||||
glTexCoord4f(s, 0, 0, 1);
|
||||
}
|
||||
void glTexCoord1fv(GLfloat *t) {
|
||||
glTexCoord2f(t[0], 0);
|
||||
glTexCoord4f(t[0], 0, 0, 1);
|
||||
}
|
||||
void glTexCoord2f(GLfloat s, GLfloat t) {
|
||||
glTexCoord4f(s, t, 0, 1);
|
||||
}
|
||||
void glTexCoord2fv(GLfloat *t) {
|
||||
glTexCoord2f(t[0], t[1]);
|
||||
glTexCoord4f(t[0], t[1], 0, 1);
|
||||
}
|
||||
void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r) {
|
||||
glTexCoord2f(s, t);
|
||||
glTexCoord4f(s, t, r, 1);
|
||||
}
|
||||
void glTexCoord3fv(GLfloat *t) {
|
||||
glTexCoord2f(t[0], t[1]);
|
||||
glTexCoord4f(t[0], t[1], t[2], 1);
|
||||
}
|
||||
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
/*void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
||||
glTexCoord2f(s, t);
|
||||
}
|
||||
}*/
|
||||
void glTexCoord4fv(GLfloat *t) {
|
||||
glTexCoord2f(t[0], t[1]);
|
||||
glTexCoord4f(t[0], t[1], t[2], t[3]);
|
||||
}
|
||||
|
||||
// texgen
|
||||
@@ -731,7 +738,10 @@ void glVertex4fv(GLfloat *v) {
|
||||
}
|
||||
|
||||
void glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void *indices) {
|
||||
//printf("glDrawRangeElements(0x%04X, %i, %i, %i, 0x%04X, @%p), inlist=%i\n", mode, start, end, count, type, indices, (state.list.active)?1:0);
|
||||
//printf("glDrawRangeElements(%s, %i, %i, %i, %s, @%p), inlist=%i\n", PrintEnum(mode), start, end, count, PrintEnum(type), indices, (state.list.active)?1:0);
|
||||
#if 1
|
||||
glDrawElements(mode, count, type, indices);
|
||||
#else
|
||||
GLushort *newinds = (GLushort*)malloc(sizeof(GLushort)*count);
|
||||
int newcount=0;
|
||||
glbuffer_t *elements = state.vao->elements;
|
||||
@@ -751,6 +761,7 @@ void glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenu
|
||||
free(newinds);
|
||||
|
||||
state.vao->elements = elements;
|
||||
#endif
|
||||
}
|
||||
|
||||
void glDrawRangeElementsEXT(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void *indices) {
|
||||
|
||||
@@ -156,7 +156,6 @@ static bool g_usefb = false;
|
||||
static bool g_usefbo = false;
|
||||
static bool g_xrefresh = false;
|
||||
static bool g_stacktrace = false;
|
||||
static bool g_bcm_active = false;
|
||||
extern int automipmap;
|
||||
extern int texcopydata;
|
||||
extern int tested_env;
|
||||
@@ -171,10 +170,47 @@ extern char gl_version[50];
|
||||
|
||||
bool g_recyclefbo = false;
|
||||
static int g_width=0, g_height=0;
|
||||
#ifndef BCMHOST
|
||||
// RPI stuffs
|
||||
static bool g_bcmhost = false;
|
||||
#else
|
||||
static bool g_bcmhost = true;
|
||||
static bool g_bcm_active = false;
|
||||
void (*bcm_host_init)();
|
||||
void (*bcm_host_deinit)();
|
||||
#ifdef BCMHOST
|
||||
void *bcm_host = NULL, *vcos = NULL;
|
||||
static const char *path_prefix[] = {
|
||||
"",
|
||||
"/opt/vc/lib/",
|
||||
"/usr/local/lib/",
|
||||
"/usr/lib/",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *lib_ext[] = {
|
||||
"so",
|
||||
"so.1",
|
||||
"so.2",
|
||||
"dylib",
|
||||
"dll",
|
||||
NULL,
|
||||
};
|
||||
void *open_lib(const char **names) {
|
||||
void *lib = NULL;
|
||||
|
||||
char path_name[PATH_MAX + 1];
|
||||
int flags = RTLD_LOCAL | RTLD_NOW;
|
||||
for (int p = 0; path_prefix[p]; p++) {
|
||||
for (int i = 0; names[i]; i++) {
|
||||
for (int e = 0; lib_ext[e]; e++) {
|
||||
snprintf(path_name, PATH_MAX, "%s%s.%s", path_prefix[p], names[i], lib_ext[e]);
|
||||
if ((lib = dlopen(path_name, flags))) {
|
||||
printf("libGL:loaded: %s\n", path_name);
|
||||
return lib;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int swap_interval = 1;
|
||||
@@ -281,6 +317,20 @@ static void scan_env() {
|
||||
|
||||
env(LIBGL_XREFRESH, g_xrefresh, "xrefresh will be called on cleanup");
|
||||
env(LIBGL_STACKTRACE, g_stacktrace, "stacktrace will be printed on crash");
|
||||
#ifdef BCMHOST
|
||||
// Try to load RPi specifics libs
|
||||
const char *bcm_host_name[] = {"libbcm_host", NULL};
|
||||
const char *vcos_name[] = {"libvcos", NULL};
|
||||
bcm_host = open_lib(bcm_host_name);
|
||||
vcos = open_lib(vcos_name);
|
||||
// if ok, grab the init/deinit functions
|
||||
if (bcm_host) {
|
||||
bcm_host_init = dlsym(bcm_host, "bcm_host_init");
|
||||
bcm_host_deinit = dlsym(bcm_host, "bcm_host_deinit");
|
||||
if (bcm_host_init && bcm_host_deinit)
|
||||
g_bcmhost = true;
|
||||
}
|
||||
#endif
|
||||
if (g_xrefresh || g_stacktrace || g_bcmhost) {
|
||||
// TODO: a bit gross. Maybe look at this: http://stackoverflow.com/a/13290134/293352
|
||||
signal(SIGBUS, signal_handler);
|
||||
@@ -1101,4 +1151,12 @@ int glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) {
|
||||
printf("LIBGL: Warning, stub glxDestroyPBuffer called\n");
|
||||
}
|
||||
GLXPbuffer glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int * attrib_list) {
|
||||
printf("LIBGL: Warning, stub glxCreatePBuffer called\n");
|
||||
return 0;
|
||||
}
|
||||
#endif //ANDROID
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
#if defined (BCMHOST) && !defined(ANDROID)
|
||||
#include "bcm_host.h"
|
||||
#endif
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@@ -144,6 +140,8 @@ struct __GLXContextRec {
|
||||
EGLContext eglContext;
|
||||
};
|
||||
typedef struct __GLXContextRec *GLXContext;
|
||||
|
||||
typedef XID GLXPbuffer;
|
||||
#endif //ANDROID
|
||||
struct __GLXFBConfigRec {
|
||||
int visualType;
|
||||
@@ -257,4 +255,7 @@ void glXDestroyWindow(Display *display, void *win);
|
||||
|
||||
Bool glXMakeContextCurrent(Display *display, int drawable, int readable, GLXContext context);
|
||||
GLXContext glXCreateNewContext(Display *display, GLXFBConfig config, int render_type, GLXContext share_list, Bool is_direct);
|
||||
#endif //ANDROID
|
||||
|
||||
void glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf);
|
||||
GLXPbuffer glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int * attrib_list);
|
||||
#endif //ANDROID
|
||||
|
||||
Reference in New Issue
Block a user