Search
lxdream.org :: lxdream :: r1210:79bbd30363f4
lxdream 0.9.1
released Jun 29
Download Now
changeset1210:79bbd30363f4
parent1209:e606e65eaf54
child1211:eecdeb37934a
authornkeynes
dateTue Feb 07 14:27:13 2012 +1000 (7 years ago)
Add wrangling for some of the core vs EXT/ARB versions of functions + macros
config.h.in
configure
configure.in
src/drivers/gl_fbo.c
src/pvr2/glutil.h
src/pvr2/texcache.c
1.1 --- a/config.h.in Tue Feb 07 11:59:07 2012 +1000
1.2 +++ b/config.h.in Tue Feb 07 14:27:13 2012 +1000
1.3 @@ -106,8 +106,11 @@
1.4 /* Have Color Clamp */
1.5 #undef HAVE_OPENGL_CLAMP_COLOR
1.6
1.7 +/* Have 2.0 framebuffer_object support */
1.8 +#undef HAVE_OPENGL_FBO
1.9 +
1.10 /* Have EXT_framebuffer_object support */
1.11 -#undef HAVE_OPENGL_FBO
1.12 +#undef HAVE_OPENGL_FBO_EXT
1.13
1.14 /* Have 2.0 shader support */
1.15 #undef HAVE_OPENGL_SHADER
2.1 --- a/configure Tue Feb 07 11:59:07 2012 +1000
2.2 +++ b/configure Tue Feb 07 14:27:13 2012 +1000
2.3 @@ -11258,6 +11258,95 @@
2.4 fi
2.5
2.6
2.7 +{ echo "$as_me:$LINENO: checking for glGenFramebuffers" >&5
2.8 +echo $ECHO_N "checking for glGenFramebuffers... $ECHO_C" >&6; }
2.9 +if test "${ac_cv_func_glGenFramebuffers+set}" = set; then
2.10 + echo $ECHO_N "(cached) $ECHO_C" >&6
2.11 +else
2.12 + cat >conftest.$ac_ext <<_ACEOF
2.13 +/* confdefs.h. */
2.14 +_ACEOF
2.15 +cat confdefs.h >>conftest.$ac_ext
2.16 +cat >>conftest.$ac_ext <<_ACEOF
2.17 +/* end confdefs.h. */
2.18 +/* Define glGenFramebuffers to an innocuous variant, in case <limits.h> declares glGenFramebuffers.
2.19 + For example, HP-UX 11i <limits.h> declares gettimeofday. */
2.20 +#define glGenFramebuffers innocuous_glGenFramebuffers
2.21 +
2.22 +/* System header to define __stub macros and hopefully few prototypes,
2.23 + which can conflict with char glGenFramebuffers (); below.
2.24 + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
2.25 + <limits.h> exists even on freestanding compilers. */
2.26 +
2.27 +#ifdef __STDC__
2.28 +# include <limits.h>
2.29 +#else
2.30 +# include <assert.h>
2.31 +#endif
2.32 +
2.33 +#undef glGenFramebuffers
2.34 +
2.35 +/* Override any GCC internal prototype to avoid an error.
2.36 + Use char because int might match the return type of a GCC
2.37 + builtin and then its argument prototype would still apply. */
2.38 +#ifdef __cplusplus
2.39 +extern "C"
2.40 +#endif
2.41 +char glGenFramebuffers ();
2.42 +/* The GNU C library defines this for functions which it implements
2.43 + to always fail with ENOSYS. Some functions are actually named
2.44 + something starting with __ and the normal name is an alias. */
2.45 +#if defined __stub_glGenFramebuffers || defined __stub___glGenFramebuffers
2.46 +choke me
2.47 +#endif
2.48 +
2.49 +int
2.50 +main ()
2.51 +{
2.52 +return glGenFramebuffers ();
2.53 + ;
2.54 + return 0;
2.55 +}
2.56 +_ACEOF
2.57 +rm -f conftest.$ac_objext conftest$ac_exeext
2.58 +if { (ac_try="$ac_link"
2.59 +case "(($ac_try" in
2.60 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2.61 + *) ac_try_echo=$ac_try;;
2.62 +esac
2.63 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
2.64 + (eval "$ac_link") 2>conftest.er1
2.65 + ac_status=$?
2.66 + grep -v '^ *+' conftest.er1 >conftest.err
2.67 + rm -f conftest.er1
2.68 + cat conftest.err >&5
2.69 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
2.70 + (exit $ac_status); } && {
2.71 + test -z "$ac_c_werror_flag" ||
2.72 + test ! -s conftest.err
2.73 + } && test -s conftest$ac_exeext &&
2.74 + $as_test_x conftest$ac_exeext; then
2.75 + ac_cv_func_glGenFramebuffers=yes
2.76 +else
2.77 + echo "$as_me: failed program was:" >&5
2.78 +sed 's/^/| /' conftest.$ac_ext >&5
2.79 +
2.80 + ac_cv_func_glGenFramebuffers=no
2.81 +fi
2.82 +
2.83 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
2.84 + conftest$ac_exeext conftest.$ac_ext
2.85 +fi
2.86 +{ echo "$as_me:$LINENO: result: $ac_cv_func_glGenFramebuffers" >&5
2.87 +echo "${ECHO_T}$ac_cv_func_glGenFramebuffers" >&6; }
2.88 +if test $ac_cv_func_glGenFramebuffers = yes; then
2.89 +
2.90 +cat >>confdefs.h <<\_ACEOF
2.91 +#define HAVE_OPENGL_FBO 1
2.92 +_ACEOF
2.93 +
2.94 +fi
2.95 +
2.96 { echo "$as_me:$LINENO: checking for glGenFramebuffersEXT" >&5
2.97 echo $ECHO_N "checking for glGenFramebuffersEXT... $ECHO_C" >&6; }
2.98 if test "${ac_cv_func_glGenFramebuffersEXT+set}" = set; then
2.99 @@ -11342,7 +11431,7 @@
2.100 if test $ac_cv_func_glGenFramebuffersEXT = yes; then
2.101
2.102 cat >>confdefs.h <<\_ACEOF
2.103 -#define HAVE_OPENGL_FBO 1
2.104 +#define HAVE_OPENGL_FBO_EXT 1
2.105 _ACEOF
2.106
2.107 fi
3.1 --- a/configure.in Tue Feb 07 11:59:07 2012 +1000
3.2 +++ b/configure.in Tue Feb 07 14:27:13 2012 +1000
3.3 @@ -286,7 +286,8 @@
3.4 AM_CONDITIONAL(VIDEO_NSGL, [test "x$HAVE_NSGL" = "xyes"])
3.5
3.6 dnl Check for optional (but highly desireable) OpenGL features
3.7 -AC_CHECK_FUNC(glGenFramebuffersEXT, [ AC_DEFINE([HAVE_OPENGL_FBO],1,[Have EXT_framebuffer_object support]) ], [])
3.8 +AC_CHECK_FUNC(glGenFramebuffers, [ AC_DEFINE([HAVE_OPENGL_FBO],1,[Have 2.0 framebuffer_object support]) ], [])
3.9 +AC_CHECK_FUNC(glGenFramebuffersEXT, [ AC_DEFINE([HAVE_OPENGL_FBO_EXT],1,[Have EXT_framebuffer_object support]) ], [])
3.10 AC_CHECK_FUNC(glCreateShader, [ AC_DEFINE([HAVE_OPENGL_SHADER],1,[Have 2.0 shader support]) ], [])
3.11 AC_CHECK_FUNC(glCreateShaderObjectARB, [ AC_DEFINE([HAVE_OPENGL_SHADER_ARB],1,[Have ARB shader support]) ], [])
3.12 AC_CHECK_FUNC(glClampColorARB, [ AC_DEFINE([HAVE_OPENGL_CLAMP_COLOR],1,[Have Color Clamp]) ], [])
4.1 --- a/src/drivers/gl_fbo.c Tue Feb 07 11:59:07 2012 +1000
4.2 +++ b/src/drivers/gl_fbo.c Tue Feb 07 14:27:13 2012 +1000
4.3 @@ -30,7 +30,7 @@
4.4 #include "drivers/video_gl.h"
4.5 #include "pvr2/glutil.h"
4.6
4.7 -#ifdef HAVE_OPENGL_FBO
4.8 +#if defined(HAVE_OPENGL_FBO) || defined(HAVE_OPENGL_FBO_EXT)
4.9
4.10 #define MAX_FRAMEBUFFERS 2
4.11 #define MAX_TEXTURES_PER_FB 16
4.12 @@ -62,7 +62,7 @@
4.13 static gboolean gl_fbo_have_packed_stencil = FALSE;
4.14 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];
4.15
4.16 -#define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0_EXT+(n))
4.17 +#define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0+(n))
4.18 static int last_used_fbo;
4.19
4.20 gboolean gl_fbo_is_supported()
4.21 @@ -80,9 +80,9 @@
4.22 GLuint fbids[MAX_FRAMEBUFFERS];
4.23 GLuint rbids[MAX_FRAMEBUFFERS*2]; /* depth buffer, stencil buffer per fb */
4.24
4.25 - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &gl_fbo_max_attachments);
4.26 - glGenFramebuffersEXT( MAX_FRAMEBUFFERS, &fbids[0] );
4.27 - glGenRenderbuffersEXT( MAX_FRAMEBUFFERS*2, &rbids[0] );
4.28 + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &gl_fbo_max_attachments);
4.29 + glGenFramebuffers( MAX_FRAMEBUFFERS, &fbids[0] );
4.30 + glGenRenderbuffers( MAX_FRAMEBUFFERS*2, &rbids[0] );
4.31 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
4.32 fbo[i].fb_id = fbids[i];
4.33 fbo[i].depth_id = rbids[i*2];
4.34 @@ -114,28 +114,28 @@
4.35 driver->read_render_buffer = gl_fbo_read_render_buffer;
4.36
4.37 gl_fbo_test_framebuffer();
4.38 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
4.39 + glBindFramebuffer(GL_FRAMEBUFFER, 0);
4.40 }
4.41
4.42 void gl_fbo_shutdown()
4.43 {
4.44 int i;
4.45 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
4.46 + glBindFramebuffer( GL_FRAMEBUFFER, 0 );
4.47 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
4.48 - glDeleteFramebuffersEXT( 1, &fbo[i].fb_id );
4.49 - glDeleteRenderbuffersEXT( 2, &fbo[i].depth_id );
4.50 + glDeleteFramebuffers( 1, &fbo[i].fb_id );
4.51 + glDeleteRenderbuffers( 2, &fbo[i].depth_id );
4.52 }
4.53 }
4.54
4.55 static void gl_fbo_setup_framebuffer( int bufno, int width, int height )
4.56 {
4.57 int i;
4.58 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id);
4.59 + glBindFramebuffer(GL_FRAMEBUFFER, fbo[bufno].fb_id);
4.60
4.61 /* Clear out any existing texture attachments */
4.62 for( i=0; i<gl_fbo_max_attachments; i++ ) {
4.63 if( fbo[bufno].tex_ids[i] != -1 ) {
4.64 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(i),
4.65 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(i),
4.66 GL_TEXTURE_RECTANGLE_ARB, 0, 0);
4.67 fbo[bufno].tex_ids[i] = -1;
4.68 }
4.69 @@ -143,17 +143,17 @@
4.70
4.71 /* Setup the renderbuffers */
4.72 if( gl_fbo_have_packed_stencil ) {
4.73 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
4.74 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);
4.75 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
4.76 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
4.77 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
4.78 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
4.79 + glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
4.80 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_EXT, width, height);
4.81 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
4.82 + GL_RENDERBUFFER, fbo[bufno].depth_id);
4.83 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
4.84 + GL_RENDERBUFFER, fbo[bufno].depth_id);
4.85 } else {
4.86 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
4.87 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
4.88 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
4.89 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
4.90 + glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
4.91 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
4.92 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
4.93 + GL_RENDERBUFFER, fbo[bufno].depth_id);
4.94 /* In theory you could attach a separate stencil buffer. In practice this
4.95 * isn't actually supported by any hardware I've had access to, so we're
4.96 * stencil-less.
4.97 @@ -183,7 +183,7 @@
4.98 last_used_fbo = bufno;
4.99 }
4.100 if( fbo[bufno].width == width && fbo[bufno].height == height ) {
4.101 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id );
4.102 + glBindFramebuffer( GL_FRAMEBUFFER, fbo[bufno].fb_id );
4.103 } else {
4.104 gl_fbo_setup_framebuffer( bufno, width, height );
4.105 }
4.106 @@ -210,7 +210,7 @@
4.107 }
4.108 fbo[fbo_no].tex_ids[attach] = tex_id;
4.109 glBindTexture( GL_TEXTURE_RECTANGLE_ARB, 0 ); // Ensure the output texture is unbound
4.110 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(attach),
4.111 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(attach),
4.112 GL_TEXTURE_RECTANGLE_ARB, tex_id, 0 );
4.113 /* Set draw/read buffers by default */
4.114 glDrawBuffer(ATTACHMENT_POINT(attach));
4.115 @@ -226,8 +226,8 @@
4.116 render_buffer_t buffer = gl_fbo_create_render_buffer( 640, 480, 0 );
4.117 gl_fbo_set_render_target(buffer);
4.118
4.119 - GLint status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
4.120 - if( status != GL_FRAMEBUFFER_COMPLETE_EXT ) {
4.121 + GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
4.122 + if( status != GL_FRAMEBUFFER_COMPLETE ) {
4.123 ERROR( "Framebuffer failure: %x", status );
4.124 result = FALSE;
4.125 }
4.126 @@ -274,8 +274,8 @@
4.127 if( fbo[i].width == buffer->width && fbo[i].height == buffer->height ) {
4.128 for( j=0; j<gl_fbo_max_attachments; j++ ) {
4.129 if( fbo[i].tex_ids[j] == buffer->buf_id ) {
4.130 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[i].fb_id);
4.131 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(j),
4.132 + glBindFramebuffer(GL_FRAMEBUFFER, fbo[i].fb_id);
4.133 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(j),
4.134 GL_TEXTURE_RECTANGLE_ARB, GL_NONE, 0 );
4.135 fbo[i].tex_ids[j] = -1;
4.136 return;
4.137 @@ -343,7 +343,7 @@
4.138
4.139 void gl_fbo_detach()
4.140 {
4.141 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
4.142 + glBindFramebuffer( GL_FRAMEBUFFER, 0 );
4.143 /* Make sure texture attachment is not a current draw/read buffer */
4.144 glDrawBuffer( GL_FRONT );
4.145 glReadBuffer( GL_FRONT );
5.1 --- a/src/pvr2/glutil.h Tue Feb 07 11:59:07 2012 +1000
5.2 +++ b/src/pvr2/glutil.h Tue Feb 07 14:27:13 2012 +1000
5.3 @@ -57,7 +57,51 @@
5.4
5.5 /****** Extension variant wrangling *****/
5.6
5.7 +#if defined(GL_MIRRORED_REPEAT_ARB) && !defined(GL_MIRRORED_REPEAT)
5.8 +#define GL_MIRRORED_REPEAT GL_MIRRORED_REPEAT_ARB
5.9 +#endif
5.10
5.11 +#if defined(GL_FRAMEBUFFER_EXT) && !defined(GL_FRAMEBUFFER)
5.12 +#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
5.13 +#endif
5.14 +
5.15 +#if defined(GL_RENDERBUFFER_EXT) && !defined(GL_RENDERBUFFER)
5.16 +#define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
5.17 +#endif
5.18 +
5.19 +#if defined(GL_COLOR_ATTACHMENT0_EXT) && !defined(GL_COLOR_ATTACHMENT0)
5.20 +#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
5.21 +#endif
5.22 +
5.23 +#if defined(GL_MAX_COLOR_ATTACHMENTS_EXT) && !defined(GL_MAX_COLOR_ATTACHMENTS)
5.24 +#define GL_MAX_COLOR_ATTACHMENTS GL_MAX_COLOR_ATTACHMENTS_EXT
5.25 +#endif
5.26 +
5.27 +#if defined(GL_STENCIL_ATTACHMENT_EXT) && !defined(GL_STENCIL_ATTACHMENT)
5.28 +#define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
5.29 +#endif
5.30 +
5.31 +#if defined(GL_DEPTH_ATTACHMENT_EXT) && !defined(GL_DEPTH_ATTACHMENT)
5.32 +#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
5.33 +#endif
5.34 +
5.35 +#if defined(GL_FRAMEBUFFER_COMPLETE_EXT) && !defined(GL_FRAMEBUFFER_COMPLETE)
5.36 +#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
5.37 +#endif
5.38 +
5.39 +#if defined(HAVE_OPENGL_FBO_EXT) && !defined(HAVE_OPENGL_FBO)
5.40 +#define glGenFramebuffers glGenFramebuffersEXT
5.41 +#define glGenRenderbuffers glGenRenderbuffersEXT
5.42 +#define glBindFramebuffer glBindFramebufferEXT
5.43 +#define glDeleteFramebuffers glDeleteFramebuffersEXT
5.44 +#define glDeleteRenderbuffers glDeleteRenderbuffersEXT
5.45 +#define glBindFramebuffer glBindFramebufferEXT
5.46 +#define glBindRenderbuffer glBindRenderbufferEXT
5.47 +#define glRenderbufferStorage glRenderbufferStorageEXT
5.48 +#define glFramebufferRenderbuffer glFramebufferRenderbufferEXT
5.49 +#define glFramebufferTexture2D glFramebufferTexture2DEXT
5.50 +#define glCheckFramebufferStatus glCheckFramebufferStatusEXT
5.51 +#endif
5.52
5.53
5.54 /****** Shader handling (gl_sl.c) *****/
6.1 --- a/src/pvr2/texcache.c Tue Feb 07 11:59:07 2012 +1000
6.2 +++ b/src/pvr2/texcache.c Tue Feb 07 14:27:13 2012 +1000
6.3 @@ -790,16 +790,16 @@
6.4
6.5 /* Set texture parameters from the poly2 word */
6.6 if( POLY2_TEX_CLAMP_U(poly2_word) ) {
6.7 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
6.8 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
6.9 } else if( POLY2_TEX_MIRROR_U(poly2_word) ) {
6.10 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT_ARB );
6.11 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT );
6.12 } else {
6.13 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
6.14 }
6.15 if( POLY2_TEX_CLAMP_V(poly2_word) ) {
6.16 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
6.17 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
6.18 } else if( POLY2_TEX_MIRROR_V(poly2_word) ) {
6.19 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT_ARB );
6.20 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT );
6.21 } else {
6.22 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
6.23 }
.