glshim updated. added changes from https://github.com/ptitSeb/glshim
This commit is contained in:
1
project/jni/glshim/Android.mk
Executable file → Normal file
1
project/jni/glshim/Android.mk
Executable file → Normal file
@@ -47,3 +47,4 @@ LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DBCMHOST -include include/andro
|
||||
#LOCAL_LDLIBS := -ldl -llog -lEGL
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
@@ -8,6 +8,19 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
|
||||
option(PANDORA "Set to ON if targeting an OpenPandora device" ${PANDORA})
|
||||
option(BCMHOST "Set to ON if targeting an RPi(2) device" ${BCMHOST})
|
||||
option(ODROID "Set to ON if targeting an ODroid device" ${ODROID})
|
||||
|
||||
#select at least 1 plateform, PANDORA is default...
|
||||
if(NOT PANDORA)
|
||||
if(NOT BCMHOST)
|
||||
if(NOT ODROID)
|
||||
set(PANDORA ON CACHE BOOL "Set to ON if targeting an OpenPandora device" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Raspberry PI
|
||||
if(BCMHOST)
|
||||
include_directories(/opt/vc/include /opt/vc/include/interface/vcos/pthreads /opt/vc/include/interface/vmcs_host/linux)
|
||||
@@ -15,6 +28,15 @@ if(BCMHOST)
|
||||
add_definitions(-DBCMHOST)
|
||||
endif()
|
||||
|
||||
if(PANDORA)
|
||||
add_definitions(-DPANDORA)
|
||||
add_definitions(-DTEXSTREAM)
|
||||
endif()
|
||||
|
||||
if(ODROID)
|
||||
add_definitions(-DODROID)
|
||||
endif()
|
||||
|
||||
link_directories(${CMAKE_BINARY_DIR}/lib)
|
||||
add_definitions(-g -std=gnu99 -funwind-tables -O3)
|
||||
|
||||
|
||||
35
project/jni/glshim/README.md
Normal file → Executable file
35
project/jni/glshim/README.md
Normal file → Executable file
@@ -3,23 +3,50 @@ glshim
|
||||
|
||||
This is a shim providing OpenGL 1.x functionality to OpenGL ES accelerated cards.
|
||||
|
||||
Most function of OpenGL up to 1.5 are supported, with some notable exceptions:
|
||||
* Reading of Depth or Stencil buffer will not work
|
||||
* GL_FEEDBACK mode is not implemented
|
||||
* OcclusionQuery is not implemented
|
||||
|
||||
Some know limitations:
|
||||
* GL_SELECT as some limitation in its implementation (for exemple, current Depth buffer or binded texture are not taken into account)
|
||||
* NPOT texture are supported, but not with GL_REPEAT / GL_MIRRORED, only GL_CLAMP will work properly
|
||||
* Framebuffer use FRAMEBUFFER_OES extension (that must be present in the GLES 1.1 stack)
|
||||
* Multiple Color attachment on Framebuffer are not supported
|
||||
* Internaly, Texture coordinates are 2D, Vertex are 3D only (no real support for W for vertex, or 3D texture / cubemaps)
|
||||
* Probably many other things
|
||||
|
||||
----
|
||||
|
||||
Compiling
|
||||
----
|
||||
*for Pandora*
|
||||
|
||||
cmake .; make GL
|
||||
|
||||
cmake . ; make GL
|
||||
|
||||
*or for the Raspberry Pi*
|
||||
|
||||
cmake . -DBCMHOST=1; make GL
|
||||
|
||||
*or for the ODroid*
|
||||
|
||||
cmake . -DODROID=1; make GL
|
||||
|
||||
*or for Android*
|
||||
|
||||
An Android.mk is provided that should compile with an NDK
|
||||
|
||||
|
||||
*or use ccmake*
|
||||
Alternatively, you can use the curses-bases ccmake to select wich platform to use interactively.
|
||||
|
||||
----
|
||||
|
||||
GLU
|
||||
----
|
||||
Standard GLU do works without any issues.
|
||||
|
||||
You probably want the glu branch from https://github.com/lunixbochs/glues
|
||||
But you can also find a GLES optimized version og GLU there https://github.com/lunixbochs/glues
|
||||
|
||||
git clone git@github.com:lunixbochs/glues.git; git checkout glu; cmake .; make
|
||||
|
||||
@@ -28,4 +55,4 @@ You probably want the glu branch from https://github.com/lunixbochs/glues
|
||||
Installation
|
||||
----
|
||||
|
||||
Put lib/libGL.so.1 in your `LD_LIBRARY_PATH`. If you need GLU, build libGLU.so.1 from the glues repo and do likewise.
|
||||
Put lib/libGL.so.1 in your `LD_LIBRARY_PATH`.
|
||||
|
||||
3
project/jni/glshim/include/android_debug.h
Executable file → Normal file
3
project/jni/glshim/include/android_debug.h
Executable file → Normal file
@@ -9,7 +9,7 @@
|
||||
#include <android/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
// Include everything beforehand, so we wont' get compiler eerors because of our #define
|
||||
// Include everything beforehand, so we wont' get compiler errors because of our #define
|
||||
#include <string>
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
@@ -67,3 +67,4 @@ static inline int __sdl_logged_fprintf(FILE *stream, const char *format, ...)
|
||||
#define fprintf(...) __sdl_logged_fprintf(__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ add_library(GL SHARED ${GL_SOURCES})
|
||||
|
||||
if(BCMHOST)
|
||||
set(PI_LIBS bcm_host vcos pthread)
|
||||
target_link_libraries(GL ${PI_LIBS} GLESv1_CM)
|
||||
target_link_libraries(GL ${PI_LIBS})
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
@@ -100,7 +100,6 @@ const GLubyte *glGetString(GLenum name) {
|
||||
"GL_ARB_texture_env_dot3 "
|
||||
"GL_ARB_texture_mirrored_repeat "
|
||||
"GL_SGIS_generate_mipmap "
|
||||
"GL_EXT_blend_subtract "
|
||||
"GL_EXT_packed_depth_stencil "
|
||||
"GL_EXT_draw_range_elements "
|
||||
"GL_EXT_bgra "
|
||||
@@ -116,8 +115,11 @@ const GLubyte *glGetString(GLenum name) {
|
||||
"GL_ARB_point_parameters "
|
||||
"GL_EXT_point_parameters "
|
||||
"GL_EXT_stencil_wrap "
|
||||
#ifndef ODROID
|
||||
"GL_EXT_blend_subtract "
|
||||
"GL_EXT_blend_func_separate "
|
||||
"GL_EXT_blend_equation_separate "
|
||||
#endif
|
||||
"GL_ARB_draw_buffers "
|
||||
// "GL_EXT_blend_logic_op "
|
||||
// "GL_EXT_blend_color "
|
||||
@@ -429,8 +431,10 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) {
|
||||
if (!state.texture.bound[state.texture.active]->alpha)
|
||||
enable = false;
|
||||
noerrorShim();
|
||||
#ifdef TEXSTREAM
|
||||
if (cap==GL_TEXTURE_STREAM_IMG)
|
||||
state.enable.texture_2d[state.texture.active] = enable;
|
||||
state.enable.texture_2d[state.texture.active] = enable;
|
||||
#endif
|
||||
switch (cap) {
|
||||
proxy_enable(GL_BLEND, blend);
|
||||
proxy_enable(GL_TEXTURE_2D, texture_2d[state.texture.active]);
|
||||
@@ -1673,7 +1677,10 @@ void glBlendFunc(GLenum sfactor, GLenum dfactor) {
|
||||
// special case, as seen in Xash3D, but it breaks torus_trooper, so disabled
|
||||
sfactor = GL_ONE;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
#ifdef ODROID
|
||||
if(gles_glBlendFunc)
|
||||
#endif
|
||||
gles_glBlendFunc(sfactor, dfactor);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include <dlfcn.h>
|
||||
#if defined (BCMHOST) && !defined(ANDROID)
|
||||
#include "bcm_host.h"
|
||||
#endif
|
||||
#include <GLES/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#ifdef TEXSTREAM
|
||||
#include <EGL/eglext.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
@@ -28,21 +33,12 @@ typedef EGLBoolean (*eglBindTexImage_PTR)(EGLDisplay dpy, EGLSurface surface, EG
|
||||
typedef EGLBoolean (*eglChooseConfig_PTR)(EGLDisplay dpy, const EGLint * attrib_list, EGLConfig * configs, EGLint config_size, EGLint * num_config);
|
||||
typedef EGLBoolean (*eglCopyBuffers_PTR)(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
||||
typedef EGLContext (*eglCreateContext_PTR)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint * attrib_list);
|
||||
typedef EGLImageKHR (*eglCreateImageKHR_PTR)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreatePbufferFromClientBuffer_PTR)(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreatePbufferSurface_PTR)(EGLDisplay dpy, EGLConfig config, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreatePixmapSurface_PTR)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreatePixmapSurfaceHI_PTR)(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI * pixmap);
|
||||
typedef EGLStreamKHR (*eglCreateStreamFromFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
|
||||
typedef EGLStreamKHR (*eglCreateStreamKHR_PTR)(EGLDisplay dpy, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint * attrib_list);
|
||||
typedef EGLSyncKHR (*eglCreateSyncKHR_PTR)(EGLDisplay dpy, EGLenum type, const EGLint * attrib_list);
|
||||
typedef EGLSurface (*eglCreateWindowSurface_PTR)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint * attrib_list);
|
||||
typedef EGLBoolean (*eglDestroyContext_PTR)(EGLDisplay dpy, EGLContext ctx);
|
||||
typedef EGLBoolean (*eglDestroyImageKHR_PTR)(EGLDisplay dpy, EGLImageKHR image);
|
||||
typedef EGLBoolean (*eglDestroyStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglDestroySurface_PTR)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (*eglDestroySyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync);
|
||||
typedef EGLBoolean (*eglGetConfigAttrib_PTR)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglGetConfigs_PTR)(EGLDisplay dpy, EGLConfig * configs, EGLint config_size, EGLint * num_config);
|
||||
typedef EGLContext (*eglGetCurrentContext_PTR)();
|
||||
@@ -51,24 +47,14 @@ typedef EGLSurface (*eglGetCurrentSurface_PTR)(EGLint readdraw);
|
||||
typedef EGLDisplay (*eglGetDisplay_PTR)(EGLNativeDisplayType display_id);
|
||||
typedef EGLint (*eglGetError_PTR)();
|
||||
typedef __eglMustCastToProperFunctionPointerType (*eglGetProcAddress_PTR)(const char * procname);
|
||||
typedef EGLNativeFileDescriptorKHR (*eglGetStreamFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglGetSyncAttribKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglInitialize_PTR)(EGLDisplay dpy, EGLint * major, EGLint * minor);
|
||||
typedef EGLBoolean (*eglLockSurfaceKHR_PTR)(EGLDisplay display, EGLSurface surface, const EGLint * attrib_list);
|
||||
typedef EGLBoolean (*eglMakeCurrent_PTR)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
typedef EGLenum (*eglQueryAPI_PTR)();
|
||||
typedef EGLBoolean (*eglQueryContext_PTR)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglQueryStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglQueryStreamTimeKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR * value);
|
||||
typedef const char * (*eglQueryString_PTR)(EGLDisplay dpy, EGLint name);
|
||||
typedef EGLBoolean (*eglQuerySurface_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglReleaseTexImage_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
typedef EGLBoolean (*eglReleaseThread_PTR)();
|
||||
typedef EGLBoolean (*eglSignalSyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
|
||||
typedef EGLBoolean (*eglStreamAttribKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
|
||||
typedef EGLBoolean (*eglStreamConsumerAcquireKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglStreamConsumerGLTextureExternalKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglStreamConsumerReleaseKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglSurfaceAttrib_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
||||
typedef EGLBoolean (*eglSwapBuffers_PTR)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (*eglSwapBuffersWithDamageEXT_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint * rects, EGLint n_rects);
|
||||
@@ -78,7 +64,28 @@ typedef EGLBoolean (*eglUnlockSurfaceKHR_PTR)(EGLDisplay display, EGLSurface sur
|
||||
typedef EGLBoolean (*eglWaitClient_PTR)();
|
||||
typedef EGLBoolean (*eglWaitGL_PTR)();
|
||||
typedef EGLBoolean (*eglWaitNative_PTR)(EGLint engine);
|
||||
#ifdef TEXSTREAM
|
||||
typedef EGLSurface (*eglCreatePixmapSurfaceHI_PTR)(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI * pixmap);
|
||||
typedef EGLBoolean (*eglDestroyImageKHR_PTR)(EGLDisplay dpy, EGLImageKHR image);
|
||||
typedef EGLBoolean (*eglDestroyStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLImageKHR (*eglCreateImageKHR_PTR)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
|
||||
typedef EGLStreamKHR (*eglCreateStreamFromFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
|
||||
typedef EGLStreamKHR (*eglCreateStreamKHR_PTR)(EGLDisplay dpy, const EGLint * attrib_list);
|
||||
typedef EGLSyncKHR (*eglCreateSyncKHR_PTR)(EGLDisplay dpy, EGLenum type, const EGLint * attrib_list);
|
||||
typedef EGLBoolean (*eglDestroySyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync);
|
||||
typedef EGLBoolean (*eglSignalSyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
|
||||
typedef EGLBoolean (*eglGetSyncAttribKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglStreamAttribKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
|
||||
typedef EGLBoolean (*eglStreamConsumerAcquireKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglStreamConsumerGLTextureExternalKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglStreamConsumerReleaseKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglLockSurfaceKHR_PTR)(EGLDisplay display, EGLSurface surface, const EGLint * attrib_list);
|
||||
typedef EGLNativeFileDescriptorKHR (*eglGetStreamFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (*eglQueryStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint * value);
|
||||
typedef EGLBoolean (*eglQueryStreamTimeKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR * value);
|
||||
typedef EGLint (*eglWaitSyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
|
||||
typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint * attrib_list);
|
||||
#endif
|
||||
|
||||
// end of defintions
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ glstack_t *stack = NULL;
|
||||
glclientstack_t *clientStack = NULL;
|
||||
|
||||
void glPushAttrib(GLbitfield mask) {
|
||||
//printf("glPushAttrib(0x%04X)\n", mask);
|
||||
//printf("glPushAttrib(0x%04X)\n", mask);
|
||||
noerrorShim();
|
||||
if ((state.list.compiling || state.gl_batch) && state.list.active) {
|
||||
NewStage(state.list.active, STAGE_PUSH);
|
||||
@@ -63,12 +63,23 @@ void glPushAttrib(GLbitfield mask) {
|
||||
if (mask & GL_ENABLE_BIT) {
|
||||
int i;
|
||||
GLint max_clip_planes;
|
||||
|
||||
cur->alpha_test = glIsEnabled(GL_ALPHA_TEST);
|
||||
cur->autonormal = glIsEnabled(GL_AUTO_NORMAL);
|
||||
cur->blend = glIsEnabled(GL_BLEND);
|
||||
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
|
||||
cur->clip_planes_enabled = (GLboolean *)malloc(max_clip_planes * sizeof(GLboolean));
|
||||
for (i = 0; i < max_clip_planes; i++) {
|
||||
*(cur->clip_planes_enabled + i) = glIsEnabled(GL_CLIP_PLANE0 + i);
|
||||
}
|
||||
|
||||
cur->colormaterial = glIsEnabled(GL_COLOR_MATERIAL);
|
||||
cur->cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
cur->depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
cur->dither = glIsEnabled(GL_DITHER);
|
||||
cur->fog = glIsEnabled(GL_FOG);
|
||||
|
||||
GLint max_lights;
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
|
||||
cur->lights_enabled = (GLboolean *)malloc(max_lights * sizeof(GLboolean));
|
||||
@@ -76,34 +87,36 @@ void glPushAttrib(GLbitfield mask) {
|
||||
*(cur->lights_enabled + i) = glIsEnabled(GL_LIGHT0 + i);
|
||||
}
|
||||
|
||||
cur->alpha_test = glIsEnabled(GL_ALPHA_TEST);
|
||||
cur->blend = glIsEnabled(GL_BLEND);
|
||||
|
||||
cur->cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
cur->depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
cur->dither = glIsEnabled(GL_DITHER);
|
||||
cur->fog = glIsEnabled(GL_FOG);
|
||||
cur->lighting = glIsEnabled(GL_LIGHTING);
|
||||
cur->line_smooth = glIsEnabled(GL_LINE_SMOOTH);
|
||||
cur->line_stipple = glIsEnabled(GL_LINE_STIPPLE);
|
||||
cur->color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
|
||||
//TODO: GL_INDEX_LOGIC_OP
|
||||
//TODO: GL_MAP1_x
|
||||
//TODO: GL_MAP2_x
|
||||
cur->multisample = glIsEnabled(GL_MULTISAMPLE);
|
||||
cur->normalize = glIsEnabled(GL_NORMALIZE);
|
||||
cur->point_smooth = glIsEnabled(GL_POINT_SMOOTH);
|
||||
//TODO: GL_POLYGON_OFFSET_LINE
|
||||
cur->polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
|
||||
//TODO: GL_POLYGON_OFFSET_POINT
|
||||
//TODO: GL_POLYGON_SMOOTH
|
||||
//TODO: GL_POLYGON_STIPPLE
|
||||
cur->sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
cur->sample_alpha_to_one = glIsEnabled(GL_SAMPLE_ALPHA_TO_ONE);
|
||||
cur->sample_coverage = glIsEnabled(GL_SAMPLE_COVERAGE);
|
||||
cur->scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
cur->stencil_test = glIsEnabled(GL_STENCIL_TEST);
|
||||
cur->colormaterial = glIsEnabled(GL_COLOR_MATERIAL);
|
||||
int a;
|
||||
int old_tex=state.texture.active;
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
/*glActiveTexture(GL_TEXTURE0+a);*/
|
||||
cur->texture_2d[a] = state.enable.texture_2d[a];/*glIsEnabled(GL_TEXTURE_2D);*/
|
||||
cur->texture_1d[a] = state.enable.texture_1d[a];
|
||||
cur->texture_2d[a] = state.enable.texture_2d[a];
|
||||
cur->texture_3d[a] = state.enable.texture_3d[a];
|
||||
cur->texgen_s[a] = state.enable.texgen_s[a];
|
||||
cur->texgen_r[a] = state.enable.texgen_r[a];
|
||||
cur->texgen_t[a] = state.enable.texgen_t[a];
|
||||
}
|
||||
/*glActiveTexture(GL_TEXTURE0+old_tex);*/
|
||||
|
||||
}
|
||||
|
||||
// TODO: GL_EVAL_BIT
|
||||
@@ -168,6 +181,9 @@ void glPushAttrib(GLbitfield mask) {
|
||||
int i;
|
||||
for (i=0; i<8; i++)
|
||||
glGetFloatv(pixel_name[i], &cur->pixel_scale_bias[i]);
|
||||
//TODO: GL_DEPTH_BIAS & GL_DEPTH_SCALE (probably difficult)
|
||||
//TODO: GL_INDEX_OFFEST & GL_INDEX_SHIFT
|
||||
//TODO: GL_MAP_COLOR & GL_MAP_STENCIL (probably difficult too)
|
||||
glGetFloatv(GL_ZOOM_X, &cur->pixel_zoomx);
|
||||
glGetFloatv(GL_ZOOM_Y, &cur->pixel_zoomy);
|
||||
}
|
||||
@@ -186,14 +202,30 @@ void glPushAttrib(GLbitfield mask) {
|
||||
}
|
||||
|
||||
// TODO: GL_STENCIL_BUFFER_BIT
|
||||
if (mask & GL_STENCIL_BUFFER_BIT) {
|
||||
cur->stencil_test = glIsEnabled(GL_STENCIL_TEST);
|
||||
glGetIntegerv(GL_STENCIL_FUNC, &cur->stencil_func);
|
||||
glGetIntegerv(GL_STENCIL_VALUE_MASK, &cur->stencil_mask);
|
||||
glGetIntegerv(GL_STENCIL_REF, &cur->stencil_ref);
|
||||
//TODO: glStencilFuncSeperate
|
||||
|
||||
//TODO: Stencil value mask
|
||||
glGetIntegerv(GL_STENCIL_FAIL, &cur->stencil_sfail);
|
||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &cur->stencil_dpfail);
|
||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &cur->stencil_dppass);
|
||||
//TODO: glStencilOpSeparate
|
||||
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &cur->stencil_clearvalue);
|
||||
//TODO: Stencil buffer writemask
|
||||
}
|
||||
// GL_TEXTURE_BIT - TODO: incomplete
|
||||
if (mask & GL_TEXTURE_BIT) {
|
||||
cur->active=state.texture.active;
|
||||
int a;
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
//glActiveTexture(GL_TEXTURE0+a);
|
||||
//glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur->texture[a]);
|
||||
cur->texgen_r[a] = state.enable.texgen_r[a];
|
||||
cur->texgen_r[a] = state.enable.texgen_s[a];
|
||||
cur->texgen_r[a] = state.enable.texgen_t[a];
|
||||
cur->texture[a] = (state.texture.bound[a])?state.texture.bound[a]->texture:0;
|
||||
}
|
||||
//glActiveTexture(GL_TEXTURE0+cur->active);
|
||||
@@ -257,20 +289,6 @@ void glPushClientAttrib(GLbitfield mask) {
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
cur->tex_enable[a] = state.enable.tex_coord_array[a];
|
||||
}
|
||||
/*
|
||||
memcpy(&cur->verts, &state.pointers.vertex, sizeof(pointer_state_t));
|
||||
cur->ref_verts = (void*)state.pointers.vertex.pointer;
|
||||
memcpy(&cur->color, &state.pointers.color, sizeof(pointer_state_t));
|
||||
cur->ref_colors = (void*)state.pointers.color.pointer;
|
||||
memcpy(&cur->secondary, &state.pointers.secondary, sizeof(pointer_state_t));
|
||||
cur->ref_secondary = (void*)state.pointers.secondary.pointer;
|
||||
memcpy(&cur->normal, &state.pointers.normal, sizeof(pointer_state_t));
|
||||
cur->ref_normal = (void*)state.pointers.normal.pointer;
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
memcpy(&cur->tex[a], &state.pointers.tex_coord[a], sizeof(pointer_state_t));
|
||||
cur->ref_tex[a] = (void*)state.pointers.tex_coord[a].pointer;
|
||||
}
|
||||
*/
|
||||
memcpy(&(cur->pointers), &state.pointers, sizeof(pointer_states_t));
|
||||
cur->client = state.texture.client;
|
||||
}
|
||||
@@ -305,19 +323,15 @@ void glPopAttrib() {
|
||||
glstack_t *cur = stack + stack->len-1;
|
||||
|
||||
if (cur->mask & GL_COLOR_BUFFER_BIT) {
|
||||
#ifndef USE_ES2
|
||||
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
|
||||
glAlphaFunc(cur->alpha_test_func, cur->alpha_test_ref);
|
||||
#endif
|
||||
|
||||
enable_disable(GL_BLEND, cur->blend);
|
||||
glBlendFunc(cur->blend_src_func, cur->blend_dst_func);
|
||||
|
||||
enable_disable(GL_DITHER, cur->dither);
|
||||
#ifndef USE_ES2
|
||||
enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op);
|
||||
glLogicOp(cur->logic_op);
|
||||
#endif
|
||||
|
||||
GLfloat *c;
|
||||
glClearColor(v4(cur->clear_color));
|
||||
@@ -326,9 +340,7 @@ void glPopAttrib() {
|
||||
|
||||
if (cur->mask & GL_CURRENT_BIT) {
|
||||
glColor4f(v4(cur->color));
|
||||
#ifndef USE_ES2
|
||||
glNormal3f(v3(cur->normal));
|
||||
#endif
|
||||
glTexCoord2f(v2(cur->tex));
|
||||
}
|
||||
|
||||
@@ -341,50 +353,71 @@ void glPopAttrib() {
|
||||
|
||||
if (cur->mask & GL_ENABLE_BIT) {
|
||||
int i;
|
||||
|
||||
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
|
||||
enable_disable(GL_AUTO_NORMAL, cur->autonormal);
|
||||
enable_disable(GL_BLEND, cur->blend);
|
||||
|
||||
GLint max_clip_planes;
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
|
||||
for (i = 0; i < max_clip_planes; i++) {
|
||||
enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i));
|
||||
}
|
||||
|
||||
enable_disable(GL_COLOR_MATERIAL, cur->colormaterial);
|
||||
enable_disable(GL_CULL_FACE, cur->cull_face);
|
||||
enable_disable(GL_DEPTH_TEST, cur->depth_test);
|
||||
enable_disable(GL_DITHER, cur->dither);
|
||||
enable_disable(GL_FOG, cur->fog);
|
||||
|
||||
GLint max_lights;
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
|
||||
for (i = 0; i < max_lights; i++) {
|
||||
enable_disable(GL_LIGHT0 + i, *(cur->lights_enabled + i));
|
||||
}
|
||||
|
||||
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
|
||||
enable_disable(GL_BLEND, cur->blend);
|
||||
enable_disable(GL_CULL_FACE, cur->cull_face);
|
||||
enable_disable(GL_DEPTH_TEST, cur->depth_test);
|
||||
enable_disable(GL_DITHER, cur->dither);
|
||||
enable_disable(GL_FOG, cur->fog);
|
||||
enable_disable(GL_LIGHTING, cur->lighting);
|
||||
enable_disable(GL_LINE_SMOOTH, cur->line_smooth);
|
||||
enable_disable(GL_LINE_STIPPLE, cur->line_stipple);
|
||||
enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op);
|
||||
//TODO: GL_INDEX_LOGIC_OP
|
||||
//TODO: GL_MAP1_x
|
||||
//TODO: GL_MAP2_x
|
||||
enable_disable(GL_MULTISAMPLE, cur->multisample);
|
||||
enable_disable(GL_NORMALIZE, cur->normalize);
|
||||
enable_disable(GL_POINT_SMOOTH, cur->point_smooth);
|
||||
//TODO: GL_POLYGON_OFFSET_LINE
|
||||
enable_disable(GL_POLYGON_OFFSET_FILL, cur->polygon_offset_fill);
|
||||
//TODO: GL_POLYGON_OFFSET_POINT
|
||||
//TODO: GL_POLYGON_SMOOTH
|
||||
//TODO: GL_POLYGON_STIPPLE
|
||||
enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage);
|
||||
enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one);
|
||||
enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage);
|
||||
enable_disable(GL_SCISSOR_TEST, cur->scissor_test);
|
||||
enable_disable(GL_STENCIL_TEST, cur->stencil_test);
|
||||
enable_disable(GL_COLOR_MATERIAL, cur->colormaterial);
|
||||
int a;
|
||||
int old_tex = state.texture.active;
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
if (state.enable.texture_1d[a] != cur->texture_1d[a]) {
|
||||
glActiveTexture(GL_TEXTURE0+a);
|
||||
enable_disable(GL_TEXTURE_1D, cur->texture_1d[a]);
|
||||
}
|
||||
if (state.enable.texture_2d[a] != cur->texture_2d[a]) {
|
||||
glActiveTexture(GL_TEXTURE0+a);
|
||||
enable_disable(GL_TEXTURE_2D, cur->texture_2d[a]);
|
||||
}
|
||||
if (state.enable.texture_3d[a] != cur->texture_3d[a]) {
|
||||
glActiveTexture(GL_TEXTURE0+a);
|
||||
enable_disable(GL_TEXTURE_3D, cur->texture_3d[a]);
|
||||
}
|
||||
state.enable.texgen_r[a] = cur->texgen_r[a];
|
||||
state.enable.texgen_s[a] = cur->texgen_s[a];
|
||||
state.enable.texgen_t[a] = cur->texgen_t[a];
|
||||
}
|
||||
if (state.texture.active != old_tex) glActiveTexture(GL_TEXTURE0+old_tex);
|
||||
}
|
||||
|
||||
#ifndef USE_ES2
|
||||
if (cur->mask & GL_FOG_BIT) {
|
||||
enable_disable(GL_FOG, cur->fog);
|
||||
glFogfv(GL_FOG_COLOR, cur->fog_color);
|
||||
@@ -393,7 +426,6 @@ void glPopAttrib() {
|
||||
glFogf(GL_FOG_END, cur->fog_end);
|
||||
glFogf(GL_FOG_MODE, cur->fog_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cur->mask & GL_HINT_BIT) {
|
||||
enable_disable(GL_PERSPECTIVE_CORRECTION_HINT, cur->perspective_hint);
|
||||
@@ -420,21 +452,32 @@ void glPopAttrib() {
|
||||
enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage);
|
||||
}
|
||||
|
||||
#ifndef USE_ES2
|
||||
if (cur->mask & GL_POINT_BIT) {
|
||||
enable_disable(GL_POINT_SMOOTH, cur->point_smooth);
|
||||
glPointSize(cur->point_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cur->mask & GL_SCISSOR_BIT) {
|
||||
enable_disable(GL_SCISSOR_TEST, cur->scissor_test);
|
||||
glScissor(v4(cur->scissor_box));
|
||||
}
|
||||
|
||||
if (cur->mask & GL_STENCIL_BUFFER_BIT) {
|
||||
enable_disable(GL_STENCIL_TEST, cur->stencil_test);
|
||||
glStencilFunc(cur->stencil_func, cur->stencil_ref, cur->stencil_mask);
|
||||
//TODO: Stencil value mask
|
||||
glStencilOp(cur->stencil_sfail, cur->stencil_dpfail, cur->stencil_dppass);
|
||||
glClearStencil(cur->stencil_clearvalue);
|
||||
//TODO: Stencil buffer writemask
|
||||
}
|
||||
|
||||
if (cur->mask & GL_TEXTURE_BIT) {
|
||||
int a;
|
||||
//TODO: Enable bit for the 4 texture coordinates
|
||||
for (a=0; a<MAX_TEX; a++) {
|
||||
state.enable.texgen_r[a] = cur->texgen_r[a];
|
||||
state.enable.texgen_s[a] = cur->texgen_s[a];
|
||||
state.enable.texgen_t[a] = cur->texgen_t[a];
|
||||
if ((cur->texture[a]==0 && state.texture.bound[a] != 0) || (cur->texture[a]!=0 && state.texture.bound[a]==0)) {
|
||||
glActiveTexture(GL_TEXTURE0+a);
|
||||
glBindTexture(GL_TEXTURE_2D, cur->texture[a]);
|
||||
@@ -442,11 +485,15 @@ void glPopAttrib() {
|
||||
}
|
||||
if (state.texture.active!= cur->active) glActiveTexture(GL_TEXTURE0+cur->active);
|
||||
}
|
||||
|
||||
if (cur->mask & GL_PIXEL_MODE_BIT) {
|
||||
GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE};
|
||||
int i;
|
||||
for (i=0; i<8; i++)
|
||||
glPixelTransferf(pixel_name[i], cur->pixel_scale_bias[i]);
|
||||
//TODO: GL_DEPTH_BIAS & GL_DEPTH_SCALE (probably difficult)
|
||||
//TODO: GL_INDEX_OFFEST & GL_INDEX_SHIFT
|
||||
//TODO: GL_MAP_COLOR & GL_MAP_STENCIL (probably difficult too)
|
||||
glPixelZoom(cur->pixel_zoomx, cur->pixel_zoomy);
|
||||
}
|
||||
|
||||
@@ -521,32 +568,6 @@ void glPopClientAttrib() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (state.pointers.vertex.pointer != cur->ref_verts) {
|
||||
memcpy(&state.pointers.vertex, &cur->pointers.verts, sizeof(pointer_state_t));
|
||||
//if (state.pointers.vertex.pointer) gles_glVertexPointer(state.pointers.vertex.size, state.pointers.vertex.type, state.pointers.vertex.stride, state.pointers.vertex.pointer);
|
||||
}
|
||||
if (state.pointers.color.pointer != cur->ref_colors) {
|
||||
memcpy(&state.pointers.color, &cur->color, sizeof(pointer_state_t));
|
||||
//if (state.pointers.color.pointer) gles_glColorPointer(state.pointers.color.size, state.pointers.color.type, state.pointers.color.stride, state.pointers.color.pointer);
|
||||
}
|
||||
if (state.pointers.secondary.pointer != cur->ref_secondary) {
|
||||
memcpy(&state.pointers.secondary, &cur->secondary, sizeof(pointer_state_t));
|
||||
}
|
||||
if (state.pointers.normal.pointer != cur->ref_normal) {
|
||||
memcpy(&state.pointers.normal, &cur->normal, sizeof(pointer_state_t));
|
||||
//if (state.pointers.normal.pointer) gles_glNormalPointer(state.pointers.normal.type, state.pointers.normal.stride, state.pointers.normal.pointer);
|
||||
}
|
||||
for (int a=0; a<MAX_TEX; a++) {
|
||||
if (state.pointers.tex_coord[a].pointer != cur->ref_tex[a]) {
|
||||
memcpy(&state.pointers.tex_coord[a], &cur->tex[a], sizeof(pointer_state_t));
|
||||
//if (state.pointers.tex_coord[a].pointer) {
|
||||
// glClientActiveTexture(GL_TEXTURE0+a);
|
||||
// gles_glTexCoordPointer(state.pointers.tex_coord[a].size, state.pointers.tex_coord[a].type, state.pointers.tex_coord[a].stride, state.pointers.tex_coord[a].pointer);
|
||||
//}
|
||||
}
|
||||
}
|
||||
*/
|
||||
memcpy(&state.pointers, &(cur->pointers), sizeof(pointer_states_t));
|
||||
if (state.texture.client != cur->client) glClientActiveTexture(GL_TEXTURE0+cur->client);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,14 @@ typedef struct {
|
||||
GLboolean normalize;
|
||||
GLboolean polygon_offset_fill;
|
||||
GLboolean stencil_test;
|
||||
GLboolean texture_1d[MAX_TEX];
|
||||
GLboolean texture_2d[MAX_TEX];
|
||||
GLboolean texture_3d[MAX_TEX];
|
||||
GLboolean texgen_s[MAX_TEX];
|
||||
GLboolean texgen_r[MAX_TEX];
|
||||
GLboolean texgen_t[MAX_TEX];
|
||||
GLboolean colormaterial;
|
||||
GLboolean autonormal;
|
||||
|
||||
// GL_FOG_BIT
|
||||
GLboolean fog;
|
||||
@@ -101,7 +107,14 @@ typedef struct {
|
||||
GLboolean scissor_test;
|
||||
GLfloat scissor_box[4];
|
||||
|
||||
// TODO: GL_STENCIL_BUFFER_BIT
|
||||
// GL_STENCIL_BUFFER_BIT
|
||||
GLenum stencil_func;
|
||||
GLint stencil_ref;
|
||||
GLuint stencil_mask;
|
||||
GLint stencil_clearvalue;
|
||||
GLenum stencil_sfail;
|
||||
GLenum stencil_dpfail;
|
||||
GLenum stencil_dppass;
|
||||
|
||||
// GL_TEXTURE_BIT
|
||||
GLint texture[MAX_TEX];
|
||||
|
||||
@@ -283,6 +283,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
|
||||
alphahack = 1;
|
||||
printf("LIBGL: Alpha Hack enabled\n");
|
||||
}
|
||||
#ifdef TEXSTREAM
|
||||
char *env_stream = getenv("LIBGL_STREAM");
|
||||
if (env_stream && strcmp(env_stream, "1") == 0) {
|
||||
texstream = InitStreamingCache();
|
||||
@@ -294,6 +295,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
|
||||
printf("LIBGL: Streaming texture %s\n",(texstream)?"forced":"not available");
|
||||
//FreeStreamed(AddStreamed(1024, 512, 0));
|
||||
}
|
||||
#endif
|
||||
char *env_copy = getenv("LIBGL_COPY");
|
||||
if (env_copy && strcmp(env_copy, "1") == 0) {
|
||||
printf("LIBGL: No glCopyTexImage2D / glCopyTexSubImage2D hack\n");
|
||||
@@ -434,6 +436,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef TEXSTREAM
|
||||
if (texstream && bound && (target==GL_TEXTURE_2D) && (width>=256 && height>=256) &&
|
||||
((internalformat==GL_RGB) || (internalformat==3) || (internalformat==GL_RGB8) || (internalformat==GL_BGR) || (internalformat==GL_RGB5)) || (texstream==2) ) {
|
||||
bound->streamingID = AddStreamed(width, height, bound->texture);
|
||||
@@ -452,6 +455,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
|
||||
gles_glEnable(GL_TEXTURE_STREAM_IMG);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (bound) {
|
||||
bound->shrink = 0;
|
||||
if (!bound->streamed)
|
||||
@@ -612,6 +616,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
}
|
||||
|
||||
GLvoid *old = pixels;
|
||||
#ifdef TEXSTREAM
|
||||
if (bound && texstream && (bound->streamed)) {
|
||||
// Optimisation, let's do convert directly to the right place...
|
||||
GLvoid *tmp = GetStreamingBuffer(bound->streamingID);
|
||||
@@ -623,7 +628,9 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
}
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
//pixels = (GLvoid *)swizzle_texture(width, height, &format, &type, old);
|
||||
if (!pixel_convert(old, &pixels, width, height, format, type, bound->format, bound->type, 0)) {
|
||||
printf("LIBGL: Error in pixel_convert while glTexSubImage2D\n");
|
||||
@@ -880,6 +887,7 @@ tex_changed=1; // seems buggy, temporary disabling that...
|
||||
if (tex_changed) {
|
||||
|
||||
GLboolean tmp = state.enable.texture_2d[state.texture.active];
|
||||
#ifdef TEXSTREAM
|
||||
if (texstream) { // unbind streaming texture if any...
|
||||
gltexture_t *bound = state.texture.bound[state.texture.active];
|
||||
if (bound && bound->streamed) {
|
||||
@@ -890,6 +898,7 @@ tex_changed=1; // seems buggy, temporary disabling that...
|
||||
gles_glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
state.texture.rect_arb[state.texture.active] = (target == GL_TEXTURE_RECTANGLE_ARB);
|
||||
target = map_tex_target(target);
|
||||
@@ -897,13 +906,16 @@ tex_changed=1; // seems buggy, temporary disabling that...
|
||||
state.texture.bound[state.texture.active] = tex;
|
||||
|
||||
LOAD_GLES(glBindTexture);
|
||||
#ifdef TEXSTREAM
|
||||
if (texstream && (streamingID>-1)) {
|
||||
if (tmp)
|
||||
gles_glDisable(GL_TEXTURE_2D);
|
||||
ActivateStreaming(streamingID);
|
||||
if (tmp)
|
||||
gles_glEnable(GL_TEXTURE_STREAM_IMG);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
gles_glBindTexture(target, texture);
|
||||
errorGL();
|
||||
}
|
||||
@@ -995,8 +1007,10 @@ void glDeleteTextures(GLsizei n, const GLuint *textures) {
|
||||
}
|
||||
gles_glDeleteTextures(1, &tex->glname);
|
||||
errorGL();
|
||||
#ifdef TEXSTREAM
|
||||
if (texstream && tex->streamed)
|
||||
FreeStreamed(tex->streamingID);
|
||||
#endif
|
||||
#if 1
|
||||
kh_del(tex, list, k);
|
||||
if (tex->data) free(tex->data);
|
||||
@@ -1153,14 +1167,14 @@ void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoi
|
||||
GLvoid *dst = img;
|
||||
if (state.buffers.pack)
|
||||
dst += (uintptr_t)state.buffers.pack->data;
|
||||
|
||||
#ifdef TEXSTREAM
|
||||
if (texstream && bound->streamed) {
|
||||
noerrorShim();
|
||||
pixel_convert(GetStreamingBuffer(bound->streamingID), &dst, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format, type, 0);
|
||||
readfboEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (texcopydata && bound->data) {
|
||||
errorShim(GL_INVALID_ENUM);
|
||||
if (!pixel_convert(bound->data, &dst, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0))
|
||||
@@ -1284,6 +1298,7 @@ void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffse
|
||||
state.gl_batch = old_glbatch;
|
||||
return;
|
||||
}
|
||||
#ifdef TEXSTREAM
|
||||
if (bound && bound->streamed) {
|
||||
void* buff = GetStreamingBuffer(bound->streamingID);
|
||||
if ((bound->width == width) && (bound->height == height) && (xoffset == yoffset == 0)) {
|
||||
@@ -1296,7 +1311,9 @@ void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffse
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (copytex) {
|
||||
gles_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||
} else {
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#ifdef PANDORA
|
||||
#include <linux/fb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "glx.h"
|
||||
@@ -18,8 +20,10 @@ bool eglInitialized = false;
|
||||
EGLDisplay eglDisplay;
|
||||
EGLSurface eglSurface;
|
||||
EGLConfig eglConfigs[1];
|
||||
#ifdef PANDORA
|
||||
struct sockaddr_un sun;
|
||||
int sock = -2;
|
||||
#endif
|
||||
|
||||
void* egl = NULL;
|
||||
|
||||
@@ -139,13 +143,16 @@ static GLXContext fbContext = NULL;
|
||||
|
||||
static int fbcontext_count = 0;
|
||||
|
||||
#ifdef PANDORA
|
||||
#ifndef FBIO_WAITFORVSYNC
|
||||
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
|
||||
#endif
|
||||
static int fbdev = -1;
|
||||
static bool g_vsync = false;
|
||||
#endif
|
||||
static bool g_showfps = false;
|
||||
static bool g_usefb = false;
|
||||
static bool g_usefbo = false;
|
||||
static bool g_vsync = false;
|
||||
static bool g_xrefresh = false;
|
||||
static bool g_stacktrace = false;
|
||||
static bool g_bcm_active = false;
|
||||
@@ -156,7 +163,6 @@ static bool g_bcmhost = false;
|
||||
static bool g_bcmhost = true;
|
||||
#endif
|
||||
|
||||
static int fbdev = -1;
|
||||
static int swap_interval = 1;
|
||||
#ifndef ANDROID
|
||||
static void init_display(Display *display) {
|
||||
@@ -173,10 +179,12 @@ static void init_display(Display *display) {
|
||||
}
|
||||
#endif //ANDROID
|
||||
static void init_vsync() {
|
||||
#ifdef PANDORA
|
||||
fbdev = open("/dev/fb0", O_RDONLY);
|
||||
if (fbdev < 0) {
|
||||
fprintf(stderr, "Could not open /dev/fb0 for vsync.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void xrefresh() {
|
||||
@@ -215,7 +223,7 @@ static void signal_handler(int sig) {
|
||||
signal(sig, SIG_DFL);
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
#ifdef PANDORA
|
||||
static void init_liveinfo() {
|
||||
static const char socket_name[] = "\0liveinfo";
|
||||
sock = socket(PF_UNIX, SOCK_DGRAM, 0);
|
||||
@@ -236,6 +244,7 @@ static void init_liveinfo() {
|
||||
} else
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
#endif
|
||||
extern void initialize_glshim();
|
||||
static void scan_env() {
|
||||
static bool first = true;
|
||||
@@ -284,10 +293,8 @@ static void scan_env() {
|
||||
g_usefbo = true;
|
||||
}
|
||||
env(LIBGL_FPS, g_showfps, "fps counter enabled");
|
||||
#ifdef PANDORA
|
||||
env(LIBGL_VSYNC, g_vsync, "vsync enabled");
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof(cwd))!= NULL)
|
||||
printf("LIBGL: Current folder is:%s\n", cwd);
|
||||
if (g_vsync) {
|
||||
init_vsync();
|
||||
}
|
||||
@@ -295,6 +302,10 @@ static void scan_env() {
|
||||
if (sock>-1) {
|
||||
printf("LIBGL: LiveInfo detected, fps will be shown\n");
|
||||
}
|
||||
#endif
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof(cwd))!= NULL)
|
||||
printf("LIBGL: Current folder is:%s\n", cwd);
|
||||
}
|
||||
#ifndef ANDROID
|
||||
GLXContext glXCreateContext(Display *display,
|
||||
@@ -606,7 +617,7 @@ void glXSwapBuffers(Display *display,
|
||||
if (gl_batch){
|
||||
flush();
|
||||
}
|
||||
|
||||
#ifdef PANDORA
|
||||
if (g_vsync && fbdev >= 0) {
|
||||
// TODO: can I just return if I don't meet vsync over multiple frames?
|
||||
// this will just block otherwise.
|
||||
@@ -615,6 +626,7 @@ void glXSwapBuffers(Display *display,
|
||||
ioctl(fbdev, FBIO_WAITFORVSYNC, &arg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (g_usefbo) {
|
||||
unbindMainFBO();
|
||||
blitMainFBO();
|
||||
@@ -623,7 +635,7 @@ void glXSwapBuffers(Display *display,
|
||||
|
||||
egl_eglSwapBuffers(eglDisplay, eglSurface);
|
||||
CheckEGLErrors();
|
||||
|
||||
#ifdef PANDORA
|
||||
if (g_showfps || (sock>-1)) {
|
||||
// framerate counter
|
||||
static float avg, fps = 0;
|
||||
@@ -658,7 +670,7 @@ void glXSwapBuffers(Display *display,
|
||||
}
|
||||
last_frame = now;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (g_usefbo)
|
||||
bindMainFBO();
|
||||
}
|
||||
@@ -773,9 +785,14 @@ GLXContext glXCreateNewContext(Display *display, GLXFBConfig config,
|
||||
#endif //ANDROID
|
||||
void glXSwapIntervalMESA(int interval) {
|
||||
printf("glXSwapInterval(%i)\n", interval);
|
||||
#ifdef PANDORA
|
||||
if (! g_vsync)
|
||||
printf("Enable LIBGL_VSYNC=1 if you want to use vsync.\n");
|
||||
swap_interval = interval;
|
||||
#else
|
||||
LOAD_EGL(eglSwapInterval);
|
||||
egl_eglSwapInterval(eglDisplay, swap_interval);
|
||||
#endif
|
||||
}
|
||||
|
||||
void glXSwapIntervalSGI(int interval) {
|
||||
@@ -959,4 +976,4 @@ int glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif //ANDROID
|
||||
#endif //ANDROID
|
||||
|
||||
@@ -286,18 +286,20 @@ void *glXGetProcAddressARB(const char *name) {
|
||||
ARB(glBlendColor);*/
|
||||
EXT(glBlendEquation);
|
||||
ARB(glBlendEquation);
|
||||
EXT(glBlendFunc);
|
||||
ARB(glBlendFunc);
|
||||
#ifndef ODROID
|
||||
EXT(glBlendEquationSeparate);
|
||||
ARB(glBlendEquationSeparate);
|
||||
EX(glBlendEquationSeparatei);
|
||||
EXT(glBlendEquationSeparatei);
|
||||
ARB(glBlendEquationSeparatei);
|
||||
EXT(glBlendFunc);
|
||||
ARB(glBlendFunc);
|
||||
EXT(glBlendFuncSeparate);
|
||||
ARB(glBlendFuncSeparate);
|
||||
EX(glBlendFuncSeparatei);
|
||||
EXT(glBlendFuncSeparatei);
|
||||
ARB(glBlendFuncSeparatei);
|
||||
#endif
|
||||
EX(glCallList);
|
||||
EX(glCallLists);
|
||||
EX(glClearDepth);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
Helper fonctions for Streaming textures
|
||||
*/
|
||||
#ifdef TEXSTREAM
|
||||
|
||||
#include <bc_cat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
@@ -287,3 +289,4 @@ void DeactivateStreaming() {
|
||||
return;
|
||||
// gles_glDisable(GL_TEXTURE_STREAM_IMG);
|
||||
}
|
||||
#endif //TEXSTREAM
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef STREAMING_H
|
||||
#define STREAMING_H
|
||||
|
||||
#ifdef TEXSTREAM
|
||||
|
||||
#include "../gl/gl.h"
|
||||
|
||||
@@ -41,5 +41,5 @@ void ApplyFilterID(int ID, GLenum min_filter, GLenum mag_filter);
|
||||
void ActivateStreaming(int ID);
|
||||
// Function to deactivate the Streaming texture on current tex...
|
||||
void DeactivateStreaming();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user