summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/glsink/ARB_multitexture.h309
-rw-r--r--sys/glsink/EXT_paletted_texture.h142
-rw-r--r--sys/glsink/NV_register_combiners.h218
-rw-r--r--sys/glsink/gstgl_nvimage.c256
-rw-r--r--sys/glsink/gstgl_rgbimage.c12
-rw-r--r--sys/glsink/gstglsink.c33
-rw-r--r--sys/glsink/gstglsink.h4
-rw-r--r--sys/glsink/gstglxwindow.c11
-rw-r--r--sys/glsink/regcomb_yuvrgb.c349
9 files changed, 1200 insertions, 134 deletions
diff --git a/sys/glsink/ARB_multitexture.h b/sys/glsink/ARB_multitexture.h
new file mode 100644
index 00000000..92fc44b4
--- /dev/null
+++ b/sys/glsink/ARB_multitexture.h
@@ -0,0 +1,309 @@
+/*************************************************************
+ * *
+ * file : ARB_multitexture.h *
+ * author: Jens Schneider *
+ * date : 01.Mar.2001-10.Jul.2001 *
+ * e-mail: jens@glHint.de *
+ * *
+ * version 1.0ß *
+ * *
+ *************************************************************/
+
+#ifndef __ARB_MULTITEXTURE_H_
+#define __ARB_MULTITEXTURE_H_
+
+/*
+ * GLOBAL SWITCHES - enable/disable advanced features of this header
+ *
+ */
+#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines
+#ifndef _WIN32
+#define GL_GLEXT_PROTOTYPES 1
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+
+// Header file version number, required by OpenGL ABI for Linux
+#define GL_GLEXT_VERSION 7
+
+
+/*
+ * NEW TOKENS TO OPENGL 1.2.1
+ *
+ */
+#ifndef GL_ARB_multitexture
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_TEXTURE4_ARB 0x84C4
+#define GL_TEXTURE5_ARB 0x84C5
+#define GL_TEXTURE6_ARB 0x84C6
+#define GL_TEXTURE7_ARB 0x84C7
+#define GL_TEXTURE8_ARB 0x84C8
+#define GL_TEXTURE9_ARB 0x84C9
+#define GL_TEXTURE10_ARB 0x84CA
+#define GL_TEXTURE11_ARB 0x84CB
+#define GL_TEXTURE12_ARB 0x84CC
+#define GL_TEXTURE13_ARB 0x84CD
+#define GL_TEXTURE14_ARB 0x84CE
+#define GL_TEXTURE15_ARB 0x84CF
+#define GL_TEXTURE16_ARB 0x84D0
+#define GL_TEXTURE17_ARB 0x84D1
+#define GL_TEXTURE18_ARB 0x84D2
+#define GL_TEXTURE19_ARB 0x84D3
+#define GL_TEXTURE20_ARB 0x84D4
+#define GL_TEXTURE21_ARB 0x84D5
+#define GL_TEXTURE22_ARB 0x84D6
+#define GL_TEXTURE23_ARB 0x84D7
+#define GL_TEXTURE24_ARB 0x84D8
+#define GL_TEXTURE25_ARB 0x84D9
+#define GL_TEXTURE26_ARB 0x84DA
+#define GL_TEXTURE27_ARB 0x84DB
+#define GL_TEXTURE28_ARB 0x84DC
+#define GL_TEXTURE29_ARB 0x84DD
+#define GL_TEXTURE30_ARB 0x84DE
+#define GL_TEXTURE31_ARB 0x84DF
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
+#define GL_ARB_multitexture 1
+#endif
+
+#ifndef _WIN32
+#ifdef GL_GLEXT_PROTOTYPES
+extern void APIENTRY glActiveTextureARB (GLenum);
+extern void APIENTRY glClientActiveTextureARB (GLenum);
+extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
+extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
+extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
+extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
+extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
+extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+#endif // GL_GLEXT_PROTOTYPES
+#else // not _WIN32
+typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#endif // _WIN32
+
+#ifdef ARB_MULTITEXTURE_INITIALIZE
+#include<string.h> // string manipulation for runtime-check
+
+#ifdef _WIN32
+PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
+PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
+PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
+PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
+PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
+PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
+PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
+PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
+PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
+PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
+PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
+PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
+PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
+PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
+PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
+PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
+PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
+PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
+PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
+PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
+PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
+PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
+PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
+PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
+PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
+PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
+PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
+PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
+PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
+PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
+PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
+PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
+PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
+PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
+#endif // _WIN32
+
+int CheckForARBMultitextureSupport(void) {
+ const char search[]="GL_ARB_multitexture";
+ int i, pos=0;
+ int maxpos=strlen(search)-1;
+ char extensions[10000];
+ strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
+ int len=strlen(extensions);
+ for ( i=0; i<len; i++) {
+ if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
+ pos=0;
+ while(extensions[i]!=' ') {
+ if (extensions[i]==search[pos]) pos++;
+ if ((pos>maxpos) && extensions[i+1]==' ') {
+ //if (debug)
+ {
+ //fprintf(stderr, search);
+ //fprintf(stderr, " supported.\n");
+ }
+ return 1;
+ }
+ ++i;
+ }
+ }
+ }
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+}
+
+int GL_ARB_multitexture_Init(void) {
+ if (!CheckForARBMultitextureSupport()) return 0;
+#ifdef _WIN32
+ glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
+ if (glActiveTextureARB==NULL) {fprintf(stderr,"glActiveTextureARB not found.\n"); return 0; }
+ glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");
+ if (glClientActiveTextureARB==NULL) {fprintf(stderr,"glClientActiveTextureARB not found.\n"); return 0; }
+ glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) wglGetProcAddress("glMultiTexCoord1dARB");
+ if (glMultiTexCoord1dARB==NULL) {fprintf(stderr,"glMultiTexCoord1dARB not found.\n"); return 0; }
+ glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) wglGetProcAddress("glMultiTexCoord1dvARB");
+ if (glMultiTexCoord1dvARB==NULL) {fprintf(stderr,"glMultiTexCoord1dAvRB not found.\n"); return 0; }
+ glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) wglGetProcAddress("glMultiTexCoord1fARB");
+ if (glMultiTexCoord1fARB==NULL) {fprintf(stderr,"glMultiTexCoord1fARB not found.\n"); return 0; }
+ glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) wglGetProcAddress("glMultiTexCoord1fvARB");
+ if (glMultiTexCoord1fvARB==NULL) {fprintf(stderr,"glMultiTexCoord1fvARB not found.\n"); return 0; }
+ glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) wglGetProcAddress("glMultiTexCoord1iARB");
+ if (glMultiTexCoord1iARB==NULL) {fprintf(stderr,"glMultiTexCoord1iARB not found.\n"); return 0; }
+ glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) wglGetProcAddress("glMultiTexCoord1ivARB");
+ if (glMultiTexCoord1ivARB==NULL) {fprintf(stderr,"glMultiTexCoord1ivARB not found.\n"); return 0; }
+ glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) wglGetProcAddress("glMultiTexCoord1sARB");
+ if (glMultiTexCoord1sARB==NULL) {fprintf(stderr,"glMultiTexCoord1sARB not found.\n"); return 0; }
+ glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) wglGetProcAddress("glMultiTexCoord1svARB");
+ if (glMultiTexCoord1svARB==NULL) {fprintf(stderr,"glMultiTexCoord1svARB not found.\n"); return 0; }
+ glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) wglGetProcAddress("glMultiTexCoord2dARB");
+ if (glMultiTexCoord2dARB==NULL) {fprintf(stderr,"glMultiTexCoord2dARB not found.\n"); return 0; }
+ glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) wglGetProcAddress("glMultiTexCoord2dvARB");
+ if (glMultiTexCoord2dvARB==NULL) {fprintf(stderr,"glMultiTexCoord2dAvRB not found.\n"); return 0; }
+ glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
+ if (glMultiTexCoord2fARB==NULL) {fprintf(stderr,"glMultiTexCoord2fARB not found.\n"); return 0; }
+ glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
+ if (glMultiTexCoord2fvARB==NULL) {fprintf(stderr,"glMultiTexCoord2fvARB not found.\n"); return 0; }
+ glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) wglGetProcAddress("glMultiTexCoord2iARB");
+ if (glMultiTexCoord2iARB==NULL) {fprintf(stderr,"glMultiTexCoord2iARB not found.\n"); return 0; }
+ glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) wglGetProcAddress("glMultiTexCoord2ivARB");
+ if (glMultiTexCoord2ivARB==NULL) {fprintf(stderr,"glMultiTexCoord2ivARB not found.\n"); return 0; }
+ glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) wglGetProcAddress("glMultiTexCoord2sARB");
+ if (glMultiTexCoord2sARB==NULL) {fprintf(stderr,"glMultiTexCoord2sARB not found.\n"); return 0; }
+ glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) wglGetProcAddress("glMultiTexCoord2svARB");
+ if (glMultiTexCoord2svARB==NULL) {fprintf(stderr,"glMultiTexCoord2svARB not found.\n"); return 0; }
+ glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) wglGetProcAddress("glMultiTexCoord3dARB");
+ if (glMultiTexCoord3dARB==NULL) {fprintf(stderr,"glMultiTexCoord3dARB not found.\n"); return 0; }
+ glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) wglGetProcAddress("glMultiTexCoord3dvARB");
+ if (glMultiTexCoord3dvARB==NULL) {fprintf(stderr,"glMultiTexCoord3dAvRB not found.\n"); return 0; }
+ glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) wglGetProcAddress("glMultiTexCoord3fARB");
+ if (glMultiTexCoord3fARB==NULL) {fprintf(stderr,"glMultiTexCoord3fARB not found.\n"); return 0; }
+ glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) wglGetProcAddress("glMultiTexCoord3fvARB");
+ if (glMultiTexCoord3fvARB==NULL) {fprintf(stderr,"glMultiTexCoord3fvARB not found.\n"); return 0; }
+ glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) wglGetProcAddress("glMultiTexCoord3iARB");
+ if (glMultiTexCoord3iARB==NULL) {fprintf(stderr,"glMultiTexCoord3iARB not found.\n"); return 0; }
+ glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) wglGetProcAddress("glMultiTexCoord3ivARB");
+ if (glMultiTexCoord3ivARB==NULL) {fprintf(stderr,"glMultiTexCoord3ivARB not found.\n"); return 0; }
+ glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) wglGetProcAddress("glMultiTexCoord3sARB");
+ if (glMultiTexCoord3sARB==NULL) {fprintf(stderr,"glMultiTexCoord3sARB not found.\n"); return 0; }
+ glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) wglGetProcAddress("glMultiTexCoord3svARB");
+ if (glMultiTexCoord3svARB==NULL) {fprintf(stderr,"glMultiTexCoord3svARB not found.\n"); return 0; }
+ glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) wglGetProcAddress("glMultiTexCoord4dARB");
+ if (glMultiTexCoord4dARB==NULL) {fprintf(stderr,"glMultiTexCoord4dARB not found.\n"); return 0; }
+ glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) wglGetProcAddress("glMultiTexCoord4dvARB");
+ if (glMultiTexCoord4dvARB==NULL) {fprintf(stderr,"glMultiTexCoord4dAvRB not found.\n"); return 0; }
+ glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) wglGetProcAddress("glMultiTexCoord4fARB");
+ if (glMultiTexCoord4fARB==NULL) {fprintf(stderr,"glMultiTexCoord4fARB not found.\n"); return 0; }
+ glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) wglGetProcAddress("glMultiTexCoord4fvARB");
+ if (glMultiTexCoord4fvARB==NULL) {fprintf(stderr,"glMultiTexCoord4fvARB not found.\n"); return 0; }
+ glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) wglGetProcAddress("glMultiTexCoord4iARB");
+ if (glMultiTexCoord4iARB==NULL) {fprintf(stderr,"glMultiTexCoord4iARB not found.\n"); return 0; }
+ glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) wglGetProcAddress("glMultiTexCoord4ivARB");
+ if (glMultiTexCoord4ivARB==NULL) {fprintf(stderr,"glMultiTexCoord4ivARB not found.\n"); return 0; }
+ glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) wglGetProcAddress("glMultiTexCoord4sARB");
+ if (glMultiTexCoord4sARB==NULL) {fprintf(stderr,"glMultiTexCoord4sARB not found.\n"); return 0; }
+ glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) wglGetProcAddress("glMultiTexCoord4svARB");
+ if (glMultiTexCoord4svARB==NULL) {fprintf(stderr,"glMultiTexCoord4svARB not found.\n"); return 0; }
+#endif // _WIN32
+ return 1;
+}
+
+#endif // ARB_MULTITEXTURE_INITIALIZE
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // not __ARB_MULTITEXTURE_H_
diff --git a/sys/glsink/EXT_paletted_texture.h b/sys/glsink/EXT_paletted_texture.h
new file mode 100644
index 00000000..6df6b996
--- /dev/null
+++ b/sys/glsink/EXT_paletted_texture.h
@@ -0,0 +1,142 @@
+/*************************************************************
+ * *
+ * file : EXT_paletted_texture.h *
+ * author: Jens Schneider *
+ * date : 14.Mar.2001-10.Jul.2001 *
+ * e-mail: jens@glHint.de *
+ * *
+ * version 1.0ß *
+ * *
+ *************************************************************/
+
+#ifndef __EXT_paletted_texture_H_
+#define __EXT_paletted_texture_H_
+
+/*
+ * GLOBAL SWITCHES - enable/disable advanced features of this header
+ *
+ */
+#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines
+#ifndef _WIN32
+#define GL_GLEXT_PROTOTYPES 1
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+
+// Header file version number, required by OpenGL ABI for Linux
+#define GL_GLEXT_VERSION 7
+
+
+/*
+ * NEW TOKENS TO OPENGL 1.2.1
+ *
+ */
+#ifndef GL_EXT_paletted_texture
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
+#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#define GL_EXT_paletted_texture 1
+#endif
+
+#ifndef _WIN32
+#ifdef GL_GLEXT_PROTOTYPES
+extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+extern void APIENTRY glColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+extern void APIENTRY glGetColorTableEXT(GLenum, GLenum, GLenum, GLvoid *);
+extern void APIENTRY glGetColorTableParameterivEXT(GLenum, GLenum, GLint *);
+extern void APIENTRY glGetColorTableParameterfvEXT(GLenum, GLenum, GLfloat *);
+#endif // GL_GLEXT_PROTOTYPES
+#else // _WIN32
+typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC)(GLenum target, GLenum format, GLenum type, GLvoid *data);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)(GLenum target, GLenum pname, GLfloat *params);
+#endif // not _WIN32
+
+#ifdef EXT_PALETTED_TEXTURE_INITIALIZE
+#include<string.h> // string manipulation for runtime-check
+
+#ifdef _WIN32
+PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
+PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
+PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
+PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
+PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
+#endif // _WIN32
+
+int CheckForEXTPalettedTextureSupport(void) {
+ const char search[]="GL_EXT_paletted_texture";
+ int i, pos=0;
+ int maxpos=strlen(search)-1;
+ char extensions[10000];
+ strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
+ int len=strlen(extensions);
+ for (i=0; i<len; i++) {
+ if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
+ pos=0;
+ while(extensions[i]!=' ') {
+ if (extensions[i]==search[pos]) pos++;
+ if ((pos>maxpos) && extensions[i+1]==' ') {
+ //printf(search);
+ //printf(" supported.\n");
+ return 1;
+ }
+ i++;
+ }
+ }
+ }
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+}
+
+int GL_EXT_paletted_texture_Init(void) {
+ if (!CheckForEXTPalettedTextureSupport()) return 0;
+
+#ifdef _WIN32
+ glColorTableEXT = (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress("glColorTableEXT");
+ if (glColorTableEXT==NULL) {fprintf(stderr,"glColorTableEXT not found.\n"); return 0;}
+ glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC) wglGetProcAddress("glColorSubTableEXT");
+ if (glColorSubTableEXT==NULL) {fprintf(stderr,"glColorSubTableEXT not found.\n"); return 0;}
+ glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC) wglGetProcAddress("glGetColorTableEXT");
+ if (glGetColorTableEXT==NULL) {fprintf(stderr,"glGetColorTableEXT not found.\n"); return 0;}
+ glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) wglGetProcAddress("glGetColorTableParameterivEXT");
+ if (glGetColorTableParameterivEXT==NULL) {fprintf(stderr,"glGetColorTableParameterivEXT not found.\n"); return 0;}
+ glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) wglGetProcAddress("glGetColorTableParameterfvEXT");
+ if (glGetColorTableParameterfvEXT==NULL) {fprintf(stderr,"glGetColorTableParameterfvEXT not found.\n"); return 0;}
+#endif // _WIN32
+ return 1;
+}
+
+#endif // EXT_PALETTED_TEXTURE_INITIALIZE
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // not __EXT_PALETTED_TEXTURE_H_
diff --git a/sys/glsink/NV_register_combiners.h b/sys/glsink/NV_register_combiners.h
new file mode 100644
index 00000000..f4a752ab
--- /dev/null
+++ b/sys/glsink/NV_register_combiners.h
@@ -0,0 +1,218 @@
+/*************************************************************
+ * *
+ * file : NV_register_combiners.h *
+ * author: Jens Schneider *
+ * date : 12.Mar.2001-04.Jul.2001 *
+ * e-mail: jens@glHint.de *
+ * *
+ * version 2.0ß *
+ * *
+ *************************************************************/
+
+#ifndef __NV_register_combiners_H_
+#define __NV_register_combiners_H_
+
+/*
+ * GLOBAL SWITCHES - enable/disable advanced features of this header
+ *
+ */
+#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines
+#ifndef _WIN32
+#define GL_GLEXT_PROTOTYPES 1
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+
+// Header file version number, required by OpenGL ABI for Linux
+#define GL_GLEXT_VERSION 7
+
+
+/*
+ * NEW TOKENS TO OPENGL 1.2.1
+ *
+ */
+#ifndef GL_NV_register_combiners
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#define GL_COMBINER0_NV 0x8550
+#define GL_COMBINER1_NV 0x8551
+#define GL_COMBINER2_NV 0x8552
+#define GL_COMBINER3_NV 0x8553
+#define GL_COMBINER4_NV 0x8554
+#define GL_COMBINER5_NV 0x8555
+#define GL_COMBINER6_NV 0x8556
+#define GL_COMBINER7_NV 0x8557
+#define GL_VARIABLE_A_NV 0x8523
+#define GL_VARIABLE_B_NV 0x8524
+#define GL_VARIABLE_C_NV 0x8525
+#define GL_VARIABLE_D_NV 0x8526
+#define GL_VARIABLE_E_NV 0x8527
+#define GL_VARIABLE_F_NV 0x8528
+#define GL_VARIABLE_G_NV 0x8529
+#define GL_CONSTANT_COLOR0_NV 0x852A
+#define GL_CONSTANT_COLOR1_NV 0x852B
+#define GL_PRIMARY_COLOR_NV 0x852C
+#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_SPARE0_NV 0x852E
+#define GL_SPARE1_NV 0x852F
+#define GL_UNSIGNED_IDENTITY_NV 0x8536
+#define GL_UNSIGNED_INVERT_NV 0x8537
+#define GL_EXPAND_NORMAL_NV 0x8538
+#define GL_EXPAND_NEGATE_NV 0x8539
+#define GL_HALF_BIAS_NORMAL_NV 0x853A
+#define GL_HALF_BIAS_NEGATE_NV 0x853B
+#define GL_SIGNED_IDENTITY_NV 0x853C
+#define GL_SIGNED_NEGATE_NV 0x853D
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_SCALE_BY_TWO_NV 0x853E
+#define GL_SCALE_BY_FOUR_NV 0x853F
+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
+#define GL_DISCARD_NV 0x8530
+#define GL_COMBINER_INPUT_NV 0x8542
+#define GL_COMBINER_MAPPING_NV 0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
+#define GL_COMBINER_MUX_SUM_NV 0x8547
+#define GL_COMBINER_SCALE_NV 0x8548
+#define GL_COMBINER_BIAS_NV 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NV_register_combiners 1
+#endif
+
+#ifndef _WIN32
+#ifdef GL_GLEXT_PROTOTYPES
+extern void APIENTRY glCombinerParameterfvNV(GLenum, const GLfloat *);
+extern void APIENTRY glCombinerParameterivNV(GLenum, const GLint *);
+extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
+extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
+extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
+extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
+extern void APIENTRY glGetCombinerOutputParameterfvNV(GLenum, GLenum, GLenum, GLfloat *);
+extern void APIENTRY glGetCombinerOutputParameterivNV(GLenum, GLenum, GLenum, GLint *);
+extern void APIENTRY glGetFinalCombinerInputParameterfvNV(GLenum, GLenum, GLfloat *);
+extern void APIENTRY glGetFinalCombinerInputParameterivNV(GLenum, GLenum, GLint *);
+#endif // GL_GLEXT_PROTOTYPES
+#else // _WIN32
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params);
+#endif // not _WIN32
+
+#ifdef NV_REGISTER_COMBINERS_INITIALIZE
+#include<string.h> // string manipulation for runtime-check
+
+#ifdef _WIN32
+PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
+PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
+PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
+PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
+PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
+PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
+PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
+PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV = NULL;
+PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV = NULL;
+PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV = NULL;
+PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV = NULL;
+PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV = NULL;
+PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV = NULL;
+#endif // _WIN32
+
+int CheckForNVRegisterCombinersSupport(void) {
+ const char search[]="GL_NV_register_combiners";
+ int i, pos=0;
+ int maxpos=strlen(search)-1;
+ char extensions[10000];
+ strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
+ int len=strlen(extensions);
+ for (i=0; i<len; i++) {
+ if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
+ pos=0;
+ while(extensions[i]!=' ') {
+ if (extensions[i]==search[pos]) pos++;
+ if ((pos>maxpos) && extensions[i+1]==' ') {
+ //printf(search);
+ // printf(" supported.\n");
+ return 1;
+ }
+ i++;
+ }
+ }
+ }
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+}
+
+int GL_NV_register_combiners_Init(void) {
+ if (!CheckForNVRegisterCombinersSupport()) return 0;
+
+#ifdef _WIN32
+ glCombinerParameterfvNV=(PFNGLCOMBINERPARAMETERFVNVPROC) wglGetProcAddress("glCombinerParameterfvNV");
+ if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfvNV not found.\n"); return 0;}
+ glCombinerParameterivNV=(PFNGLCOMBINERPARAMETERIVNVPROC) wglGetProcAddress("glCombinerParameterivNV");
+ if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameterivNV not found.\n"); return 0;}
+ glCombinerParameterfNV=(PFNGLCOMBINERPARAMETERFNVPROC) wglGetProcAddress("glCombinerParameterfNV");
+ if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfNV not found.\n"); return 0;}
+ glCombinerParameteriNV=(PFNGLCOMBINERPARAMETERINVPROC) wglGetProcAddress("glCombinerParameteriNV");
+ if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameteriNV not found.\n"); return 0;}
+ glCombinerInputNV=(PFNGLCOMBINERINPUTNVPROC) wglGetProcAddress("glCombinerInputNV");
+ if (glCombinerInputNV==NULL) {fprintf(stderr,"glCombinerInputNV not found.\n"); return 0;}
+ glCombinerOutputNV=(PFNGLCOMBINEROUTPUTNVPROC) wglGetProcAddress("glCombinerOutputNV");
+ if (glCombinerOutputNV==NULL) {fprintf(stderr,"glCombinerOutputNV not found.\n"); return 0;}
+ glFinalCombinerInputNV=(PFNGLFINALCOMBINERINPUTNVPROC) wglGetProcAddress("glFinalCombinerInputNV");
+ if (glFinalCombinerInputNV==NULL) {fprintf(stderr,"glFinalCombinerInputNV not found.\n"); return 0;}
+ glGetCombinerInputParameterfvNV=(PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerInputParameterfvNV");
+ if (glGetCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterfvNV not found.\n"); return 0;}
+ glGetCombinerInputParameterivNV=(PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerInputParameterivNV");
+ if (glGetCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterivNV not found.\n"); return 0;}
+ glGetCombinerOutputParameterfvNV=(PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterfvNV");
+ if (glGetCombinerOutputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterfvNV not found.\n"); return 0;}
+ glGetCombinerOutputParameterivNV=(PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterivNV");
+ if (glGetCombinerOutputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterivNV not found.\n"); return 0;}
+ glGetFinalCombinerInputParameterfvNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterfvNV");
+ if (glGetFinalCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterfvNV not found.\n"); return 0;}
+ glGetFinalCombinerInputParameterivNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterivNV");
+ if (glGetFinalCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterivNV not found.\n"); return 0;}
+#endif // _WIN32
+ return 1;
+}
+
+#endif // NV_REGISTER_COMBINERS_INITIALIZE
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // not __NV_REGISTER_COMBINERS_H_
diff --git a/sys/glsink/gstgl_nvimage.c b/sys/glsink/gstgl_nvimage.c
index faa5224c..61d18749 100644
--- a/sys/glsink/gstgl_nvimage.c
+++ b/sys/glsink/gstgl_nvimage.c
@@ -13,19 +13,18 @@
#include <stdlib.h>
#include <sys/types.h>
-#define GL_GLEXT_PROTOTYPES
-
-// VERY dangerous:
-#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/glx.h>
#include <GL/gl.h>
-#include <GL/glext.h>
+//#include <GL/glext.h>
#include <GL/glu.h>
#include <string.h>
+// too lazy to write an API for this ;)
+#include "regcomb_yuvrgb.c"
+
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
@@ -102,8 +101,12 @@ gst_gl_nvimage_connection (GstImageConnection *conn)
gboolean
gst_gl_nvimage_check_xvideo ()
{
- int ver, rel, req, ev, err;
+ //int ver, rel, req, ev, err;
+ if (!GL_ARB_multitexture_Init()) return FALSE;
+ if (!GL_EXT_paletted_texture_Init()) return FALSE;
+ if (!GL_NV_register_combiners_Init()) return FALSE;
+
#if 0
if (display == NULL)
return FALSE;
@@ -111,15 +114,15 @@ gst_gl_nvimage_check_xvideo ()
return TRUE;
#endif
- return FALSE;
+ return TRUE;
}
static GstCaps *
gst_gl_nvimage_get_caps (GstImageInfo *info)
{
- gint i;
- int adaptors;
- int formats;
+ //gint i;
+ //int adaptors;
+ //int formats;
GstCaps *caps = NULL;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
@@ -128,14 +131,14 @@ gst_gl_nvimage_get_caps (GstImageInfo *info)
if (gst_gl_nvimage_check_xvideo () == FALSE)
{
- g_warning("GL_NVImage: Server has no NVidia extension support\n");
+ g_warning("GL_NVImage: Server has no NVidia extension support\n");
return NULL;
}
caps = gst_caps_append (caps, GST_CAPS_NEW (
"xvimage_caps",
"video/raw",
- "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
+ "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'V', '1', '2')),
"width", GST_PROPS_INT_RANGE (0, 1024),
"height", GST_PROPS_INT_RANGE (0, 1024))
);
@@ -145,9 +148,9 @@ gst_gl_nvimage_get_caps (GstImageInfo *info)
static GstImageConnection *
gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
{
- gint i, j = 0;
- int adaptors;
- int formats;
+ //gint i, j = 0;
+ //int adaptors;
+ //int formats;
GstGLImageConnection *conn;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
guint32 format;
@@ -166,6 +169,12 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
"format", &format,
NULL);
+ // maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
+ if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2'))
+ {
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
+ return NULL;
+ }
if (0) //conn->port == (XvPortID) -1)
{
/* this happens if the plugin can't handle the caps, so no warning */
@@ -173,6 +182,7 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
return NULL;
}
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image", caps);
return (GstImageConnection *) conn;
}
@@ -182,35 +192,22 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
GstNvImage *image;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
- int slot = 0;
/* checks */
if (xinfo == NULL) return NULL;
if (nvconn == NULL) return NULL;
- // I should also check the current GLX context ! Don't have to, I am guarantueed to always be in the same thread
+ // I should also check the current GLX context !
+ // Ah, Don't have to, I am guarantueed to always be in the same thread
image = g_new0(GstNvImage, 1);
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- {
- if (!nvconn->m_bufslots[slot]) break;
- }
-
image->data.size = nvconn->w * nvconn->h * 3/2;
- if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
- {
- image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
- image->slot = slot; // store for freeing
- nvconn->m_bufslots[slot] = 1; // it is now taken
- }
- else
- {
- g_warning("Allocating from main memory !");
- image->data.data = g_malloc(image->data.size);
- image->slot = AGP_BUFSLOTS; // no AGP slot
- }
+ //g_warning("Allocating %d bytes from main memory !", image->data.size);
+ image->data.data = g_malloc(image->data.size);
+ //image->slot = AGP_BUFSLOTS; // no AGP slot
+
image->conn = nvconn;
if (image->data.data == NULL)
@@ -229,52 +226,125 @@ gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
GstNvImage *im = (GstNvImage *) image;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
+ int uv_width = img_width >> 1;
+ int uv_height = img_height >> 1;
+
+ unsigned char *buf_y = im->data.data;
+ unsigned char *buf_v = (buf_y + img_width * img_height);
+ unsigned char *buf_u = buf_v + ((img_width/2) * (img_height/2));
+
/* checks omitted for speed (and lazyness), do we need them? */
g_assert (xinfo != NULL);
- /* Upload the texture here */
- g_warning("PUTTING IMAGE - BROOOKEN");
-
// both upload the video, and redraw the screen
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -50.0);
glEnable(GL_TEXTURE_2D);
glPushMatrix();
//glTranslatef(0,1,0);
- glRotatef(xinfo->rotX-250,1,0,0);
+ glRotatef(xinfo->rotX,1,0,0);
glRotatef(xinfo->rotY,0,1,0);
- int zoom = xinfo->zoom;
- glScaled(zoom,zoom,zoom);
- //Draws the surface rectangle
- glBindTexture(GL_TEXTURE_2D, im->conn->ytex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
- GL_UNSIGNED_BYTE, im->data.data);
- float xmax = (float)im->conn->w/TEX_XSIZE;
- float ymax = (float)im->conn->h/TEX_YSIZE;
+ if (xinfo->info.demo)
+ {
+ //xinfo->rotX += 0.2;
+ //xinfo->rotY -= 0.2;
+ float zoom = xinfo->zoom;
+ glScalef(zoom,zoom,zoom);
+
+ if (xinfo->zoom > 2.0)
+ xinfo->zoomdir = -0.05;
+
+ if (xinfo->zoom < 1.0)
+ xinfo->zoomdir = 0.05;
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
+ xinfo->zoom += xinfo->zoomdir;
+ }
- glNormal3f(0, -1, 0);
-
- glTexCoord2f(xmax, 0);
- glVertex3f(4,0,-4);
+ //Draws the surface rectangle
+
+ if (Ywidth != im->conn->w || Yheight != im->conn->h)
+ {
+ Ywidth = im->conn->w; Yheight = im->conn->h; UVwidth = im->conn->w/2; UVheight = im->conn->h/2;
+ Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ }
- glTexCoord2f(0, 0);
- glVertex3f(-4,0,-4);
+ LoadYUVPlanes(Yhandle,Uhandle,Vhandle,img_width,img_height,uv_width,uv_height,buf_y,buf_u,buf_v);
+ float xmax = (float)(im->conn->w-1)/tex_xsize;
+ float ymax = (float)(im->conn->h-1)/tex_ysize;
- glTexCoord2f(0, ymax);
- glVertex3f(-4,0,4);
+ /* Upload the texture here */
+ //g_warning("PUTTING IMAGE %f %f %d %d\n", xmax, ymax, tex_xsize, tex_ysize);
- glTexCoord2f(xmax, ymax);
- glVertex3f(4,0,4);
+ //glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
+ glBegin(GL_QUADS);
+
+ glNormal3f(0, -1, 0);
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
+ glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,0);
+ glVertex3f(-4,4,0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,ymax);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,ymax);
+ glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,ymax);
+ glVertex3f(-4,-4,0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,ymax);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,ymax);
+ glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,ymax);
+ glVertex3f(4,-4,0);
+
+ glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,0);
+ glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,0);
+ glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,0);
+ glVertex3f(4,4,0);
glEnd();
glPopMatrix();
+ if (xinfo->info.dumpvideo)
+ {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
+
+ printf("Recording frame #%d\n", framenr);
+ glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
+
+ sprintf(capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen(capfilename, "wb");
+ if (outfile != NULL)
+ {
+ fprintf(outfile, "P6\n");
+ fprintf(outfile,"# created by raw_zb\n");
+ fprintf(outfile,"%d %d\n",img_width,img_height);
+ fprintf(outfile,"255\n");
+ fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
+ fclose(outfile);
+ }
+ framenr++;
+ }
+
+
glXSwapBuffers(xinfo->dpy, xinfo->win);
}
@@ -301,76 +371,18 @@ gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- unsigned char data_sep[2][2] = {{0, 255}, {0, 255}};
- int slot;
-
- g_warning("Opening NVidia Connection");
- xconn->m_memory = (unsigned char*)glXAllocateMemoryNV(AGP_BUFSLOTS*YUVTEX_SIZE, 0, 1.0, 1.0);
-
- if (!xconn->m_memory)
- {
- printf("Unable to acquire graphics card mem... will acquire in normal memory.\n");
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 1;
- }
- else
- {
- // maybe this fast writable memory, awfully slow to read from, though
- glPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV, AGP_BUFSLOTS*YUVTEX_SIZE, xconn->m_memory);
- glEnableClientState(GL_WRITE_PIXEL_DATA_RANGE_NV);
-
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 0;
- }
-
- glGenTextures(1, &xconn->ytex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->ytex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
-
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glGenTextures(1, &xconn->uvtex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->uvtex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE/2, TEX_YSIZE/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glGenTextures(1, &xconn->septex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->septex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data_sep);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glFlushPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV);
- //glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
+ g_warning("Opening NVidia GL context connection, using register combiners.\n");
+ {
+ Ywidth = TEX_XSIZE; Yheight = TEX_YSIZE; UVwidth = TEX_XSIZE/2; UVheight = TEX_YSIZE/2;
+ Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ }
}
static void
gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
{
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ //GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
// anything needed in here ? Oh, maybe drawing de-init, or something
glDeleteTextures(1, &xconn->ytex_id);
diff --git a/sys/glsink/gstgl_rgbimage.c b/sys/glsink/gstgl_rgbimage.c
index 31ac16ae..7c2cfb54 100644
--- a/sys/glsink/gstgl_rgbimage.c
+++ b/sys/glsink/gstgl_rgbimage.c
@@ -237,6 +237,10 @@ gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
// both upload the video, and redraw the screen
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -50.0);
+
glEnable(GL_TEXTURE_2D);
glPushMatrix();
@@ -259,16 +263,16 @@ gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
glNormal3f(0, -1, 0);
glTexCoord2f(xmax, 0);
- glVertex3f(4,0,-4);
+ glVertex3f(4,4,0);
glTexCoord2f(0, 0);
- glVertex3f(-4,0,-4);
+ glVertex3f(-4,4,0);
glTexCoord2f(0, ymax);
- glVertex3f(-4,0,4);
+ glVertex3f(-4,-4,0);
glTexCoord2f(xmax, ymax);
- glVertex3f(4,0,4);
+ glVertex3f(4,-4,0);
glEnd();
diff --git a/sys/glsink/gstglsink.c b/sys/glsink/gstglsink.c
index d3e53f22..62292f1e 100644
--- a/sys/glsink/gstglsink.c
+++ b/sys/glsink/gstglsink.c
@@ -56,7 +56,9 @@ enum {
ARG_FRAME_TIME,
ARG_HOOK,
ARG_MUTE,
- ARG_REPAINT
+ ARG_REPAINT,
+ ARG_DEMO,
+ ARG_DUMP
};
/* GLsink class */
@@ -78,6 +80,8 @@ struct _GstGLSink {
guint64 frame_time;
gint width, height;
gboolean muted;
+ gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
+ gboolean dumpvideo; // dump the video down to .ppm:s
GstBuffer *last_image; /* not thread safe ? */
GstClock *clock;
@@ -197,6 +201,10 @@ gst_glsink_class_init (GstGLSinkClass *klass)
g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_REPAINT,
g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame", FALSE, G_PARAM_WRITABLE));
+ g_object_class_install_property (gobject_class, ARG_DEMO,
+ g_param_spec_int ("demo", "Demo", "demo mode (shows 3D capabilities)",0, 1, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_DUMP,
+ g_param_spec_boolean ("dump", "Dump", "stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
/* gobject_class->dispose = gst_glsink_dispose; */
@@ -206,7 +214,8 @@ gst_glsink_class_init (GstGLSinkClass *klass)
/* plugins */
klass->plugins = NULL;
//klass->plugins = g_list_append (klass->plugins, get_xvimage_plugin ());
- klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
+ //klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
+ klass->plugins = g_list_append (klass->plugins, get_gl_nvimage_plugin ());
}
@@ -299,12 +308,14 @@ gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
sink = GST_GLSINK (user_data);
+ /* If cache is non-empty, get buffer from there */
if (sink->cache != NULL) {
g_mutex_lock (sink->cache_lock);
image = (GstImageData *) sink->cache->data;
sink->cache = g_list_delete_link (sink->cache, sink->cache);
g_mutex_unlock (sink->cache_lock);
} else {
+ /* otherwise, get one from the plugin */
image = sink->plugin->get_image (sink->hook, sink->conn);
}
@@ -489,6 +500,10 @@ gst_glsink_chain (GstPad *pad, GstBuffer *buf)
if (sink->last_image != NULL)
gst_buffer_unref (sink->last_image);
if (sink->bufferpool && GST_BUFFER_BUFFERPOOL (buf) == sink->bufferpool) {
+ // awful hack ! But I currently have no other solution without changing the API
+ sink->hook->demo = sink->demo;
+ sink->hook->dumpvideo = sink->dumpvideo;
+
sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
sink->last_image = buf;
} else {
@@ -537,6 +552,14 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
sink->muted = g_value_get_boolean (value);
g_object_notify (object, "mute");
break;
+ case ARG_DEMO:
+ sink->demo = g_value_get_int (value);
+ g_object_notify (object, "demo");
+ break;
+ case ARG_DUMP:
+ sink->dumpvideo = g_value_get_boolean (value);
+ g_object_notify (object, "dump");
+ break;
case ARG_REPAINT:
if (sink->last_image != NULL) {
sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
@@ -572,6 +595,12 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case ARG_MUTE:
g_value_set_boolean (value, sink->muted);
break;
+ case ARG_DEMO:
+ g_value_set_int (value, sink->demo);
+ break;
+ case ARG_DUMP:
+ g_value_set_boolean (value, sink->dumpvideo);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/sys/glsink/gstglsink.h b/sys/glsink/gstglsink.h
index 8cedccc1..8a34df9a 100644
--- a/sys/glsink/gstglsink.h
+++ b/sys/glsink/gstglsink.h
@@ -33,6 +33,8 @@ extern "C" {
typedef struct _GstImageInfo GstImageInfo;
struct _GstImageInfo {
gulong id;
+ int demo;
+ int dumpvideo;
void (*free_info) (GstImageInfo *info);
};
@@ -82,7 +84,7 @@ struct _GstGLImageInfo {
/* window specific from here */
GstElement *sink;
gulong handler_id;
- float rotX,rotY,zoom;
+ float rotX,rotY,zoom, zoomdir;
};
diff --git a/sys/glsink/gstglxwindow.c b/sys/glsink/gstglxwindow.c
index 96ec673a..5f723160 100644
--- a/sys/glsink/gstglxwindow.c
+++ b/sys/glsink/gstglxwindow.c
@@ -1,3 +1,5 @@
+/* This stores the common OpenGL initialization stuff for all instances */
+
/* gcc -ansi -pedantic on GNU/Linux causes warnings and errors
* unless this is defined:
* warning: #warning "Files using this header must be compiled with _SVID_SOURCE or _XOPEN_SOURCE"
@@ -90,17 +92,13 @@ gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
XMapRaised (data->dpy, data->win);
// resize OpenGL
- g_warning("resizing in OpenGL");
+ //g_warning("resizing in OpenGL");
glViewport(0, 0, (GLint) w, (GLint) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat aspect = (GLfloat) h / (GLfloat) w;
glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, -3.0, -50.0);
}
}
if (attr.width != data->width || attr.height != data->height)
@@ -230,6 +228,9 @@ gst_glxwindow_new (GstElement *sink)
glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);
+ glShadeModel(GL_SMOOTH);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
+
XSelectInput (new->dpy, new->win, ExposureMask | StructureNotifyMask);
g_object_set (sink, "hook", new, NULL);
diff --git a/sys/glsink/regcomb_yuvrgb.c b/sys/glsink/regcomb_yuvrgb.c
new file mode 100644
index 00000000..0c953c6f
--- /dev/null
+++ b/sys/glsink/regcomb_yuvrgb.c
@@ -0,0 +1,349 @@
+// these includes don't do a lot in Linux, they are more needed in Win32 (for the OpenGL function call pointers)
+// but they are used at least for checking if the necessary extensions are present
+#include "ARB_multitexture.h"
+#include "NV_register_combiners.h"
+#include "EXT_paletted_texture.h"
+
+/***********************************************************************************************
+ INTERESTING PART: *
+ handles initialization of the Nvidia register combiners for YUV->RGB conversion.
+ This code was created by Jens Schneider <schneider@glhint.de>
+ ***********************************************************************************************/
+
+GLuint Yhandle;
+GLuint Uhandle;
+GLuint Vhandle;
+unsigned char *YPlane;
+unsigned char *UPlane;
+unsigned char *VPlane;
+
+// YUV 4:2:2 example
+unsigned int Ywidth=512, Yheight=512;
+unsigned int UVwidth=256, UVheight=512;
+
+int tex_xsize, tex_ysize;
+
+void GenerateRGBTables(unsigned char *Ytable, // Y-palette
+ unsigned char *Utable, // U-palette
+ unsigned char *Vtable, // V-palette
+ float *bias, // bias (fourth vector to be added)
+ float *Uscale, // scaling color for U
+ float *Vscale) // scaling color for V
+{
+ int i;
+ const float mat[9]= { // the modified YUV->RGB matrix
+ +1.130469478f,-0.058755723f,+1.596026304f,
+ +1.130469478f,-0.450515935f,-0.812967512f,
+ +1.130469478f,+1.958477882f, 0.0f
+ };
+ #define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
+ #define fCOMPRESS(a) (0.5f*(a)+0.5f);
+ #define XCLAMP(a) ((a)<0.0f ? 0.0f : ((a)>255.0f ? 255.0f : (a))) // should not be necessary, but what do you know.
+ bias[0]=fCOMPRESS(-0.842580964f);
+ bias[1]=fCOMPRESS(+0.563287723f);
+ bias[2]=fCOMPRESS(-1.0f);
+ bias[3]=0.0f;
+ Uscale[0]=8.0f/255.0f;
+ Uscale[1]=60.0f/255.0f;
+ Uscale[2]=250.0f/255.0f;
+ Uscale[3]=0.0f;
+ Vscale[0]=204.0f/255.0f;
+ Vscale[1]=105.0f/255.0f;
+ Vscale[2]=0.5f;
+ Vscale[3]=0.0f;
+ for (i=0; i<256; i++) {
+ // Y-table holds unsigned values
+ Ytable[3*i ]=(unsigned char)XCLAMP(mat[0]*(float)i); // R
+ Ytable[3*i+1]=(unsigned char)XCLAMP(mat[3]*(float)i); // G
+ Ytable[3*i+2]=(unsigned char)XCLAMP(mat[6]*(float)i); // B
+ // U-table holds signed values
+ Utable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/ 16.0f*mat[1]*(float)i)); // R
+ Utable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/120.0f*mat[4]*(float)i)); // G
+ Utable[3*i+2]=(unsigned char)XCLAMP(COMPRESS(255.0f/500.0f*mat[7]*(float)i)); // B
+ // V-table holds signed values
+ Vtable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/408.0f*mat[2]*(float)i)); // R
+ Vtable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/210.0f*mat[5]*(float)i)); // G
+ Vtable[3*i+2]=(unsigned char)(128.0f-14.0f); // G constant
+ }
+ #undef fCOMPRESS
+ #undef COMPRESS
+ #undef XCLAMP
+}
+
+
+// Sets the constants. Call once prior to rendering.
+void SetConsts(float *bias, float *Uscale, float *Vscale) {
+ glEnable(GL_REGISTER_COMBINERS_NV);
+ glColor3fv(bias);
+ //printf("%f %f %f\n",bias[0],bias[1],bias[2]);
+ glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,Uscale);
+ glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,Vscale);
+}
+
+/*
+ * SOFTWARE PATH
+ */
+
+inline void map_EXPAND_NORMAL(float *v) {
+ v[0]=2.0f*v[0]-1.0f;
+ v[1]=2.0f*v[1]-1.0f;
+ v[2]=2.0f*v[2]-1.0f;
+}
+
+inline void map_UNSIGNED_INVERT(float *v) {
+ v[0]=1.0f-v[0];
+ v[1]=1.0f-v[1];
+ v[2]=1.0f-v[2];
+}
+
+inline void map_UNSIGNED_IDENTITY(float *v) {
+ v[0]=(v[0]<0.0f ? 0.0f : v[0]);
+ v[1]=(v[1]<0.0f ? 0.0f : v[1]);
+ v[2]=(v[2]<0.0f ? 0.0f : v[2]);
+}
+
+inline void map_SIGNED_IDENTITY(float *v) {
+}
+
+inline void omap_SCALE_BY_TWO(float *v) {
+ v[0]*=2.0f;
+ v[1]*=2.0f;
+ v[2]*=2.0f;
+}
+
+inline void omap_SCALE_BY_ONE_HALF(float *v) {
+ v[0]*=0.5f;
+ v[1]*=0.5f;
+ v[2]*=0.5f;
+}
+
+inline void omap_RANGE(float *v) {
+ v[0]=(v[0]<-1.0f ? -1.0f : (v[0]>1.0f ? 1.0f : v[0]));
+ v[1]=(v[1]<-1.0f ? -1.0f : (v[1]>1.0f ? 1.0f : v[1]));
+ v[2]=(v[2]<-1.0f ? -1.0f : (v[2]>1.0f ? 1.0f : v[2]));
+}
+
+
+inline void omap_CLAMP_01(float *v) {
+ v[0]=(v[0]<0.0f ? 0.0f : (v[0]>1.0f ? 1.0f : v[0]));
+ v[1]=(v[1]<0.0f ? 0.0f : (v[1]>1.0f ? 1.0f : v[1]));
+ v[2]=(v[2]<0.0f ? 0.0f : (v[2]>1.0f ? 1.0f : v[2]));
+}
+
+void PerformSWCombiner(unsigned char *Result,
+ unsigned char *tex0,
+ unsigned char *tex1,
+ unsigned char *tex2,
+ float *COLOR0,
+ float *CONST0,
+ float *CONST1
+ )
+{
+ float SPARE0[3];
+ float SPARE1[3];
+ float A[3],B[3],C[3],D[3];
+ float TEX0[3],TEX1[3],TEX2[3];
+ float ZERO[3]={0.0f,0.0f,0.0f};
+
+ TEX0[0]=(float)tex0[0]/255.0f;
+ TEX0[1]=(float)tex0[1]/255.0f;
+ TEX0[2]=(float)tex0[2]/255.0f;
+
+ TEX1[0]=(float)tex1[0]/255.0f;
+ TEX1[1]=(float)tex1[1]/255.0f;
+ TEX1[2]=(float)tex1[2]/255.0f;
+
+ TEX2[0]=(float)tex2[0]/255.0f;
+ TEX2[1]=(float)tex2[1]/255.0f;
+ TEX2[2]=(float)tex2[2]/255.0f;
+
+ // Combiner Stage 0:
+ memcpy(A,TEX0,3*sizeof(float)); map_UNSIGNED_IDENTITY(A);
+ memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
+ memcpy(C,COLOR0,3*sizeof(float)); map_EXPAND_NORMAL(C);
+ memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
+ SPARE0[0]=A[0]*B[0]+C[0]*D[0];
+ SPARE0[1]=A[1]*B[1]+C[1]*D[1];
+ SPARE0[2]=A[2]*B[2]+C[2]*D[2];
+ omap_SCALE_BY_ONE_HALF(SPARE0);
+ omap_RANGE(SPARE0);
+
+ // Combiner Stage 1:
+ memcpy(A,TEX1,3*sizeof(float)); map_EXPAND_NORMAL(A);
+ memcpy(B,CONST0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
+ memcpy(C,TEX2,3*sizeof(float)); map_EXPAND_NORMAL(C);
+ memcpy(D,CONST1,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
+ SPARE1[0]=A[0]*B[0]+C[0]*D[0];
+ SPARE1[1]=A[1]*B[1]+C[1]*D[1];
+ SPARE1[2]=A[2]*B[2]+C[2]*D[2];
+ omap_RANGE(SPARE1);
+
+ // Combiner Stage 2:
+ memcpy(A,SPARE0,3*sizeof(float)); map_SIGNED_IDENTITY(A);
+ memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
+ memcpy(C,SPARE1,3*sizeof(float)); map_SIGNED_IDENTITY(C);
+ memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
+ SPARE0[0]=A[0]*B[0]+C[0]*D[0];
+ SPARE0[1]=A[1]*B[1]+C[1]*D[1];
+ SPARE0[2]=A[2]*B[2]+C[2]*D[2];
+ omap_SCALE_BY_TWO(SPARE0);
+ omap_RANGE(SPARE0);
+
+ // Final Combiner Stage:
+ memcpy(A,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(A);
+ memcpy(B,SPARE0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
+ memcpy(C,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(C);
+ memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
+ SPARE0[0]=A[0]*B[0]+(1.0f-A[0])*C[0]+D[0];
+ SPARE0[1]=A[1]*B[1]+(1.0f-A[1])*C[1]+D[1];
+ SPARE0[2]=A[2]*B[2]+(1.0f-A[2])*C[2]+D[2];
+ omap_CLAMP_01(SPARE0);
+ Result[0]=(unsigned char)(SPARE0[0]*255.0f);
+ Result[1]=(unsigned char)(SPARE0[1]*255.0f);
+ Result[2]=(unsigned char)(SPARE0[2]*255.0f);
+}
+
+// Sets up the register combiners. Call once prior to rendering
+void SetupCombiners(void)
+{
+ glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,3);
+ // Combiner Stage 0: th. OK
+ glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_C_NV,GL_PRIMARY_COLOR_NV,GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV(GL_COMBINER0_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_ONE_HALF_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
+ // Combiner Stage 1: th. OK
+ glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_C_NV,GL_TEXTURE2_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_D_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glCombinerOutputNV(GL_COMBINER1_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE1_NV,GL_NONE,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
+ // Combiner Stage 2: th. OK
+ glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_A_NV,GL_SPARE0_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_C_NV,GL_SPARE1_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV(GL_COMBINER2_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_TWO_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
+ // Final Sage: th. OK
+ glFinalCombinerInputNV(GL_VARIABLE_A_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glFinalCombinerInputNV(GL_VARIABLE_B_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glFinalCombinerInputNV(GL_VARIABLE_C_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glFinalCombinerInputNV(GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
+ glFinalCombinerInputNV(GL_VARIABLE_G_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
+}
+
+
+unsigned int PowerOfTwo(unsigned int i) {
+ unsigned int bitsum=0;
+ unsigned int shifts=0;
+ unsigned int j=(unsigned int)i;
+ // Check wether i is a power of two - may contain at most one set bit
+ do {
+ bitsum+=j&1;
+ j=j>>1;
+ ++shifts;
+ } while (j>0);
+ if (bitsum==1) return i;
+ else return (1<<shifts);
+}
+
+
+// Initializes textures. Call once prior to rendering
+void InitYUVPlanes(GLuint *Yhandle, GLuint *Uhandle, GLuint *Vhandle,
+ unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight,
+ GLenum filter, // filter should be either GL_NEAREST or GL_LINEAR. Test this!
+ unsigned char* Ypal, unsigned char *Upal, unsigned char *Vpal)
+{
+ glGenTextures(1,Yhandle);
+ glGenTextures(1,Uhandle);
+ glGenTextures(1,Vhandle);
+ glBindTexture(GL_TEXTURE_2D,(*Yhandle));
+#ifdef _WIN32
+ glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+#else // Hopefully Linux
+ glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+#endif
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
+ tex_xsize = PowerOfTwo(Ywidth);
+ tex_ysize = PowerOfTwo(Yheight);
+ glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(Ywidth),PowerOfTwo(Yheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
+
+ glBindTexture(GL_TEXTURE_2D,(*Uhandle));
+#ifdef _WIN32
+ glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+#else // Hopefully Linux
+ glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+#endif
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
+
+ glBindTexture(GL_TEXTURE_2D,(*Vhandle));
+#ifdef _WIN32
+ glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+#else // Hopefully Linux
+ glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+#endif
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
+}
+
+void LoadYUVPlanes(GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
+ unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight,
+ unsigned char *Ydata,
+ unsigned char *Udata,
+ unsigned char *Vdata)
+{
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ glBindTexture(GL_TEXTURE_2D,Yhandle);
+ glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Ywidth,Yheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Ydata);
+ glEnable(GL_TEXTURE_2D);
+
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glBindTexture(GL_TEXTURE_2D,Uhandle);
+ glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Udata);
+ glEnable(GL_TEXTURE_2D);
+
+ glActiveTextureARB(GL_TEXTURE2_ARB);
+ glBindTexture(GL_TEXTURE_2D,Vhandle);
+ glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Vdata);
+ glEnable(GL_TEXTURE_2D);
+}
+
+
+void Initialize_Backend(unsigned int Ywidth, unsigned int Yheight, unsigned int UVwidth, unsigned int UVheight, GLenum filter)
+{
+ printf("Reinitializing register combiner backend with res %d x %d!\n", Ywidth, Yheight);
+ if (!GL_ARB_multitexture_Init()) exit(0);
+ if (!GL_EXT_paletted_texture_Init()) exit(0);
+ if (!GL_NV_register_combiners_Init()) exit(0);
+ unsigned char Ypal[768];
+ unsigned char Upal[768];
+ unsigned char Vpal[768];
+ float bias[4];
+ float Uscale[4];
+ float Vscale[4];
+ GenerateRGBTables(Ypal,Upal,Vpal,bias,Uscale,Vscale);
+ InitYUVPlanes(&Yhandle,&Uhandle,&Vhandle,Ywidth,Yheight,UVwidth,UVheight,filter,Ypal,Upal,Vpal);
+ SetupCombiners();
+ SetConsts(bias,Uscale,Vscale);
+}
+
+
+void initialize(GLenum filter) {
+ glShadeModel(GL_SMOOTH);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
+ glClearColor(0.0f,0.0f,0.2f,1.0f);
+ Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,filter);
+}