[008/906] gst-indent
This commit is contained in:
parent
925dfd952a
commit
febb402b4b
@ -16,29 +16,29 @@
|
|||||||
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines
|
#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#define GL_GLEXT_PROTOTYPES 1
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
{
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef APIENTRY
|
#ifndef APIENTRY
|
||||||
#define APIENTRY
|
#define APIENTRY
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
|
|
||||||
// Header file version number, required by OpenGL ABI for Linux
|
// Header file version number, required by OpenGL ABI for Linux
|
||||||
//#define GL_GLEXT_VERSION 7
|
//#define GL_GLEXT_VERSION 7
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEW TOKENS TO OPENGL 1.2.1
|
* NEW TOKENS TO OPENGL 1.2.1
|
||||||
*
|
*
|
||||||
@ -80,232 +80,421 @@ extern "C" {
|
|||||||
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
|
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
|
||||||
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
|
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
|
||||||
#define GL_ARB_multitexture 1
|
#define GL_ARB_multitexture 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#ifdef GL_GLEXT_PROTOTYPES
|
#ifdef GL_GLEXT_PROTOTYPES
|
||||||
extern void APIENTRY glActiveTextureARB (GLenum);
|
extern void APIENTRY glActiveTextureARB (GLenum);
|
||||||
extern void APIENTRY glClientActiveTextureARB (GLenum);
|
extern void APIENTRY glClientActiveTextureARB (GLenum);
|
||||||
extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
|
extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
|
||||||
extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
|
extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
|
||||||
extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
|
extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
|
||||||
extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
|
extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
|
||||||
extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
|
extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
|
||||||
extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
|
extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
|
||||||
extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
|
extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
|
||||||
extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
|
extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
|
||||||
extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
|
extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
|
||||||
extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
|
extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
|
||||||
extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
|
extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
|
||||||
extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
|
extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
|
||||||
extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
|
extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
|
||||||
extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
|
extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
|
||||||
extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
|
extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
|
||||||
extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
|
extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
|
||||||
extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
|
extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble,
|
||||||
extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
|
GLdouble);
|
||||||
extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
|
extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
|
||||||
extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
|
extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat,
|
||||||
extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
|
GLfloat);
|
||||||
extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
|
extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
|
||||||
extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
|
extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
|
||||||
extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
|
extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
|
||||||
extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
|
extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort,
|
||||||
extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
|
GLshort);
|
||||||
extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
|
extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
|
||||||
extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
|
extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble,
|
||||||
extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
|
GLdouble, GLdouble);
|
||||||
extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
|
extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
|
||||||
extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
|
extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat,
|
||||||
extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
|
GLfloat, GLfloat);
|
||||||
#endif // GL_GLEXT_PROTOTYPES
|
extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
|
||||||
#else // not _WIN32
|
extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint,
|
||||||
typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
|
GLint);
|
||||||
typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
|
extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
|
extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
|
GLshort, GLshort);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
|
extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
|
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
|
#endif // GL_GLEXT_PROTOTYPES
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
|
#else // not _WIN32
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
|
typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
|
typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
|
GLdouble s);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
|
const GLdouble * v);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
|
GLfloat s);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
|
const GLfloat * v);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
|
GLint s);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
|
const GLint * v);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
|
GLshort s);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
|
const GLshort * v);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
|
GLdouble s, GLdouble t);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
|
const GLdouble * v);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
|
GLfloat s, GLfloat t);
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
|
typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target,
|
||||||
typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
|
const GLfloat * v);
|
||||||
#endif // _WIN32
|
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
|
#ifdef ARB_MULTITEXTURE_INITIALIZE
|
||||||
#include<string.h> // string manipulation for runtime-check
|
#include<string.h> // string manipulation for runtime-check
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
|
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
|
||||||
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
|
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
|
PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
|
PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
|
PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
|
PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
|
PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
|
PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
|
PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
|
||||||
PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
|
PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
|
PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
|
PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
|
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
|
PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
|
PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
|
PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
|
PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
|
||||||
PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
|
PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
|
PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
|
PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
|
PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
|
PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
|
PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
|
PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
|
PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
|
||||||
PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
|
PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
|
PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
|
PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
|
PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
|
PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
|
PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
|
PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
|
PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
|
||||||
PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
|
PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
int CheckForARBMultitextureSupport(void) {
|
#endif // _WIN32
|
||||||
const char search[]="GL_ARB_multitexture";
|
int CheckForARBMultitextureSupport (void)
|
||||||
int i, pos=0;
|
{
|
||||||
int maxpos=strlen(search)-1;
|
const char search[] = "GL_ARB_multitexture";
|
||||||
char extensions[10000];
|
int i, pos = 0;
|
||||||
printf("Getting GLstring, context is %p\n", glXGetCurrentContext());
|
int maxpos = strlen (search) - 1;
|
||||||
strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
|
char extensions[10000];
|
||||||
printf("Examinig GLstring\n");
|
printf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
|
||||||
int len=strlen(extensions);
|
strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
|
||||||
for ( i=0; i<len; i++) {
|
printf ("Examinig GLstring\n");
|
||||||
if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
|
int len = strlen (extensions);
|
||||||
pos=0;
|
for (i = 0; i < len; i++)
|
||||||
while(extensions[i]!=' ') {
|
{
|
||||||
if (extensions[i]==search[pos]) pos++;
|
if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
|
||||||
if ((pos>maxpos) && extensions[i+1]==' ') {
|
pos = 0;
|
||||||
//if (debug)
|
while (extensions[i] != ' ')
|
||||||
{
|
{
|
||||||
//fprintf(stderr, search);
|
if (extensions[i] == search[pos])
|
||||||
//fprintf(stderr, " supported.\n");
|
pos++;
|
||||||
}
|
if ((pos > maxpos) && extensions[i + 1] == ' ') {
|
||||||
return 1;
|
|
||||||
}
|
//if (debug)
|
||||||
++i;
|
{
|
||||||
}
|
|
||||||
}
|
//fprintf(stderr, search);
|
||||||
}
|
//fprintf(stderr, " supported.\n");
|
||||||
//printf(search);
|
}
|
||||||
//printf(" not supported.\n");
|
return 1;
|
||||||
return 0;
|
}
|
||||||
}
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf(search);
|
||||||
|
//printf(" not supported.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int GL_ARB_multitexture_Init (void)
|
||||||
|
{
|
||||||
|
if (!CheckForARBMultitextureSupport ())
|
||||||
|
return 0;
|
||||||
|
|
||||||
int GL_ARB_multitexture_Init(void) {
|
|
||||||
if (!CheckForARBMultitextureSupport()) return 0;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
|
glActiveTextureARB =
|
||||||
if (glActiveTextureARB==NULL) {fprintf(stderr,"glActiveTextureARB not found.\n"); return 0; }
|
(PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress ("glActiveTextureARB");
|
||||||
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");
|
if (glActiveTextureARB == NULL) {
|
||||||
if (glClientActiveTextureARB==NULL) {fprintf(stderr,"glClientActiveTextureARB not found.\n"); return 0; }
|
fprintf (stderr, "glActiveTextureARB not found.\n");
|
||||||
glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) wglGetProcAddress("glMultiTexCoord1dARB");
|
return 0;
|
||||||
if (glMultiTexCoord1dARB==NULL) {fprintf(stderr,"glMultiTexCoord1dARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) wglGetProcAddress("glMultiTexCoord1dvARB");
|
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)
|
||||||
if (glMultiTexCoord1dvARB==NULL) {fprintf(stderr,"glMultiTexCoord1dAvRB not found.\n"); return 0; }
|
wglGetProcAddress ("glClientActiveTextureARB");
|
||||||
glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) wglGetProcAddress("glMultiTexCoord1fARB");
|
if (glClientActiveTextureARB == NULL) {
|
||||||
if (glMultiTexCoord1fARB==NULL) {fprintf(stderr,"glMultiTexCoord1fARB not found.\n"); return 0; }
|
fprintf (stderr, "glClientActiveTextureARB not found.\n");
|
||||||
glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) wglGetProcAddress("glMultiTexCoord1fvARB");
|
return 0;
|
||||||
if (glMultiTexCoord1fvARB==NULL) {fprintf(stderr,"glMultiTexCoord1fvARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) wglGetProcAddress("glMultiTexCoord1iARB");
|
glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)
|
||||||
if (glMultiTexCoord1iARB==NULL) {fprintf(stderr,"glMultiTexCoord1iARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1dARB");
|
||||||
glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) wglGetProcAddress("glMultiTexCoord1ivARB");
|
if (glMultiTexCoord1dARB == NULL) {
|
||||||
if (glMultiTexCoord1ivARB==NULL) {fprintf(stderr,"glMultiTexCoord1ivARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1dARB not found.\n");
|
||||||
glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) wglGetProcAddress("glMultiTexCoord1sARB");
|
return 0;
|
||||||
if (glMultiTexCoord1sARB==NULL) {fprintf(stderr,"glMultiTexCoord1sARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) wglGetProcAddress("glMultiTexCoord1svARB");
|
glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)
|
||||||
if (glMultiTexCoord1svARB==NULL) {fprintf(stderr,"glMultiTexCoord1svARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1dvARB");
|
||||||
glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) wglGetProcAddress("glMultiTexCoord2dARB");
|
if (glMultiTexCoord1dvARB == NULL) {
|
||||||
if (glMultiTexCoord2dARB==NULL) {fprintf(stderr,"glMultiTexCoord2dARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1dAvRB not found.\n");
|
||||||
glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) wglGetProcAddress("glMultiTexCoord2dvARB");
|
return 0;
|
||||||
if (glMultiTexCoord2dvARB==NULL) {fprintf(stderr,"glMultiTexCoord2dAvRB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
|
glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)
|
||||||
if (glMultiTexCoord2fARB==NULL) {fprintf(stderr,"glMultiTexCoord2fARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1fARB");
|
||||||
glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
|
if (glMultiTexCoord1fARB == NULL) {
|
||||||
if (glMultiTexCoord2fvARB==NULL) {fprintf(stderr,"glMultiTexCoord2fvARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1fARB not found.\n");
|
||||||
glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) wglGetProcAddress("glMultiTexCoord2iARB");
|
return 0;
|
||||||
if (glMultiTexCoord2iARB==NULL) {fprintf(stderr,"glMultiTexCoord2iARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) wglGetProcAddress("glMultiTexCoord2ivARB");
|
glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)
|
||||||
if (glMultiTexCoord2ivARB==NULL) {fprintf(stderr,"glMultiTexCoord2ivARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1fvARB");
|
||||||
glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) wglGetProcAddress("glMultiTexCoord2sARB");
|
if (glMultiTexCoord1fvARB == NULL) {
|
||||||
if (glMultiTexCoord2sARB==NULL) {fprintf(stderr,"glMultiTexCoord2sARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1fvARB not found.\n");
|
||||||
glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) wglGetProcAddress("glMultiTexCoord2svARB");
|
return 0;
|
||||||
if (glMultiTexCoord2svARB==NULL) {fprintf(stderr,"glMultiTexCoord2svARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) wglGetProcAddress("glMultiTexCoord3dARB");
|
glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)
|
||||||
if (glMultiTexCoord3dARB==NULL) {fprintf(stderr,"glMultiTexCoord3dARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1iARB");
|
||||||
glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) wglGetProcAddress("glMultiTexCoord3dvARB");
|
if (glMultiTexCoord1iARB == NULL) {
|
||||||
if (glMultiTexCoord3dvARB==NULL) {fprintf(stderr,"glMultiTexCoord3dAvRB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1iARB not found.\n");
|
||||||
glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) wglGetProcAddress("glMultiTexCoord3fARB");
|
return 0;
|
||||||
if (glMultiTexCoord3fARB==NULL) {fprintf(stderr,"glMultiTexCoord3fARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) wglGetProcAddress("glMultiTexCoord3fvARB");
|
glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)
|
||||||
if (glMultiTexCoord3fvARB==NULL) {fprintf(stderr,"glMultiTexCoord3fvARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1ivARB");
|
||||||
glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) wglGetProcAddress("glMultiTexCoord3iARB");
|
if (glMultiTexCoord1ivARB == NULL) {
|
||||||
if (glMultiTexCoord3iARB==NULL) {fprintf(stderr,"glMultiTexCoord3iARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1ivARB not found.\n");
|
||||||
glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) wglGetProcAddress("glMultiTexCoord3ivARB");
|
return 0;
|
||||||
if (glMultiTexCoord3ivARB==NULL) {fprintf(stderr,"glMultiTexCoord3ivARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) wglGetProcAddress("glMultiTexCoord3sARB");
|
glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)
|
||||||
if (glMultiTexCoord3sARB==NULL) {fprintf(stderr,"glMultiTexCoord3sARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1sARB");
|
||||||
glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) wglGetProcAddress("glMultiTexCoord3svARB");
|
if (glMultiTexCoord1sARB == NULL) {
|
||||||
if (glMultiTexCoord3svARB==NULL) {fprintf(stderr,"glMultiTexCoord3svARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1sARB not found.\n");
|
||||||
glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) wglGetProcAddress("glMultiTexCoord4dARB");
|
return 0;
|
||||||
if (glMultiTexCoord4dARB==NULL) {fprintf(stderr,"glMultiTexCoord4dARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) wglGetProcAddress("glMultiTexCoord4dvARB");
|
glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)
|
||||||
if (glMultiTexCoord4dvARB==NULL) {fprintf(stderr,"glMultiTexCoord4dAvRB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord1svARB");
|
||||||
glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) wglGetProcAddress("glMultiTexCoord4fARB");
|
if (glMultiTexCoord1svARB == NULL) {
|
||||||
if (glMultiTexCoord4fARB==NULL) {fprintf(stderr,"glMultiTexCoord4fARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord1svARB not found.\n");
|
||||||
glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) wglGetProcAddress("glMultiTexCoord4fvARB");
|
return 0;
|
||||||
if (glMultiTexCoord4fvARB==NULL) {fprintf(stderr,"glMultiTexCoord4fvARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) wglGetProcAddress("glMultiTexCoord4iARB");
|
glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)
|
||||||
if (glMultiTexCoord4iARB==NULL) {fprintf(stderr,"glMultiTexCoord4iARB not found.\n"); return 0; }
|
wglGetProcAddress ("glMultiTexCoord2dARB");
|
||||||
glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) wglGetProcAddress("glMultiTexCoord4ivARB");
|
if (glMultiTexCoord2dARB == NULL) {
|
||||||
if (glMultiTexCoord4ivARB==NULL) {fprintf(stderr,"glMultiTexCoord4ivARB not found.\n"); return 0; }
|
fprintf (stderr, "glMultiTexCoord2dARB not found.\n");
|
||||||
glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) wglGetProcAddress("glMultiTexCoord4sARB");
|
return 0;
|
||||||
if (glMultiTexCoord4sARB==NULL) {fprintf(stderr,"glMultiTexCoord4sARB not found.\n"); return 0; }
|
}
|
||||||
glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) wglGetProcAddress("glMultiTexCoord4svARB");
|
glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)
|
||||||
if (glMultiTexCoord4svARB==NULL) {fprintf(stderr,"glMultiTexCoord4svARB not found.\n"); return 0; }
|
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
|
#endif // _WIN32
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ARB_MULTITEXTURE_INITIALIZE
|
#endif // ARB_MULTITEXTURE_INITIALIZE
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#endif // not __ARB_MULTITEXTURE_H_
|
#endif // not __ARB_MULTITEXTURE_H_
|
||||||
|
@ -16,29 +16,29 @@
|
|||||||
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines
|
#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#define GL_GLEXT_PROTOTYPES 1
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
{
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef APIENTRY
|
#ifndef APIENTRY
|
||||||
#define APIENTRY
|
#define APIENTRY
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
|
|
||||||
// Header file version number, required by OpenGL ABI for Linux
|
// Header file version number, required by OpenGL ABI for Linux
|
||||||
//#define GL_GLEXT_VERSION 7
|
//#define GL_GLEXT_VERSION 7
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEW TOKENS TO OPENGL 1.2.1
|
* NEW TOKENS TO OPENGL 1.2.1
|
||||||
*
|
*
|
||||||
@ -60,83 +60,128 @@ extern "C" {
|
|||||||
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
|
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
|
||||||
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
|
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
|
||||||
#define GL_EXT_paletted_texture 1
|
#define GL_EXT_paletted_texture 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#ifdef GL_GLEXT_PROTOTYPES
|
#ifdef GL_GLEXT_PROTOTYPES
|
||||||
extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
|
extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum,
|
||||||
extern void APIENTRY glColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
|
const GLvoid *);
|
||||||
extern void APIENTRY glGetColorTableEXT(GLenum, GLenum, GLenum, GLvoid *);
|
extern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum,
|
||||||
extern void APIENTRY glGetColorTableParameterivEXT(GLenum, GLenum, GLint *);
|
GLenum, const GLvoid *);
|
||||||
extern void APIENTRY glGetColorTableParameterfvEXT(GLenum, GLenum, GLfloat *);
|
extern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
|
||||||
#endif // GL_GLEXT_PROTOTYPES
|
extern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum,
|
||||||
#else // _WIN32
|
GLint *);
|
||||||
typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data);
|
extern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum,
|
||||||
typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
|
GLfloat *);
|
||||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC)(GLenum target, GLenum format, GLenum type, GLvoid *data);
|
|
||||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
|
#endif // GL_GLEXT_PROTOTYPES
|
||||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)(GLenum target, GLenum pname, GLfloat *params);
|
#else // _WIN32
|
||||||
#endif // not _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
|
#ifdef EXT_PALETTED_TEXTURE_INITIALIZE
|
||||||
#include<string.h> // string manipulation for runtime-check
|
#include<string.h> // string manipulation for runtime-check
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
|
PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
|
||||||
PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
|
PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
|
||||||
PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
|
PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
|
||||||
PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
|
PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
|
||||||
PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
|
PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
int CheckForEXTPalettedTextureSupport(void) {
|
#endif // _WIN32
|
||||||
const char search[]="GL_EXT_paletted_texture";
|
int CheckForEXTPalettedTextureSupport (void)
|
||||||
int i, pos=0;
|
{
|
||||||
int maxpos=strlen(search)-1;
|
const char search[] = "GL_EXT_paletted_texture";
|
||||||
char extensions[10000];
|
int i, pos = 0;
|
||||||
strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
|
int maxpos = strlen (search) - 1;
|
||||||
int len=strlen(extensions);
|
char extensions[10000];
|
||||||
for (i=0; i<len; i++) {
|
strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
|
||||||
if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
|
int len = strlen (extensions);
|
||||||
pos=0;
|
for (i = 0; i < len; i++)
|
||||||
while(extensions[i]!=' ') {
|
{
|
||||||
if (extensions[i]==search[pos]) pos++;
|
if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
|
||||||
if ((pos>maxpos) && extensions[i+1]==' ') {
|
pos = 0;
|
||||||
//printf(search);
|
while (extensions[i] != ' ')
|
||||||
//printf(" supported.\n");
|
{
|
||||||
return 1;
|
if (extensions[i] == search[pos])
|
||||||
}
|
pos++;
|
||||||
i++;
|
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;
|
||||||
}
|
}
|
||||||
//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
|
#endif // _WIN32
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EXT_PALETTED_TEXTURE_INITIALIZE
|
#endif // EXT_PALETTED_TEXTURE_INITIALIZE
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#endif // not __EXT_PALETTED_TEXTURE_H_
|
#endif // not __EXT_PALETTED_TEXTURE_H_
|
||||||
|
@ -16,29 +16,29 @@
|
|||||||
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
* GLOBAL SWITCHES - enable/disable advanced features of this header
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines
|
#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#define GL_GLEXT_PROTOTYPES 1
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
{
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef APIENTRY
|
#ifndef APIENTRY
|
||||||
#define APIENTRY
|
#define APIENTRY
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
|
|
||||||
// Header file version number, required by OpenGL ABI for Linux
|
// Header file version number, required by OpenGL ABI for Linux
|
||||||
//#define GL_GLEXT_VERSION 7
|
//#define GL_GLEXT_VERSION 7
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEW TOKENS TO OPENGL 1.2.1
|
* NEW TOKENS TO OPENGL 1.2.1
|
||||||
*
|
*
|
||||||
@ -96,123 +96,228 @@ extern "C" {
|
|||||||
#define GL_COLOR_SUM_CLAMP_NV 0x854F
|
#define GL_COLOR_SUM_CLAMP_NV 0x854F
|
||||||
#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
|
#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
|
||||||
#define GL_NV_register_combiners 1
|
#define GL_NV_register_combiners 1
|
||||||
#endif
|
#endif /*
*/
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#ifdef GL_GLEXT_PROTOTYPES
|
#ifdef GL_GLEXT_PROTOTYPES
|
||||||
extern void APIENTRY glCombinerParameterfvNV(GLenum, const GLfloat *);
|
extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
|
||||||
extern void APIENTRY glCombinerParameterivNV(GLenum, const GLint *);
|
extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
|
||||||
extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
|
extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
|
||||||
extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
|
extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
|
||||||
extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
|
extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum,
|
||||||
extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
|
GLenum, GLenum);
|
||||||
extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
|
extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum,
|
||||||
extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
|
GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
|
||||||
extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
|
extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum,
|
||||||
extern void APIENTRY glGetCombinerOutputParameterfvNV(GLenum, GLenum, GLenum, GLfloat *);
|
GLenum);
|
||||||
extern void APIENTRY glGetCombinerOutputParameterivNV(GLenum, GLenum, GLenum, GLint *);
|
extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum,
|
||||||
extern void APIENTRY glGetFinalCombinerInputParameterfvNV(GLenum, GLenum, GLfloat *);
|
GLenum, GLenum, GLfloat *);
|
||||||
extern void APIENTRY glGetFinalCombinerInputParameterivNV(GLenum, GLenum, GLint *);
|
extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum,
|
||||||
#endif // GL_GLEXT_PROTOTYPES
|
GLenum, GLenum, GLint *);
|
||||||
#else // _WIN32
|
extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum,
|
||||||
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
|
GLenum, GLfloat *);
|
||||||
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
|
extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum,
|
||||||
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
|
GLenum, GLint *);
|
||||||
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
|
extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum,
|
||||||
typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
|
GLfloat *);
|
||||||
typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
|
extern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum,
|
||||||
typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
|
GLint *);
|
||||||
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);
|
#endif // GL_GLEXT_PROTOTYPES
|
||||||
typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
|
#else // _WIN32
|
||||||
typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLint *params);
|
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname,
|
||||||
typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params);
|
const GLfloat * params);
|
||||||
typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params);
|
typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname,
|
||||||
#endif // not _WIN32
|
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
|
#ifdef NV_REGISTER_COMBINERS_INITIALIZE
|
||||||
#include<string.h> // string manipulation for runtime-check
|
#include<string.h> // string manipulation for runtime-check
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
|
PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
|
||||||
PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
|
PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
|
||||||
PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
|
PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
|
||||||
PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
|
PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
|
||||||
PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
|
PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
|
||||||
PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
|
PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
|
||||||
PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
|
PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
|
||||||
PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV = NULL;
|
PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV =
|
||||||
PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV = NULL;
|
NULL;
|
||||||
PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV = NULL;
|
PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV =
|
||||||
PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV = NULL;
|
NULL;
|
||||||
PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV = NULL;
|
PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV =
|
||||||
PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV = NULL;
|
NULL;
|
||||||
#endif // _WIN32
|
PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV =
|
||||||
|
NULL;
|
||||||
|
PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC
|
||||||
|
glGetFinalCombinerInputParameterfvNV = NULL;
|
||||||
|
PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC
|
||||||
|
glGetFinalCombinerInputParameterivNV = NULL;
|
||||||
|
|
||||||
int CheckForNVRegisterCombinersSupport(void) {
|
#endif // _WIN32
|
||||||
const char search[]="GL_NV_register_combiners";
|
int CheckForNVRegisterCombinersSupport (void)
|
||||||
int i, pos=0;
|
{
|
||||||
int maxpos=strlen(search)-1;
|
const char search[] = "GL_NV_register_combiners";
|
||||||
char extensions[10000];
|
int i, pos = 0;
|
||||||
strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
|
int maxpos = strlen (search) - 1;
|
||||||
int len=strlen(extensions);
|
char extensions[10000];
|
||||||
for (i=0; i<len; i++) {
|
strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
|
||||||
if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
|
int len = strlen (extensions);
|
||||||
pos=0;
|
for (i = 0; i < len; i++)
|
||||||
while(extensions[i]!=' ') {
|
{
|
||||||
if (extensions[i]==search[pos]) pos++;
|
if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
|
||||||
if ((pos>maxpos) && extensions[i+1]==' ') {
|
pos = 0;
|
||||||
//printf(search);
|
while (extensions[i] != ' ')
|
||||||
// printf(" supported.\n");
|
{
|
||||||
return 1;
|
if (extensions[i] == search[pos])
|
||||||
}
|
pos++;
|
||||||
i++;
|
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;
|
||||||
}
|
}
|
||||||
//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
|
#endif // _WIN32
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NV_REGISTER_COMBINERS_INITIALIZE
|
#endif // NV_REGISTER_COMBINERS_INITIALIZE
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif /*
*/
|
||||||
|
|
||||||
#endif // not __NV_REGISTER_COMBINERS_H_
|
#endif // not __NV_REGISTER_COMBINERS_H_
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
#include "gstglsink.h"
|
#include "gstglsink.h"
|
||||||
|
|
||||||
typedef struct _GstGLImageConnection GstGLImageConnection;
|
typedef struct _GstGLImageConnection GstGLImageConnection;
|
||||||
struct _GstGLImageConnection {
|
struct _GstGLImageConnection
|
||||||
|
{
|
||||||
GstImageConnection conn;
|
GstImageConnection conn;
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
@ -54,47 +55,54 @@ typedef struct _GstNvImage GstNvImage;
|
|||||||
struct _GstNvImage
|
struct _GstNvImage
|
||||||
{
|
{
|
||||||
GstImageData data;
|
GstImageData data;
|
||||||
int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
|
int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
|
||||||
GstGLImageConnection *conn;
|
GstGLImageConnection *conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
|
static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
|
||||||
static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
|
static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
|
||||||
static gboolean gst_gl_nvimage_check_xvideo ();
|
conn);
|
||||||
|
static gboolean gst_gl_nvimage_check_xvideo ();
|
||||||
|
|
||||||
static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
|
static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
|
||||||
static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
|
static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
|
||||||
static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
|
GstCaps * caps);
|
||||||
static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
|
static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
|
||||||
static void gst_gl_nvimage_free_image (GstImageData *image);
|
GstImageConnection * conn);
|
||||||
static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
|
static void gst_gl_nvimage_put_image (GstImageInfo * info,
|
||||||
static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
|
GstImageData * image);
|
||||||
static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
|
static void gst_gl_nvimage_free_image (GstImageData * image);
|
||||||
|
static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
|
||||||
|
|
||||||
GstImagePlugin* get_gl_nvimage_plugin(void)
|
GstImagePlugin *
|
||||||
|
get_gl_nvimage_plugin (void)
|
||||||
{
|
{
|
||||||
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
|
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
|
||||||
gst_gl_nvimage_set_caps,
|
gst_gl_nvimage_set_caps,
|
||||||
gst_gl_nvimage_get_image,
|
gst_gl_nvimage_get_image,
|
||||||
gst_gl_nvimage_put_image,
|
gst_gl_nvimage_put_image,
|
||||||
gst_gl_nvimage_free_image};
|
gst_gl_nvimage_free_image
|
||||||
|
};
|
||||||
|
|
||||||
return &plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GstGLImageInfo *
|
static GstGLImageInfo *
|
||||||
gst_gl_nvimage_info (GstImageInfo *info)
|
gst_gl_nvimage_info (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
|
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (GstGLImageInfo *) info;
|
return (GstGLImageInfo *) info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLImageConnection *
|
static GstGLImageConnection *
|
||||||
gst_gl_nvimage_connection (GstImageConnection *conn)
|
gst_gl_nvimage_connection (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
|
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -105,15 +113,18 @@ gboolean
|
|||||||
gst_gl_nvimage_check_xvideo ()
|
gst_gl_nvimage_check_xvideo ()
|
||||||
{
|
{
|
||||||
//int ver, rel, req, ev, err;
|
//int ver, rel, req, ev, err;
|
||||||
printf("Checking NVidia OpenGL extensions.\n");
|
printf ("Checking NVidia OpenGL extensions.\n");
|
||||||
if (!GL_ARB_multitexture_Init()) return FALSE;
|
if (!GL_ARB_multitexture_Init ())
|
||||||
if (!GL_EXT_paletted_texture_Init()) return FALSE;
|
return FALSE;
|
||||||
if (!GL_NV_register_combiners_Init()) return FALSE;
|
if (!GL_EXT_paletted_texture_Init ())
|
||||||
|
return FALSE;
|
||||||
|
if (!GL_NV_register_combiners_Init ())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
|
if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -121,7 +132,7 @@ gst_gl_nvimage_check_xvideo ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_gl_nvimage_get_caps (GstImageInfo *info)
|
gst_gl_nvimage_get_caps (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
//gint i;
|
//gint i;
|
||||||
//int adaptors;
|
//int adaptors;
|
||||||
@ -129,33 +140,31 @@ gst_gl_nvimage_get_caps (GstImageInfo *info)
|
|||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
|
|
||||||
g_warning("nvimage get caps called, context %p !\n", glXGetCurrentContext());
|
g_warning ("nvimage get caps called, context %p !\n",
|
||||||
|
glXGetCurrentContext ());
|
||||||
/* we don't handle these image information */
|
/* we don't handle these image information */
|
||||||
if (xinfo == NULL)
|
if (xinfo == NULL) {
|
||||||
{
|
printf ("Invalid XInfo struct !\n");
|
||||||
printf("Invalid XInfo struct !\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gst_gl_nvimage_check_xvideo () == FALSE)
|
|
||||||
{
|
|
||||||
g_warning("GL_NVImage: Server has no NVidia extension support\n");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
caps = gst_caps_append (caps, GST_CAPS_NEW (
|
if (gst_gl_nvimage_check_xvideo () == FALSE) {
|
||||||
"nvimage_caps",
|
g_warning ("GL_NVImage: Server has no NVidia extension support\n");
|
||||||
"video/x-raw-yuv",
|
return NULL;
|
||||||
"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))
|
caps = gst_caps_append (caps, GST_CAPS_NEW ("nvimage_caps",
|
||||||
);
|
"video/x-raw-yuv",
|
||||||
g_warning("nvimage returns caps !\n");
|
"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))
|
||||||
|
);
|
||||||
|
g_warning ("nvimage returns caps !\n");
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstImageConnection *
|
static GstImageConnection *
|
||||||
gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
|
||||||
{
|
{
|
||||||
//gint i, j = 0;
|
//gint i, j = 0;
|
||||||
//int adaptors;
|
//int adaptors;
|
||||||
@ -165,7 +174,8 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
guint32 format;
|
guint32 format;
|
||||||
|
|
||||||
/* we don't handle these image information */
|
/* we don't handle these image information */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
conn = g_new0 (GstGLImageConnection, 1);
|
conn = g_new0 (GstGLImageConnection, 1);
|
||||||
conn->conn.open_conn = gst_gl_nvimage_open_conn;
|
conn->conn.open_conn = gst_gl_nvimage_open_conn;
|
||||||
@ -173,18 +183,14 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
conn->conn.free_conn = gst_gl_nvimage_free_conn;
|
conn->conn.free_conn = gst_gl_nvimage_free_conn;
|
||||||
|
|
||||||
gst_caps_get (caps,
|
gst_caps_get (caps,
|
||||||
"width", &conn->w,
|
"width", &conn->w, "height", &conn->h, "format", &format, NULL);
|
||||||
"height", &conn->h,
|
|
||||||
"format", &format,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
|
// 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'))
|
if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2')) {
|
||||||
{
|
GST_DEBUG ("GL_NVImage: Format is invalid !\n");
|
||||||
GST_DEBUG ("GL_NVImage: Format is invalid !\n");
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
if (0) //conn->port == (XvPortID) -1)
|
||||||
if (0) //conn->port == (XvPortID) -1)
|
|
||||||
{
|
{
|
||||||
/* this happens if the plugin can't handle the caps, so no warning */
|
/* this happens if the plugin can't handle the caps, so no warning */
|
||||||
g_free (conn);
|
g_free (conn);
|
||||||
@ -196,31 +202,32 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstImageData *
|
static GstImageData *
|
||||||
gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstNvImage *image;
|
GstNvImage *image;
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
if (nvconn == NULL) return NULL;
|
return NULL;
|
||||||
|
if (nvconn == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// I should also check the current GLX context !
|
// I should also check the current GLX context !
|
||||||
// Ah, Don't have to, I am guarantueed to be in the same thread as put_image
|
// Ah, Don't have to, I am guarantueed to be in the same thread as put_image
|
||||||
|
|
||||||
image = g_new0(GstNvImage, 1);
|
image = g_new0 (GstNvImage, 1);
|
||||||
|
|
||||||
image->data.size = nvconn->w * nvconn->h * 3/2;
|
image->data.size = nvconn->w * nvconn->h * 3 / 2;
|
||||||
|
|
||||||
//g_warning("Allocating %d bytes from main memory !", image->data.size);
|
//g_warning("Allocating %d bytes from main memory !", image->data.size);
|
||||||
image->data.data = g_malloc(image->data.size);
|
image->data.data = g_malloc (image->data.size);
|
||||||
//image->slot = AGP_BUFSLOTS; // no AGP slot
|
//image->slot = AGP_BUFSLOTS; // no AGP slot
|
||||||
|
|
||||||
image->conn = nvconn;
|
image->conn = nvconn;
|
||||||
|
|
||||||
if (image->data.data == NULL)
|
if (image->data.data == NULL) {
|
||||||
{
|
|
||||||
g_warning ("GL_NvImage: data allocation failed!");
|
g_warning ("GL_NvImage: data allocation failed!");
|
||||||
g_free (image);
|
g_free (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -230,7 +237,7 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
|
gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
|
||||||
{
|
{
|
||||||
GstNvImage *im = (GstNvImage *) image;
|
GstNvImage *im = (GstNvImage *) image;
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
@ -242,174 +249,181 @@ gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
|
|||||||
|
|
||||||
unsigned char *buf_y = im->data.data;
|
unsigned char *buf_y = im->data.data;
|
||||||
unsigned char *buf_v = (buf_y + img_width * img_height);
|
unsigned char *buf_v = (buf_y + img_width * img_height);
|
||||||
unsigned char *buf_u = buf_v + ((img_width/2) * (img_height/2));
|
unsigned char *buf_u = buf_v + ((img_width / 2) * (img_height / 2));
|
||||||
|
|
||||||
/* checks omitted for speed (and lazyness), do we need them? */
|
/* checks omitted for speed (and lazyness), do we need them? */
|
||||||
g_assert (xinfo != NULL);
|
g_assert (xinfo != NULL);
|
||||||
|
|
||||||
// both upload the video, and redraw the screen
|
// both upload the video, and redraw the screen
|
||||||
//glClearColor(0,0.5, 0.3,1.0); // a test color
|
//glClearColor(0,0.5, 0.3,1.0); // a test color
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity ();
|
||||||
glTranslatef(0.0, 0.0, -5.0);
|
glTranslatef (0.0, 0.0, -5.0);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (xinfo->info.demo)
|
if (xinfo->info.demo) {
|
||||||
{
|
//g_print("Putting image, context is %p\n", glXGetCurrentContext());
|
||||||
//g_print("Putting image, context is %p\n", glXGetCurrentContext());
|
|
||||||
|
|
||||||
glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
|
glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
|
||||||
glRotatef(180.0*sin(xinfo->rotX),1,0,0);
|
glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
|
||||||
glRotatef(180.0*cos(xinfo->rotY),0,1,0);
|
glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
|
||||||
|
|
||||||
xinfo->rotX += 0.01;
|
xinfo->rotX += 0.01;
|
||||||
xinfo->rotY -= 0.015;
|
xinfo->rotY -= 0.015;
|
||||||
float zoom = xinfo->zoom;
|
float zoom = xinfo->zoom;
|
||||||
glScalef(zoom,zoom,zoom);
|
|
||||||
//glScalef(0.1,0.1,0.1);
|
|
||||||
|
|
||||||
if (xinfo->zoom > 2.0)
|
glScalef (zoom, zoom, zoom);
|
||||||
xinfo->zoomdir = -0.01;
|
//glScalef(0.1,0.1,0.1);
|
||||||
|
|
||||||
if (xinfo->zoom < 1.0)
|
if (xinfo->zoom > 2.0)
|
||||||
xinfo->zoomdir = 0.01;
|
xinfo->zoomdir = -0.01;
|
||||||
|
|
||||||
xinfo->zoom += xinfo->zoomdir;
|
if (xinfo->zoom < 1.0)
|
||||||
}
|
xinfo->zoomdir = 0.01;
|
||||||
|
|
||||||
|
xinfo->zoom += xinfo->zoomdir;
|
||||||
|
}
|
||||||
//Draws the surface rectangle
|
//Draws the surface rectangle
|
||||||
|
|
||||||
if (Ywidth != im->conn->w || Yheight != im->conn->h)
|
if (Ywidth != im->conn->w || Yheight != im->conn->h) {
|
||||||
{
|
Ywidth = im->conn->w;
|
||||||
Ywidth = im->conn->w; Yheight = im->conn->h; UVwidth = im->conn->w/2; UVheight = im->conn->h/2;
|
Yheight = im->conn->h;
|
||||||
Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
|
UVwidth = im->conn->w / 2;
|
||||||
|
UVheight = im->conn->h / 2;
|
||||||
|
Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadYUVPlanes(Yhandle,Uhandle,Vhandle,img_width,img_height,uv_width,uv_height,buf_y,buf_u,buf_v);
|
LoadYUVPlanes (Yhandle, Uhandle, Vhandle, img_width, img_height, uv_width,
|
||||||
float xmax = (float)(im->conn->w-1)/tex_xsize;
|
uv_height, buf_y, buf_u, buf_v);
|
||||||
float ymax = (float)(im->conn->h-1)/tex_ysize;
|
float xmax = (float) (im->conn->w - 1) / tex_xsize;
|
||||||
|
float ymax = (float) (im->conn->h - 1) / tex_ysize;
|
||||||
|
|
||||||
/* Upload the texture here */
|
/* Upload the texture here */
|
||||||
//g_warning("PUTTING IMAGE %f %f %d %d\n", xmax, ymax, tex_xsize, tex_ysize);
|
//g_warning("PUTTING IMAGE %f %f %d %d\n", xmax, ymax, tex_xsize, tex_ysize);
|
||||||
|
|
||||||
//glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
|
//glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
|
||||||
glBegin(GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
float aspect = img_width/(float)img_height;
|
float aspect = img_width / (float) img_height;
|
||||||
float hor = aspect;
|
float hor = aspect;
|
||||||
|
|
||||||
//g_print("Drawing vertices, context is %p\n", glXGetCurrentContext());
|
//g_print("Drawing vertices, context is %p\n", glXGetCurrentContext());
|
||||||
glNormal3f(0, -1, 0);
|
glNormal3f (0, -1, 0);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
|
glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, 0);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
|
glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, 0);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,0);
|
glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, 0);
|
||||||
glVertex3f(-hor,1,0);
|
glVertex3f (-hor, 1, 0);
|
||||||
|
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, ymax);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, ymax);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, ymax);
|
||||||
glVertex3f(-hor,-1,0);
|
glVertex3f (-hor, -1, 0);
|
||||||
|
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, ymax);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, ymax);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,ymax);
|
glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, ymax);
|
||||||
glVertex3f(hor,-1,0);
|
glVertex3f (hor, -1, 0);
|
||||||
|
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,0);
|
glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, 0);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,0);
|
glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, 0);
|
||||||
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,0);
|
glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, 0);
|
||||||
glVertex3f(hor,1,0);
|
glVertex3f (hor, 1, 0);
|
||||||
|
|
||||||
glEnd();
|
glEnd ();
|
||||||
|
|
||||||
if (xinfo->info.dumpvideo)
|
if (xinfo->info.dumpvideo) {
|
||||||
{
|
static int framenr = 0;
|
||||||
static int framenr = 0;
|
char capfilename[255];
|
||||||
char capfilename[255];
|
static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
|
||||||
static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
// hmmmm, is this reentrant ?!
|
// hmmmm, is this reentrant ?!
|
||||||
if (cap_image_data == NULL)
|
if (cap_image_data == NULL)
|
||||||
cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
|
cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
|
||||||
|
|
||||||
if (cap_image_data2 == NULL)
|
if (cap_image_data2 == NULL)
|
||||||
cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
|
cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
|
||||||
|
|
||||||
printf("Recording frame #%d\n", framenr);
|
printf ("Recording frame #%d\n", framenr);
|
||||||
glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
|
glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
|
||||||
// invert the pixels
|
cap_image_data);
|
||||||
for (i = 0; i < img_height; i++)
|
// invert the pixels
|
||||||
memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
|
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);
|
sprintf (capfilename, "cap%04d.ppm", framenr);
|
||||||
FILE *outfile = fopen(capfilename, "wb");
|
FILE *outfile = fopen (capfilename, "wb");
|
||||||
if (outfile != NULL)
|
|
||||||
{
|
if (outfile != NULL) {
|
||||||
fprintf(outfile, "P6\n");
|
fprintf (outfile, "P6\n");
|
||||||
fprintf(outfile,"# created by glsink from GStreamer\n");
|
fprintf (outfile, "# created by glsink from GStreamer\n");
|
||||||
fprintf(outfile,"%d %d\n",img_width,img_height);
|
fprintf (outfile, "%d %d\n", img_width, img_height);
|
||||||
fprintf(outfile,"255\n");
|
fprintf (outfile, "255\n");
|
||||||
fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
|
fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
|
||||||
fclose(outfile);
|
outfile);
|
||||||
}
|
fclose (outfile);
|
||||||
framenr++;
|
|
||||||
}
|
}
|
||||||
|
framenr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
glXSwapBuffers(xinfo->dpy, xinfo->win);
|
glXSwapBuffers (xinfo->dpy, xinfo->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_free_image (GstImageData *image)
|
gst_gl_nvimage_free_image (GstImageData * image)
|
||||||
{
|
{
|
||||||
GstNvImage *im = (GstNvImage *) image;
|
GstNvImage *im = (GstNvImage *) image;
|
||||||
|
|
||||||
g_return_if_fail (im != NULL);
|
g_return_if_fail (im != NULL);
|
||||||
GstGLImageConnection *nvconn = im->conn;
|
GstGLImageConnection *nvconn = im->conn;
|
||||||
|
|
||||||
if (im->slot < AGP_BUFSLOTS)
|
if (im->slot < AGP_BUFSLOTS) {
|
||||||
{
|
nvconn->m_bufslots[im->slot] = 0;
|
||||||
nvconn->m_bufslots[im->slot] = 0;
|
} else
|
||||||
}
|
g_free (im->data.data);
|
||||||
else
|
|
||||||
g_free(im->data.data);
|
|
||||||
|
|
||||||
g_free (im);
|
g_free (im);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
//GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
//GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
||||||
|
|
||||||
g_print("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
|
g_print
|
||||||
|
("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
|
||||||
{
|
{
|
||||||
Ywidth = TEX_XSIZE; Yheight = TEX_YSIZE; UVwidth = TEX_XSIZE/2; UVheight = TEX_YSIZE/2;
|
Ywidth = TEX_XSIZE;
|
||||||
Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
|
Yheight = TEX_YSIZE;
|
||||||
|
UVwidth = TEX_XSIZE / 2;
|
||||||
|
UVheight = TEX_YSIZE / 2;
|
||||||
|
Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
|
||||||
}
|
}
|
||||||
g_print("Done\n");
|
g_print ("Done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
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
|
// anything needed in here ? Oh, maybe drawing de-init, or something
|
||||||
glDeleteTextures(1, &xconn->ytex_id);
|
glDeleteTextures (1, &xconn->ytex_id);
|
||||||
glDeleteTextures(1, &xconn->uvtex_id);
|
glDeleteTextures (1, &xconn->uvtex_id);
|
||||||
glDeleteTextures(1, &xconn->septex_id);
|
glDeleteTextures (1, &xconn->septex_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_free_conn (GstImageConnection *conn)
|
gst_gl_nvimage_free_conn (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
||||||
|
|
||||||
g_free (nvconn);
|
g_free (nvconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
#include "gstglsink.h"
|
#include "gstglsink.h"
|
||||||
|
|
||||||
typedef struct _GstGLImageConnection GstGLImageConnection;
|
typedef struct _GstGLImageConnection GstGLImageConnection;
|
||||||
struct _GstGLImageConnection {
|
struct _GstGLImageConnection
|
||||||
|
{
|
||||||
GstImageConnection conn;
|
GstImageConnection conn;
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
@ -54,47 +55,54 @@ typedef struct _GstNvImage GstNvImage;
|
|||||||
struct _GstNvImage
|
struct _GstNvImage
|
||||||
{
|
{
|
||||||
GstImageData data;
|
GstImageData data;
|
||||||
int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
|
int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
|
||||||
GstGLImageConnection *conn;
|
GstGLImageConnection *conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
|
static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
|
||||||
static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
|
static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
|
||||||
static gboolean gst_gl_nvimage_check_xvideo ();
|
conn);
|
||||||
|
static gboolean gst_gl_nvimage_check_xvideo ();
|
||||||
|
|
||||||
static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
|
static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
|
||||||
static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
|
static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
|
||||||
static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
|
GstCaps * caps);
|
||||||
static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
|
static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
|
||||||
static void gst_gl_nvimage_free_image (GstImageData *image);
|
GstImageConnection * conn);
|
||||||
static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
|
static void gst_gl_nvimage_put_image (GstImageInfo * info,
|
||||||
static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
|
GstImageData * image);
|
||||||
static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
|
static void gst_gl_nvimage_free_image (GstImageData * image);
|
||||||
|
static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
|
||||||
|
|
||||||
GstImagePlugin* get_gl_nvimage_plugin(void)
|
GstImagePlugin *
|
||||||
|
get_gl_nvimage_plugin (void)
|
||||||
{
|
{
|
||||||
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
|
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
|
||||||
gst_gl_nvimage_set_caps,
|
gst_gl_nvimage_set_caps,
|
||||||
gst_gl_nvimage_get_image,
|
gst_gl_nvimage_get_image,
|
||||||
gst_gl_nvimage_put_image,
|
gst_gl_nvimage_put_image,
|
||||||
gst_gl_nvimage_free_image};
|
gst_gl_nvimage_free_image
|
||||||
|
};
|
||||||
|
|
||||||
return &plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GstGLImageInfo *
|
static GstGLImageInfo *
|
||||||
gst_gl_nvimage_info (GstImageInfo *info)
|
gst_gl_nvimage_info (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
|
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (GstGLImageInfo *) info;
|
return (GstGLImageInfo *) info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLImageConnection *
|
static GstGLImageConnection *
|
||||||
gst_gl_nvimage_connection (GstImageConnection *conn)
|
gst_gl_nvimage_connection (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
|
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -109,7 +117,7 @@ gst_gl_nvimage_check_xvideo ()
|
|||||||
#if 0
|
#if 0
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
|
if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -117,7 +125,7 @@ gst_gl_nvimage_check_xvideo ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_gl_nvimage_get_caps (GstImageInfo *info)
|
gst_gl_nvimage_get_caps (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
int adaptors;
|
int adaptors;
|
||||||
@ -126,26 +134,25 @@ gst_gl_nvimage_get_caps (GstImageInfo *info)
|
|||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
|
|
||||||
/* we don't handle these image information */
|
/* we don't handle these image information */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (gst_gl_nvimage_check_xvideo () == FALSE)
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
caps = gst_caps_append (caps, GST_CAPS_NEW (
|
caps = gst_caps_append (caps, GST_CAPS_NEW ("xvimage_caps",
|
||||||
"xvimage_caps",
|
"video/raw",
|
||||||
"video/raw",
|
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
|
||||||
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
|
"width", GST_PROPS_INT_RANGE (0, 1024),
|
||||||
"width", GST_PROPS_INT_RANGE (0, 1024),
|
"height", GST_PROPS_INT_RANGE (0, 1024))
|
||||||
"height", GST_PROPS_INT_RANGE (0, 1024))
|
);
|
||||||
);
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstImageConnection *
|
static GstImageConnection *
|
||||||
gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gint i, j = 0;
|
gint i, j = 0;
|
||||||
int adaptors;
|
int adaptors;
|
||||||
@ -155,7 +162,8 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
guint32 format;
|
guint32 format;
|
||||||
|
|
||||||
/* we don't handle these image information */
|
/* we don't handle these image information */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
conn = g_new0 (GstGLImageConnection, 1);
|
conn = g_new0 (GstGLImageConnection, 1);
|
||||||
conn->conn.open_conn = gst_gl_nvimage_open_conn;
|
conn->conn.open_conn = gst_gl_nvimage_open_conn;
|
||||||
@ -163,30 +171,27 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
conn->conn.free_conn = gst_gl_nvimage_free_conn;
|
conn->conn.free_conn = gst_gl_nvimage_free_conn;
|
||||||
|
|
||||||
gst_caps_get (caps,
|
gst_caps_get (caps,
|
||||||
"width", &conn->w,
|
"width", &conn->w, "height", &conn->h, "format", &format, NULL);
|
||||||
"height", &conn->h,
|
|
||||||
"format", &format,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
|
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
|
||||||
if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
|
if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
|
||||||
{
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
if (0) //conn->port == (XvPortID) -1)
|
||||||
if (0) //conn->port == (XvPortID) -1)
|
|
||||||
{
|
{
|
||||||
/* this happens if the plugin can't handle the caps, so no warning */
|
/* this happens if the plugin can't handle the caps, so no warning */
|
||||||
g_free (conn);
|
g_free (conn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image", caps);
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image",
|
||||||
|
caps);
|
||||||
return (GstImageConnection *) conn;
|
return (GstImageConnection *) conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstImageData *
|
static GstImageData *
|
||||||
gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstNvImage *image;
|
GstNvImage *image;
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
@ -194,37 +199,36 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
|||||||
int slot = 0;
|
int slot = 0;
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
if (nvconn == NULL) return NULL;
|
return NULL;
|
||||||
|
if (nvconn == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// I should also check the current GLX context !
|
// I should also check the current GLX context !
|
||||||
// Ah, Don't have to, I am guarantueed to always be in the same thread
|
// Ah, Don't have to, I am guarantueed to always be in the same thread
|
||||||
|
|
||||||
image = g_new0(GstNvImage, 1);
|
image = g_new0 (GstNvImage, 1);
|
||||||
|
|
||||||
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++) {
|
||||||
{
|
if (!nvconn->m_bufslots[slot])
|
||||||
if (!nvconn->m_bufslots[slot]) break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->data.size = nvconn->w * nvconn->h * 3/2;
|
image->data.size = nvconn->w * nvconn->h * 3 / 2;
|
||||||
|
|
||||||
if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
|
if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
|
||||||
{
|
{
|
||||||
image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
|
image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
|
||||||
image->slot = slot; // store for freeing
|
image->slot = slot; // store for freeing
|
||||||
nvconn->m_bufslots[slot] = 1; // it is now taken
|
nvconn->m_bufslots[slot] = 1; // it is now taken
|
||||||
}
|
} else {
|
||||||
else
|
g_warning ("Allocating from main memory !");
|
||||||
{
|
image->data.data = g_malloc (image->data.size);
|
||||||
g_warning("Allocating from main memory !");
|
image->slot = AGP_BUFSLOTS; // no AGP slot
|
||||||
image->data.data = g_malloc(image->data.size);
|
}
|
||||||
image->slot = AGP_BUFSLOTS; // no AGP slot
|
|
||||||
}
|
|
||||||
image->conn = nvconn;
|
image->conn = nvconn;
|
||||||
|
|
||||||
if (image->data.data == NULL)
|
if (image->data.data == NULL) {
|
||||||
{
|
|
||||||
g_warning ("GL_NvImage: data allocation failed!");
|
g_warning ("GL_NvImage: data allocation failed!");
|
||||||
g_free (image);
|
g_free (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -234,7 +238,7 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
|
gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
|
||||||
{
|
{
|
||||||
GstNvImage *im = (GstNvImage *) image;
|
GstNvImage *im = (GstNvImage *) image;
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
@ -243,156 +247,159 @@ gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
|
|||||||
g_assert (xinfo != NULL);
|
g_assert (xinfo != NULL);
|
||||||
|
|
||||||
/* Upload the texture here */
|
/* Upload the texture here */
|
||||||
g_warning("PUTTING IMAGE - BROOOKEN");
|
g_warning ("PUTTING IMAGE - BROOOKEN");
|
||||||
|
|
||||||
// both upload the video, and redraw the screen
|
// both upload the video, and redraw the screen
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix ();
|
||||||
//glTranslatef(0,1,0);
|
//glTranslatef(0,1,0);
|
||||||
glRotatef(xinfo->rotX-250,1,0,0);
|
glRotatef (xinfo->rotX - 250, 1, 0, 0);
|
||||||
glRotatef(xinfo->rotY,0,1,0);
|
glRotatef (xinfo->rotY, 0, 1, 0);
|
||||||
int zoom = xinfo->zoom;
|
int zoom = xinfo->zoom;
|
||||||
glScaled(zoom,zoom,zoom);
|
|
||||||
|
glScaled (zoom, zoom, zoom);
|
||||||
//Draws the surface rectangle
|
//Draws the surface rectangle
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, im->conn->ytex_id);
|
glBindTexture (GL_TEXTURE_2D, im->conn->ytex_id);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
|
||||||
GL_UNSIGNED_BYTE, im->data.data);
|
GL_UNSIGNED_BYTE, im->data.data);
|
||||||
float xmax = (float)im->conn->w/TEX_XSIZE;
|
float xmax = (float) im->conn->w / TEX_XSIZE;
|
||||||
float ymax = (float)im->conn->h/TEX_YSIZE;
|
float ymax = (float) im->conn->h / TEX_YSIZE;
|
||||||
|
|
||||||
glColor4f(1,1,1,1);
|
glColor4f (1, 1, 1, 1);
|
||||||
glBegin(GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
glNormal3f(0, -1, 0);
|
glNormal3f (0, -1, 0);
|
||||||
|
|
||||||
glTexCoord2f(xmax, 0);
|
glTexCoord2f (xmax, 0);
|
||||||
glVertex3f(4,0,-4);
|
glVertex3f (4, 0, -4);
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f (0, 0);
|
||||||
glVertex3f(-4,0,-4);
|
glVertex3f (-4, 0, -4);
|
||||||
|
|
||||||
glTexCoord2f(0, ymax);
|
glTexCoord2f (0, ymax);
|
||||||
glVertex3f(-4,0,4);
|
glVertex3f (-4, 0, 4);
|
||||||
|
|
||||||
glTexCoord2f(xmax, ymax);
|
glTexCoord2f (xmax, ymax);
|
||||||
glVertex3f(4,0,4);
|
glVertex3f (4, 0, 4);
|
||||||
|
|
||||||
glEnd();
|
glEnd ();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix ();
|
||||||
|
|
||||||
glXSwapBuffers(xinfo->dpy, xinfo->win);
|
glXSwapBuffers (xinfo->dpy, xinfo->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_free_image (GstImageData *image)
|
gst_gl_nvimage_free_image (GstImageData * image)
|
||||||
{
|
{
|
||||||
GstNvImage *im = (GstNvImage *) image;
|
GstNvImage *im = (GstNvImage *) image;
|
||||||
|
|
||||||
g_return_if_fail (im != NULL);
|
g_return_if_fail (im != NULL);
|
||||||
GstGLImageConnection *nvconn = im->conn;
|
GstGLImageConnection *nvconn = im->conn;
|
||||||
|
|
||||||
if (im->slot < AGP_BUFSLOTS)
|
if (im->slot < AGP_BUFSLOTS) {
|
||||||
{
|
nvconn->m_bufslots[im->slot] = 0;
|
||||||
nvconn->m_bufslots[im->slot] = 0;
|
} else
|
||||||
}
|
g_free (im->data.data);
|
||||||
else
|
|
||||||
g_free(im->data.data);
|
|
||||||
|
|
||||||
g_free (im);
|
g_free (im);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
||||||
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
||||||
|
|
||||||
unsigned char data_sep[2][2] = {{0, 255}, {0, 255}};
|
unsigned char data_sep[2][2] = { {0, 255}, {0, 255} };
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
g_warning("Opening NVidia Connection");
|
g_warning ("Opening NVidia Connection");
|
||||||
xconn->m_memory = (unsigned char*)glXAllocateMemoryNV(AGP_BUFSLOTS*YUVTEX_SIZE, 0, 1.0, 1.0);
|
xconn->m_memory =
|
||||||
|
(unsigned char *) glXAllocateMemoryNV (AGP_BUFSLOTS * YUVTEX_SIZE, 0, 1.0,
|
||||||
|
1.0);
|
||||||
|
|
||||||
if (!xconn->m_memory)
|
if (!xconn->m_memory) {
|
||||||
{
|
printf
|
||||||
printf("Unable to acquire graphics card mem... will acquire in normal memory.\n");
|
("Unable to acquire graphics card mem... will acquire in normal memory.\n");
|
||||||
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
||||||
xconn->m_bufslots[slot] = 1;
|
xconn->m_bufslots[slot] = 1;
|
||||||
}
|
} else {
|
||||||
else
|
// maybe this fast writable memory, awfully slow to read from, though
|
||||||
{
|
glPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV,
|
||||||
// maybe this fast writable memory, awfully slow to read from, though
|
AGP_BUFSLOTS * YUVTEX_SIZE, xconn->m_memory);
|
||||||
glPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV, AGP_BUFSLOTS*YUVTEX_SIZE, xconn->m_memory);
|
glEnableClientState (GL_WRITE_PIXEL_DATA_RANGE_NV);
|
||||||
glEnableClientState(GL_WRITE_PIXEL_DATA_RANGE_NV);
|
|
||||||
|
|
||||||
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
||||||
xconn->m_bufslots[slot] = 0;
|
xconn->m_bufslots[slot] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
glGenTextures(1, &xconn->ytex_id);
|
glGenTextures (1, &xconn->ytex_id);
|
||||||
glBindTexture(GL_TEXTURE_2D, xconn->ytex_id);
|
glBindTexture (GL_TEXTURE_2D, xconn->ytex_id);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
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_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
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);
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0,
|
||||||
|
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
glActiveTextureARB (GL_TEXTURE1_ARB);
|
||||||
glGenTextures(1, &xconn->uvtex_id);
|
glGenTextures (1, &xconn->uvtex_id);
|
||||||
glBindTexture(GL_TEXTURE_2D, xconn->uvtex_id);
|
glBindTexture (GL_TEXTURE_2D, xconn->uvtex_id);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
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);
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE / 2,
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
TEX_YSIZE / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||||
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_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
|
||||||
|
|
||||||
glActiveTextureARB(GL_TEXTURE2_ARB);
|
glActiveTextureARB (GL_TEXTURE2_ARB);
|
||||||
glGenTextures(1, &xconn->septex_id);
|
glGenTextures (1, &xconn->septex_id);
|
||||||
glBindTexture(GL_TEXTURE_2D, xconn->septex_id);
|
glBindTexture (GL_TEXTURE_2D, xconn->septex_id);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data_sep);
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE,
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
GL_UNSIGNED_BYTE, data_sep);
|
||||||
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_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
|
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);
|
glFlushPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV);
|
||||||
//glEnable(GL_TEXTURE_2D);
|
//glEnable(GL_TEXTURE_2D);
|
||||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
glActiveTextureARB (GL_TEXTURE0_ARB);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
glActiveTextureARB (GL_TEXTURE1_ARB);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
glActiveTextureARB(GL_TEXTURE2_ARB);
|
glActiveTextureARB (GL_TEXTURE2_ARB);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
glActiveTextureARB (GL_TEXTURE0_ARB);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
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
|
// anything needed in here ? Oh, maybe drawing de-init, or something
|
||||||
glDeleteTextures(1, &xconn->ytex_id);
|
glDeleteTextures (1, &xconn->ytex_id);
|
||||||
glDeleteTextures(1, &xconn->uvtex_id);
|
glDeleteTextures (1, &xconn->uvtex_id);
|
||||||
glDeleteTextures(1, &xconn->septex_id);
|
glDeleteTextures (1, &xconn->septex_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_nvimage_free_conn (GstImageConnection *conn)
|
gst_gl_nvimage_free_conn (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
||||||
|
|
||||||
g_free (nvconn);
|
g_free (nvconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
typedef struct _GstGLImageConnection GstGLImageConnection;
|
typedef struct _GstGLImageConnection GstGLImageConnection;
|
||||||
|
|
||||||
// this contains everything to draw an image, including all necessary graphics card data.
|
// this contains everything to draw an image, including all necessary graphics card data.
|
||||||
struct _GstGLImageConnection {
|
struct _GstGLImageConnection
|
||||||
|
{
|
||||||
GstImageConnection conn;
|
GstImageConnection conn;
|
||||||
Display *dpy; // the Xlib drawing context
|
Display *dpy; // the Xlib drawing context
|
||||||
GLXContext ctx; // The GLX drawing context
|
GLXContext ctx; // The GLX drawing context
|
||||||
gint w, h;
|
gint w, h;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
|
|
||||||
@ -51,41 +52,48 @@ struct _GstGLImage
|
|||||||
GstGLImageConnection *conn;
|
GstGLImageConnection *conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstGLImageInfo * gst_gl_rgbimage_info (GstImageInfo *info);
|
static GstGLImageInfo *gst_gl_rgbimage_info (GstImageInfo * info);
|
||||||
static GstGLImageConnection * gst_gl_rgbimage_connection (GstImageConnection *conn);
|
static GstGLImageConnection *gst_gl_rgbimage_connection (GstImageConnection *
|
||||||
|
conn);
|
||||||
|
|
||||||
static GstCaps * gst_gl_rgbimage_get_caps (GstImageInfo *info);
|
static GstCaps *gst_gl_rgbimage_get_caps (GstImageInfo * info);
|
||||||
static GstImageConnection * gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps);
|
static GstImageConnection *gst_gl_rgbimage_set_caps (GstImageInfo * info,
|
||||||
static GstImageData * gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn);
|
GstCaps * caps);
|
||||||
static void gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image);
|
static GstImageData *gst_gl_rgbimage_get_image (GstImageInfo * info,
|
||||||
static void gst_gl_rgbimage_free_image (GstImageData *image);
|
GstImageConnection * conn);
|
||||||
static void gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
|
static void gst_gl_rgbimage_put_image (GstImageInfo * info,
|
||||||
static void gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
|
GstImageData * image);
|
||||||
static void gst_gl_rgbimage_free_conn (GstImageConnection *conn);
|
static void gst_gl_rgbimage_free_image (GstImageData * image);
|
||||||
|
static void gst_gl_rgbimage_open_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_rgbimage_close_conn (GstImageConnection * conn,
|
||||||
|
GstImageInfo * info);
|
||||||
|
static void gst_gl_rgbimage_free_conn (GstImageConnection * conn);
|
||||||
|
|
||||||
GstImagePlugin* get_gl_rgbimage_plugin(void)
|
GstImagePlugin *
|
||||||
|
get_gl_rgbimage_plugin (void)
|
||||||
{
|
{
|
||||||
static GstImagePlugin plugin = { gst_gl_rgbimage_get_caps,
|
static GstImagePlugin plugin = { gst_gl_rgbimage_get_caps,
|
||||||
gst_gl_rgbimage_set_caps,
|
gst_gl_rgbimage_set_caps,
|
||||||
gst_gl_rgbimage_get_image,
|
gst_gl_rgbimage_get_image,
|
||||||
gst_gl_rgbimage_put_image,
|
gst_gl_rgbimage_put_image,
|
||||||
gst_gl_rgbimage_free_image};
|
gst_gl_rgbimage_free_image
|
||||||
|
};
|
||||||
|
|
||||||
return &plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLImageInfo *
|
static GstGLImageInfo *
|
||||||
gst_gl_rgbimage_info (GstImageInfo *info)
|
gst_gl_rgbimage_info (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
|
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (GstGLImageInfo *) info;
|
return (GstGLImageInfo *) info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLImageConnection *
|
static GstGLImageConnection *
|
||||||
gst_gl_rgbimage_connection (GstImageConnection *conn)
|
gst_gl_rgbimage_connection (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
if (conn == NULL || conn->free_conn != gst_gl_rgbimage_free_conn)
|
if (conn == NULL || conn->free_conn != gst_gl_rgbimage_free_conn)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -93,7 +101,7 @@ gst_gl_rgbimage_connection (GstImageConnection *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
GstCaps *
|
||||||
gst_gl_rgbimage_get_caps (GstImageInfo *info)
|
gst_gl_rgbimage_get_caps (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
@ -102,11 +110,13 @@ gst_gl_rgbimage_get_caps (GstImageInfo *info)
|
|||||||
XImage *ximage;
|
XImage *ximage;
|
||||||
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
||||||
|
|
||||||
g_warning("rgbimage get caps called, context %p, endianness %d !\n", glXGetCurrentContext(), G_BIG_ENDIAN);
|
g_warning ("rgbimage get caps called, context %p, endianness %d !\n",
|
||||||
|
glXGetCurrentContext (), G_BIG_ENDIAN);
|
||||||
/* we don't handle this image information */
|
/* we don't handle this image information */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
|
XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
|
||||||
|
|
||||||
visual = attrib.visual;
|
visual = attrib.visual;
|
||||||
if (attrib.depth <= 8)
|
if (attrib.depth <= 8)
|
||||||
@ -118,23 +128,18 @@ gst_gl_rgbimage_get_caps (GstImageInfo *info)
|
|||||||
|
|
||||||
// create a temporary image
|
// create a temporary image
|
||||||
ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
|
ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
|
||||||
100, 100, xpad, (attrib.depth + 7) / 8 * 100);
|
100, 100, xpad, (attrib.depth + 7) / 8 * 100);
|
||||||
if (ximage != NULL) {
|
if (ximage != NULL) {
|
||||||
caps =
|
caps =
|
||||||
GST_CAPS_NEW (
|
GST_CAPS_NEW ("forcing Video RGB", "video/x-raw-rgb", "format",
|
||||||
"forcing Video RGB",
|
GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), "depth", GST_PROPS_INT (24),
|
||||||
"video/x-raw-rgb",
|
"bpp", GST_PROPS_INT (24), "red_mask", GST_PROPS_INT (0xff),
|
||||||
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
|
"green_mask", GST_PROPS_INT (0xff00), "blue_mask",
|
||||||
"depth", GST_PROPS_INT(24),
|
GST_PROPS_INT (0xff0000), "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
|
||||||
"bpp", GST_PROPS_INT(24),
|
/*= 1234/4321 (INT) <- endianness */
|
||||||
"red_mask", GST_PROPS_INT(0xff),
|
"width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
|
||||||
"green_mask", GST_PROPS_INT(0xff00),
|
"height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
|
||||||
"blue_mask", GST_PROPS_INT(0xff0000),
|
);
|
||||||
"endianness", GST_PROPS_INT(G_BIG_ENDIAN), /*= 1234/4321 (INT) <- endianness */
|
|
||||||
|
|
||||||
"width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
|
|
||||||
"height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
|
|
||||||
);
|
|
||||||
XDestroyImage (ximage);
|
XDestroyImage (ximage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,9 +148,9 @@ gst_gl_rgbimage_get_caps (GstImageInfo *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstImageConnection *
|
static GstImageConnection *
|
||||||
gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
gst_gl_rgbimage_set_caps (GstImageInfo * info, GstCaps * caps)
|
||||||
{
|
{
|
||||||
g_warning("in set_caps !\n");
|
g_warning ("in set_caps !\n");
|
||||||
|
|
||||||
GstGLImageConnection *new = NULL;
|
GstGLImageConnection *new = NULL;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
@ -158,26 +163,25 @@ gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
gint width, height, bpp;
|
gint width, height, bpp;
|
||||||
|
|
||||||
/* check if this is the right image info */
|
/* check if this is the right image info */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
|
XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
|
||||||
|
|
||||||
visual = attrib.visual;
|
visual = attrib.visual;
|
||||||
|
|
||||||
gst_caps_get (caps,
|
gst_caps_get (caps,
|
||||||
"format", &format,
|
"format", &format,
|
||||||
"depth", &depth,
|
"depth", &depth,
|
||||||
"endianness", &endianness,
|
"endianness", &endianness,
|
||||||
"red_mask", &red_mask,
|
"red_mask", &red_mask,
|
||||||
"green_mask", &green_mask,
|
"green_mask", &green_mask,
|
||||||
"blue_mask", &blue_mask,
|
"blue_mask", &blue_mask,
|
||||||
"width", &width,
|
"width", &width, "height", &height, "bpp", &bpp, NULL);
|
||||||
"height", &height,
|
|
||||||
"bpp", &bpp,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* check if the caps are ok */
|
/* check if the caps are ok */
|
||||||
if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) return NULL;
|
if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
|
||||||
|
return NULL;
|
||||||
/* if (gst_caps_get_int (caps, "bpp") != ???) return NULL; */
|
/* if (gst_caps_get_int (caps, "bpp") != ???) return NULL; */
|
||||||
//if (depth != attrib.depth) return NULL;
|
//if (depth != attrib.depth) return NULL;
|
||||||
//if (endianness != ((ImageByteOrder (xinfo->dpy) == LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN)) return NULL;
|
//if (endianness != ((ImageByteOrder (xinfo->dpy) == LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN)) return NULL;
|
||||||
@ -200,9 +204,10 @@ gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstImageData *
|
static GstImageData *
|
||||||
gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
gst_gl_rgbimage_get_image (GstImageInfo * info, GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstGLImage *image;
|
GstGLImage *image;
|
||||||
|
|
||||||
//XWindowAttributes attrib;
|
//XWindowAttributes attrib;
|
||||||
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
||||||
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
||||||
@ -210,19 +215,19 @@ gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
|||||||
image = g_new (GstGLImage, 1);
|
image = g_new (GstGLImage, 1);
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (xinfo == NULL) return NULL;
|
if (xinfo == NULL)
|
||||||
if (xconn == NULL) return NULL;
|
return NULL;
|
||||||
if (xinfo->dpy != xconn->dpy)
|
if (xconn == NULL)
|
||||||
{
|
return NULL;
|
||||||
|
if (xinfo->dpy != xconn->dpy) {
|
||||||
g_warning ("XImage: wrong x display specified in 'get_image'\n");
|
g_warning ("XImage: wrong x display specified in 'get_image'\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->conn = xconn;
|
image->conn = xconn;
|
||||||
image->data.size = xconn->w * xconn->h * 4;
|
image->data.size = xconn->w * xconn->h * 4;
|
||||||
image->data.data = g_malloc(image->data.size);
|
image->data.data = g_malloc (image->data.size);
|
||||||
if (image->data.data == NULL)
|
if (image->data.data == NULL) {
|
||||||
{
|
|
||||||
g_warning ("GL_RGBImage: data allocation failed!");
|
g_warning ("GL_RGBImage: data allocation failed!");
|
||||||
g_free (image);
|
g_free (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -233,7 +238,7 @@ gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
|
gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image)
|
||||||
{
|
{
|
||||||
float xmax, ymax;
|
float xmax, ymax;
|
||||||
|
|
||||||
@ -246,141 +251,145 @@ gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
|
|||||||
g_assert (xinfo != NULL);
|
g_assert (xinfo != NULL);
|
||||||
|
|
||||||
// both upload the video, and redraw the screen
|
// both upload the video, and redraw the screen
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity ();
|
||||||
glTranslatef(0.0, 0.0, -5.0);
|
glTranslatef (0.0, 0.0, -5.0);
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (xinfo->info.demo)
|
if (xinfo->info.demo) {
|
||||||
{
|
glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
|
||||||
glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
|
glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
|
||||||
glRotatef(180.0*sin(xinfo->rotX),1,0,0);
|
glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
|
||||||
glRotatef(180.0*cos(xinfo->rotY),0,1,0);
|
|
||||||
|
|
||||||
xinfo->rotX += 0.01;
|
xinfo->rotX += 0.01;
|
||||||
xinfo->rotY -= 0.015;
|
xinfo->rotY -= 0.015;
|
||||||
float zoom = xinfo->zoom;
|
float zoom = xinfo->zoom;
|
||||||
glScalef(zoom,zoom,zoom);
|
|
||||||
|
|
||||||
if (xinfo->zoom > 2.0)
|
glScalef (zoom, zoom, zoom);
|
||||||
xinfo->zoomdir = -0.01;
|
|
||||||
|
|
||||||
if (xinfo->zoom < 1.0)
|
if (xinfo->zoom > 2.0)
|
||||||
xinfo->zoomdir = 0.01;
|
xinfo->zoomdir = -0.01;
|
||||||
|
|
||||||
xinfo->zoom += xinfo->zoomdir;
|
if (xinfo->zoom < 1.0)
|
||||||
}
|
xinfo->zoomdir = 0.01;
|
||||||
|
|
||||||
|
xinfo->zoom += xinfo->zoomdir;
|
||||||
|
}
|
||||||
//Draws the surface rectangle
|
//Draws the surface rectangle
|
||||||
glBindTexture(GL_TEXTURE_2D, im->conn->rgbatex_id);
|
glBindTexture (GL_TEXTURE_2D, im->conn->rgbatex_id);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
|
||||||
GL_UNSIGNED_BYTE, im->data.data);
|
GL_UNSIGNED_BYTE, im->data.data);
|
||||||
xmax = (float)im->conn->w/TEX_XSIZE;
|
xmax = (float) im->conn->w / TEX_XSIZE;
|
||||||
ymax = (float)im->conn->h/TEX_YSIZE;
|
ymax = (float) im->conn->h / TEX_YSIZE;
|
||||||
|
|
||||||
float aspect = img_width/(float)img_height;
|
float aspect = img_width / (float) img_height;
|
||||||
float hor = aspect;
|
float hor = aspect;
|
||||||
|
|
||||||
glColor4f(1,1,1,1);
|
glColor4f (1, 1, 1, 1);
|
||||||
glBegin(GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
glNormal3f(0, -1, 0);
|
glNormal3f (0, -1, 0);
|
||||||
|
|
||||||
glTexCoord2f(xmax, 0);
|
glTexCoord2f (xmax, 0);
|
||||||
glVertex3f(hor,1,0);
|
glVertex3f (hor, 1, 0);
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f (0, 0);
|
||||||
glVertex3f(-hor,1,0);
|
glVertex3f (-hor, 1, 0);
|
||||||
|
|
||||||
glTexCoord2f(0, ymax);
|
glTexCoord2f (0, ymax);
|
||||||
glVertex3f(-hor,-1,0);
|
glVertex3f (-hor, -1, 0);
|
||||||
|
|
||||||
glTexCoord2f(xmax, ymax);
|
glTexCoord2f (xmax, ymax);
|
||||||
glVertex3f(hor,-1,0);
|
glVertex3f (hor, -1, 0);
|
||||||
glEnd();
|
glEnd ();
|
||||||
|
|
||||||
if (xinfo->info.dumpvideo)
|
if (xinfo->info.dumpvideo) {
|
||||||
{
|
static int framenr = 0;
|
||||||
static int framenr = 0;
|
char capfilename[255];
|
||||||
char capfilename[255];
|
static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
|
||||||
static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
// hmmmm, is this reentrant ?!
|
// hmmmm, is this reentrant ?!
|
||||||
if (cap_image_data == NULL)
|
if (cap_image_data == NULL)
|
||||||
cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
|
cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
|
||||||
|
|
||||||
if (cap_image_data2 == NULL)
|
if (cap_image_data2 == NULL)
|
||||||
cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
|
cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
|
||||||
|
|
||||||
printf("Recording frame #%d\n", framenr);
|
printf ("Recording frame #%d\n", framenr);
|
||||||
glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
|
glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
|
||||||
// invert the pixels
|
cap_image_data);
|
||||||
for (i = 0; i < img_height; i++)
|
// invert the pixels
|
||||||
memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
|
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);
|
sprintf (capfilename, "cap%04d.ppm", framenr);
|
||||||
FILE *outfile = fopen(capfilename, "wb");
|
FILE *outfile = fopen (capfilename, "wb");
|
||||||
if (outfile != NULL)
|
|
||||||
{
|
if (outfile != NULL) {
|
||||||
fprintf(outfile, "P6\n");
|
fprintf (outfile, "P6\n");
|
||||||
fprintf(outfile,"# created by raw_zb\n");
|
fprintf (outfile, "# created by raw_zb\n");
|
||||||
fprintf(outfile,"%d %d\n",img_width,img_height);
|
fprintf (outfile, "%d %d\n", img_width, img_height);
|
||||||
fprintf(outfile,"255\n");
|
fprintf (outfile, "255\n");
|
||||||
fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
|
fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
|
||||||
fclose(outfile);
|
outfile);
|
||||||
}
|
fclose (outfile);
|
||||||
framenr++;
|
|
||||||
}
|
}
|
||||||
|
framenr++;
|
||||||
|
}
|
||||||
|
|
||||||
glXSwapBuffers(xinfo->dpy, xinfo->win);
|
glXSwapBuffers (xinfo->dpy, xinfo->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_gl_rgbimage_free_image (GstImageData *image)
|
gst_gl_rgbimage_free_image (GstImageData * image)
|
||||||
{
|
{
|
||||||
GstGLImage *im = (GstGLImage *) image;
|
GstGLImage *im = (GstGLImage *) image;
|
||||||
|
|
||||||
g_warning ("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
|
g_warning
|
||||||
|
("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
|
||||||
g_free (im->data.data);
|
g_free (im->data.data);
|
||||||
g_free (im);
|
g_free (im);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates an OpenGL texture to upload the picture over */
|
/* Creates an OpenGL texture to upload the picture over */
|
||||||
static void
|
static void
|
||||||
gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_rgbimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
g_warning("Opening RGB Connection; classic OpenGL 1.2 renderer.");
|
g_warning ("Opening RGB Connection; classic OpenGL 1.2 renderer.");
|
||||||
|
|
||||||
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
||||||
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
||||||
|
|
||||||
glGenTextures(1, &xconn->rgbatex_id);
|
glGenTextures (1, &xconn->rgbatex_id);
|
||||||
glBindTexture(GL_TEXTURE_2D, xconn->rgbatex_id);
|
glBindTexture (GL_TEXTURE_2D, xconn->rgbatex_id);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes the creates OpenGL textures */
|
/* Deletes the creates OpenGL textures */
|
||||||
static void
|
static void
|
||||||
gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
|
gst_gl_rgbimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
||||||
|
|
||||||
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
|
||||||
|
|
||||||
glDeleteTextures(1, &xconn->rgbatex_id);
|
glDeleteTextures (1, &xconn->rgbatex_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_rgbimage_free_conn (GstImageConnection *conn)
|
gst_gl_rgbimage_free_conn (GstImageConnection * conn)
|
||||||
{
|
{
|
||||||
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
|
||||||
|
|
||||||
@ -388,5 +397,3 @@ gst_gl_rgbimage_free_conn (GstImageConnection *conn)
|
|||||||
|
|
||||||
g_free (xconn);
|
g_free (xconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,37 +52,39 @@ static GstElementDetails gst_glsink_details = {
|
|||||||
/* default template - initiated with class struct to allow gst-register to work
|
/* default template - initiated with class struct to allow gst-register to work
|
||||||
with X running */
|
with X running */
|
||||||
GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory,
|
GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory,
|
||||||
"sink",
|
"sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_CAPS_NEW ( "glsink_rgbsink", "video/x-raw-rgb",
|
GST_CAPS_NEW ("glsink_rgbsink", "video/x-raw-rgb",
|
||||||
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
|
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
|
||||||
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
|
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
||||||
"height", GST_PROPS_INT_RANGE(0, G_MAXINT)),
|
"height", GST_PROPS_INT_RANGE (0, G_MAXINT)),
|
||||||
GST_CAPS_NEW ( "glsink_yuvsink", "video/x-raw-yuv",
|
GST_CAPS_NEW ("glsink_yuvsink", "video/x-raw-yuv",
|
||||||
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
|
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
|
||||||
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
|
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
||||||
"height", GST_PROPS_INT_RANGE(0, G_MAXINT))
|
"height", GST_PROPS_INT_RANGE (0, G_MAXINT))
|
||||||
)
|
)
|
||||||
|
|
||||||
/* glsink signals and args */
|
/* glsink signals and args */
|
||||||
enum {
|
enum
|
||||||
LAST_SIGNAL
|
{
|
||||||
};
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
ARG_0,
|
{
|
||||||
ARG_WIDTH,
|
ARG_0,
|
||||||
ARG_HEIGHT,
|
ARG_WIDTH,
|
||||||
ARG_FRAMES_DISPLAYED,
|
ARG_HEIGHT,
|
||||||
ARG_FRAME_TIME,
|
ARG_FRAMES_DISPLAYED,
|
||||||
ARG_HOOK,
|
ARG_FRAME_TIME,
|
||||||
ARG_MUTE,
|
ARG_HOOK,
|
||||||
ARG_REPAINT,
|
ARG_MUTE,
|
||||||
ARG_DEMO,
|
ARG_REPAINT,
|
||||||
ARG_DUMP
|
ARG_DEMO,
|
||||||
};
|
ARG_DUMP
|
||||||
|
};
|
||||||
|
|
||||||
/* GLsink class */
|
/* GLsink class */
|
||||||
#define GST_TYPE_GLSINK (gst_glsink_get_type())
|
#define GST_TYPE_GLSINK (gst_glsink_get_type())
|
||||||
@ -91,96 +93,105 @@ enum {
|
|||||||
#define GST_IS_GLSINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GLSINK))
|
#define GST_IS_GLSINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GLSINK))
|
||||||
#define GST_IS_GLSINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GLSINK))
|
#define GST_IS_GLSINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GLSINK))
|
||||||
|
|
||||||
typedef struct _GstGLSink GstGLSink;
|
typedef struct _GstGLSink GstGLSink;
|
||||||
typedef struct _GstGLSinkClass GstGLSinkClass;
|
typedef struct _GstGLSinkClass GstGLSinkClass;
|
||||||
|
|
||||||
struct _GstGLSink {
|
struct _GstGLSink
|
||||||
GstElement element;
|
{
|
||||||
|
GstElement element;
|
||||||
|
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
|
|
||||||
gint frames_displayed;
|
gint frames_displayed;
|
||||||
guint64 frame_time;
|
guint64 frame_time;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gboolean muted;
|
gboolean muted;
|
||||||
gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
|
gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
|
||||||
gboolean dumpvideo; // dump the video down to .ppm:s
|
gboolean dumpvideo; // dump the video down to .ppm:s
|
||||||
GstBuffer *last_image; /* not thread safe ? */
|
GstBuffer *last_image; /* not thread safe ? */
|
||||||
|
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
|
|
||||||
GMutex *cache_lock;
|
GMutex *cache_lock;
|
||||||
GList *cache;
|
GList *cache;
|
||||||
|
|
||||||
/* plugins */
|
/* plugins */
|
||||||
GstImagePlugin* plugin;
|
GstImagePlugin *plugin;
|
||||||
GstImageConnection *conn;
|
GstImageConnection *conn;
|
||||||
|
|
||||||
/* allow anybody to hook in here */
|
/* allow anybody to hook in here */
|
||||||
GstImageInfo *hook;
|
GstImageInfo *hook;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstGLSinkClass {
|
struct _GstGLSinkClass
|
||||||
GstElementClass parent_class;
|
{
|
||||||
|
GstElementClass parent_class;
|
||||||
|
|
||||||
/* plugins */
|
/* plugins */
|
||||||
GList *plugins;
|
GList *plugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static GType gst_glsink_get_type (void);
|
static GType gst_glsink_get_type (void);
|
||||||
static void gst_glsink_base_init (gpointer g_class);
|
static void gst_glsink_base_init (gpointer g_class);
|
||||||
static void gst_glsink_class_init (GstGLSinkClass *klass);
|
static void gst_glsink_class_init (GstGLSinkClass * klass);
|
||||||
static void gst_glsink_init (GstGLSink *sink);
|
static void gst_glsink_init (GstGLSink * sink);
|
||||||
|
|
||||||
/* static void gst_glsink_dispose (GObject *object); */
|
/* static void gst_glsink_dispose (GObject *object); */
|
||||||
|
|
||||||
static void gst_glsink_chain (GstPad *pad, GstData *_data);
|
static void gst_glsink_chain (GstPad * pad, GstData * _data);
|
||||||
static void gst_glsink_set_clock (GstElement *element, GstClock *clock);
|
static void gst_glsink_set_clock (GstElement * element, GstClock * clock);
|
||||||
static GstElementStateReturn gst_glsink_change_state (GstElement *element);
|
static GstElementStateReturn gst_glsink_change_state (GstElement *
|
||||||
static GstPadLinkReturn gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps);
|
element);
|
||||||
static GstCaps * gst_glsink_getcaps (GstPad *pad, GstCaps *caps);
|
static GstPadLinkReturn gst_glsink_sinkconnect (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
|
static GstCaps *gst_glsink_getcaps (GstPad * pad, GstCaps * caps);
|
||||||
|
|
||||||
static void gst_glsink_set_property (GObject *object, guint prop_id,
|
static void gst_glsink_set_property (GObject * object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_glsink_get_property (GObject *object, guint prop_id,
|
static void gst_glsink_get_property (GObject * object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static void gst_glsink_release_conn (GstGLSink *sink);
|
static void gst_glsink_release_conn (GstGLSink * sink);
|
||||||
static void gst_glsink_append_cache (GstGLSink *sink, GstImageData *image);
|
static void gst_glsink_append_cache (GstGLSink * sink,
|
||||||
static gboolean gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps);
|
GstImageData * image);
|
||||||
|
static gboolean gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps);
|
||||||
|
|
||||||
/* prototypes from plugins */
|
/* prototypes from plugins */
|
||||||
extern GstImagePlugin* get_gl_rgbimage_plugin (void);
|
extern GstImagePlugin *get_gl_rgbimage_plugin (void);
|
||||||
extern GstImagePlugin* get_gl_nvimage_plugin (void);
|
extern GstImagePlugin *get_gl_nvimage_plugin (void);
|
||||||
|
|
||||||
/* default output */
|
/* default output */
|
||||||
extern void gst_glxwindow_new (GstGLSink *sink);
|
extern void gst_glxwindow_new (GstGLSink * sink);
|
||||||
extern void gst_glxwindow_hook_context (GstImageInfo *info);
|
extern void gst_glxwindow_hook_context (GstImageInfo * info);
|
||||||
extern void gst_glxwindow_unhook_context (GstImageInfo *info);
|
extern void gst_glxwindow_unhook_context (GstImageInfo * info);
|
||||||
|
|
||||||
|
|
||||||
static GstPadTemplate *sink_template;
|
static GstPadTemplate *sink_template;
|
||||||
|
|
||||||
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
|
||||||
/* static guint gst_glsink_signals[LAST_SIGNAL] = { 0 }; */
|
/* static guint gst_glsink_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
|
|
||||||
static GType
|
static GType gst_glsink_get_type (void)
|
||||||
gst_glsink_get_type (void)
|
|
||||||
{
|
{
|
||||||
static GType videosink_type = 0;
|
static GType videosink_type = 0;
|
||||||
|
|
||||||
if (!videosink_type) {
|
if (!videosink_type) {
|
||||||
static const GTypeInfo videosink_info = {
|
static const GTypeInfo videosink_info = {
|
||||||
sizeof(GstGLSinkClass),
|
sizeof (GstGLSinkClass),
|
||||||
gst_glsink_base_init,
|
gst_glsink_base_init,
|
||||||
NULL,
|
NULL,
|
||||||
(GClassInitFunc) gst_glsink_class_init,
|
(GClassInitFunc) gst_glsink_class_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstGLSink),
|
sizeof (GstGLSink),
|
||||||
0,
|
0,
|
||||||
(GInstanceInitFunc) gst_glsink_init,
|
(GInstanceInitFunc) gst_glsink_init,
|
||||||
};
|
};
|
||||||
videosink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGLSink", &videosink_info, 0);
|
videosink_type =
|
||||||
|
g_type_register_static (GST_TYPE_ELEMENT, "GstGLSink", &videosink_info,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
return videosink_type;
|
return videosink_type;
|
||||||
}
|
}
|
||||||
@ -192,44 +203,40 @@ gst_glsink_base_init (gpointer g_class)
|
|||||||
|
|
||||||
gst_element_class_set_details (element_class, &gst_glsink_details);
|
gst_element_class_set_details (element_class, &gst_glsink_details);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (
|
gst_element_class_add_pad_template (element_class,
|
||||||
element_class,
|
GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
|
||||||
GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glsink_class_init (GstGLSinkClass *klass)
|
gst_glsink_class_init (GstGLSinkClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstelement_class = (GstElementClass*) klass;
|
gstelement_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, ARG_WIDTH,
|
g_object_class_install_property (gobject_class, ARG_WIDTH, g_param_spec_int ("width", "Width", "The video width", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
|
||||||
g_param_spec_int ("width", "Width", "The video width",
|
g_object_class_install_property (gobject_class, ARG_HEIGHT, g_param_spec_int ("height", "Height", "The video height", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
|
||||||
G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
|
g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED, g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property (gobject_class, ARG_HEIGHT,
|
g_object_class_install_property (gobject_class, ARG_FRAME_TIME, g_param_spec_int ("frame_time", "Frame time", "The interval between frames", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_param_spec_int ("height", "Height", "The video height",
|
|
||||||
G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
|
|
||||||
g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED,
|
|
||||||
g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far",
|
|
||||||
G_MININT,G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
|
|
||||||
g_object_class_install_property (gobject_class, ARG_FRAME_TIME,
|
|
||||||
g_param_spec_int ("frame_time", "Frame time", "The interval between frames",
|
|
||||||
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
|
|
||||||
g_object_class_install_property (gobject_class, ARG_HOOK,
|
g_object_class_install_property (gobject_class, ARG_HOOK,
|
||||||
g_param_spec_pointer ("hook", "Hook", "The object receiving the output", G_PARAM_WRITABLE));
|
g_param_spec_pointer ("hook", "Hook", "The object receiving the output",
|
||||||
|
G_PARAM_WRITABLE));
|
||||||
g_object_class_install_property (gobject_class, ARG_MUTE,
|
g_object_class_install_property (gobject_class, ARG_MUTE,
|
||||||
g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE, G_PARAM_READWRITE));
|
g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_REPAINT,
|
g_object_class_install_property (gobject_class, ARG_REPAINT,
|
||||||
g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame", FALSE, G_PARAM_WRITABLE));
|
g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame",
|
||||||
|
FALSE, G_PARAM_WRITABLE));
|
||||||
g_object_class_install_property (gobject_class, ARG_DEMO,
|
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_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_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));
|
g_param_spec_boolean ("dump", "Dump",
|
||||||
|
"stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gobject_class->set_property = gst_glsink_set_property;
|
gobject_class->set_property = gst_glsink_set_property;
|
||||||
gobject_class->get_property = gst_glsink_get_property;
|
gobject_class->get_property = gst_glsink_get_property;
|
||||||
@ -251,7 +258,7 @@ gst_glsink_class_init (GstGLSinkClass *klass)
|
|||||||
buffer upload
|
buffer upload
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_glsink_init (GstGLSink *sink)
|
gst_glsink_init (GstGLSink * sink)
|
||||||
{
|
{
|
||||||
sink->sinkpad = gst_pad_new_from_template (sink_template, "sink");
|
sink->sinkpad = gst_pad_new_from_template (sink_template, "sink");
|
||||||
gst_element_add_pad (GST_ELEMENT (sink), sink->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (sink), sink->sinkpad);
|
||||||
@ -265,12 +272,12 @@ gst_glsink_init (GstGLSink *sink)
|
|||||||
sink->height = 0;
|
sink->height = 0;
|
||||||
sink->muted = FALSE;
|
sink->muted = FALSE;
|
||||||
sink->clock = NULL;
|
sink->clock = NULL;
|
||||||
GST_FLAG_SET(sink, GST_ELEMENT_THREAD_SUGGESTED);
|
GST_FLAG_SET (sink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||||
GST_FLAG_SET (sink, GST_ELEMENT_EVENT_AWARE);
|
GST_FLAG_SET (sink, GST_ELEMENT_EVENT_AWARE);
|
||||||
|
|
||||||
/* create bufferpool and image cache */
|
/* create bufferpool and image cache */
|
||||||
GST_DEBUG ("glsink: creating bufferpool");
|
GST_DEBUG ("glsink: creating bufferpool");
|
||||||
sink->cache_lock = g_mutex_new();
|
sink->cache_lock = g_mutex_new ();
|
||||||
sink->cache = NULL;
|
sink->cache = NULL;
|
||||||
|
|
||||||
/* plugins */
|
/* plugins */
|
||||||
@ -280,25 +287,24 @@ gst_glsink_init (GstGLSink *sink)
|
|||||||
/* do initialization of default hook here */
|
/* do initialization of default hook here */
|
||||||
gst_glxwindow_new (sink);
|
gst_glxwindow_new (sink);
|
||||||
//printf("GLSink_init: Current context %p\n", glXGetCurrentContext());
|
//printf("GLSink_init: Current context %p\n", glXGetCurrentContext());
|
||||||
gst_glxwindow_unhook_context(sink->hook);
|
gst_glxwindow_unhook_context (sink->hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** frees the temporary connection that tests the window system capabilities */
|
/** frees the temporary connection that tests the window system capabilities */
|
||||||
static void
|
static void
|
||||||
gst_glsink_release_conn (GstGLSink *sink)
|
gst_glsink_release_conn (GstGLSink * sink)
|
||||||
{
|
{
|
||||||
if (sink->conn == NULL) return;
|
if (sink->conn == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* free last image if any */
|
/* free last image if any */
|
||||||
if (sink->last_image != NULL)
|
if (sink->last_image != NULL) {
|
||||||
{
|
|
||||||
gst_buffer_unref (sink->last_image);
|
gst_buffer_unref (sink->last_image);
|
||||||
sink->last_image = NULL;
|
sink->last_image = NULL;
|
||||||
}
|
}
|
||||||
/* free cache */
|
/* free cache */
|
||||||
g_mutex_lock (sink->cache_lock);
|
g_mutex_lock (sink->cache_lock);
|
||||||
while (sink->cache)
|
while (sink->cache) {
|
||||||
{
|
|
||||||
sink->plugin->free_image ((GstImageData *) sink->cache->data);
|
sink->plugin->free_image ((GstImageData *) sink->cache->data);
|
||||||
sink->cache = g_list_delete_link (sink->cache, sink->cache);
|
sink->cache = g_list_delete_link (sink->cache, sink->cache);
|
||||||
}
|
}
|
||||||
@ -310,7 +316,7 @@ gst_glsink_release_conn (GstGLSink *sink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glsink_append_cache (GstGLSink *sink, GstImageData *image)
|
gst_glsink_append_cache (GstGLSink * sink, GstImageData * image)
|
||||||
{
|
{
|
||||||
g_mutex_lock (sink->cache_lock);
|
g_mutex_lock (sink->cache_lock);
|
||||||
sink->cache = g_list_prepend (sink->cache, image);
|
sink->cache = g_list_prepend (sink->cache, image);
|
||||||
@ -322,9 +328,9 @@ gst_glsink_append_cache (GstGLSink *sink, GstImageData *image)
|
|||||||
Create a new buffer to hand up the chain.
|
Create a new buffer to hand up the chain.
|
||||||
This allows the plugins to make its own decoding buffers
|
This allows the plugins to make its own decoding buffers
|
||||||
*/
|
*/
|
||||||
static GstBuffer*
|
static GstBuffer *
|
||||||
gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
|
gst_glsink_buffer_new (GstBufferPool * pool, gint64 location,
|
||||||
guint size, gpointer user_data)
|
guint size, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstGLSink *sink;
|
GstGLSink *sink;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
@ -355,11 +361,15 @@ gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
|
|||||||
Free a buffer that the chain doesn't need anymore.
|
Free a buffer that the chain doesn't need anymore.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data)
|
gst_glsink_buffer_free (GstBufferPool * pool, GstBuffer * buffer,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GstGLSink *sink = GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL (buffer)));
|
GstGLSink *sink =
|
||||||
|
GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL
|
||||||
|
(buffer)));
|
||||||
|
|
||||||
gst_glsink_append_cache (sink, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
|
gst_glsink_append_cache (sink,
|
||||||
|
(GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
|
||||||
|
|
||||||
/* set to NULL so the data is not freed */
|
/* set to NULL so the data is not freed */
|
||||||
GST_BUFFER_DATA (buffer) = NULL;
|
GST_BUFFER_DATA (buffer) = NULL;
|
||||||
@ -373,23 +383,23 @@ gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_da
|
|||||||
Go through the plugin list, finding the plugin that first fits the given parameters
|
Go through the plugin list, finding the plugin that first fits the given parameters
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps)
|
gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps)
|
||||||
{
|
{
|
||||||
g_warning("in glsink set caps!\n");
|
g_warning ("in glsink set caps!\n");
|
||||||
printf("Getting GLstring, context is %p\n", glXGetCurrentContext());
|
printf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
|
||||||
|
|
||||||
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
|
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
|
||||||
GstImageConnection *conn = NULL;
|
GstImageConnection *conn = NULL;
|
||||||
while (list)
|
|
||||||
{
|
while (list) {
|
||||||
printf("AGetting GLstring, context is %p\n", glXGetCurrentContext());
|
printf ("AGetting GLstring, context is %p\n", glXGetCurrentContext ());
|
||||||
GstImagePlugin *plugin = (GstImagePlugin *) list->data;
|
GstImagePlugin *plugin = (GstImagePlugin *) list->data;
|
||||||
if ((conn = plugin->set_caps (sink->hook, caps)) != NULL)
|
|
||||||
{
|
if ((conn = plugin->set_caps (sink->hook, caps)) != NULL) {
|
||||||
//gst_glsink_release_conn (sink);
|
//gst_glsink_release_conn (sink);
|
||||||
printf("BGetting GLstring, context is %p\n", glXGetCurrentContext());
|
printf ("BGetting GLstring, context is %p\n", glXGetCurrentContext ());
|
||||||
sink->conn = conn;
|
sink->conn = conn;
|
||||||
printf("CGetting GLstring, context is %p\n", glXGetCurrentContext());
|
printf ("CGetting GLstring, context is %p\n", glXGetCurrentContext ());
|
||||||
sink->plugin = plugin;
|
sink->plugin = plugin;
|
||||||
sink->conn->open_conn (sink->conn, sink->hook);
|
sink->conn->open_conn (sink->conn, sink->hook);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -403,9 +413,9 @@ gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps)
|
|||||||
Link the input video sink internally.
|
Link the input video sink internally.
|
||||||
*/
|
*/
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
|
gst_glsink_sinkconnect (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
g_warning("in glsink sinkconnect!\n");
|
g_warning ("in glsink sinkconnect!\n");
|
||||||
GstGLSink *sink;
|
GstGLSink *sink;
|
||||||
guint32 fourcc, print_format, result;
|
guint32 fourcc, print_format, result;
|
||||||
|
|
||||||
@ -415,15 +425,14 @@ gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
|
|||||||
if (!GST_CAPS_IS_FIXED (caps))
|
if (!GST_CAPS_IS_FIXED (caps))
|
||||||
return GST_PAD_LINK_DELAYED;
|
return GST_PAD_LINK_DELAYED;
|
||||||
|
|
||||||
gst_glxwindow_hook_context(sink->hook);
|
gst_glxwindow_hook_context (sink->hook);
|
||||||
/* try to set the caps on the output */
|
/* try to set the caps on the output */
|
||||||
result = gst_glsink_set_caps (sink, caps);
|
result = gst_glsink_set_caps (sink, caps);
|
||||||
gst_glxwindow_unhook_context(sink->hook);
|
gst_glxwindow_unhook_context (sink->hook);
|
||||||
|
|
||||||
if (result == FALSE)
|
if (result == FALSE) {
|
||||||
{
|
return GST_PAD_LINK_REFUSED;
|
||||||
return GST_PAD_LINK_REFUSED;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* remember width & height */
|
/* remember width & height */
|
||||||
gst_caps_get_int (caps, "width", &sink->width);
|
gst_caps_get_int (caps, "width", &sink->width);
|
||||||
@ -432,7 +441,7 @@ gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
|
|||||||
gst_caps_get_fourcc_int (caps, "format", &fourcc);
|
gst_caps_get_fourcc_int (caps, "format", &fourcc);
|
||||||
print_format = GULONG_FROM_LE (fourcc);
|
print_format = GULONG_FROM_LE (fourcc);
|
||||||
GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
|
GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
|
||||||
fourcc, (gchar*)&print_format, sink->width, sink->height);
|
fourcc, (gchar *) & print_format, sink->width, sink->height);
|
||||||
|
|
||||||
/* emit signal */
|
/* emit signal */
|
||||||
g_object_freeze_notify (G_OBJECT (sink));
|
g_object_freeze_notify (G_OBJECT (sink));
|
||||||
@ -443,34 +452,35 @@ gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
|
|||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_glsink_getcaps (GstPad *pad, GstCaps *caps)
|
gst_glsink_getcaps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
g_warning("in glsink get caps!\n");
|
g_warning ("in glsink get caps!\n");
|
||||||
/* what is the "caps" parameter good for? */
|
/* what is the "caps" parameter good for? */
|
||||||
GstGLSink *sink = GST_GLSINK (gst_pad_get_parent (pad));
|
GstGLSink *sink = GST_GLSINK (gst_pad_get_parent (pad));
|
||||||
GstCaps *ret = NULL;
|
GstCaps *ret = NULL;
|
||||||
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
|
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
|
||||||
|
|
||||||
gst_glxwindow_hook_context(sink->hook);
|
gst_glxwindow_hook_context (sink->hook);
|
||||||
while (list)
|
while (list) {
|
||||||
{
|
ret =
|
||||||
ret = gst_caps_append (ret, ((GstImagePlugin *) list->data)->get_caps (sink->hook));
|
gst_caps_append (ret,
|
||||||
|
((GstImagePlugin *) list->data)->get_caps (sink->hook));
|
||||||
list = g_list_next (list);
|
list = g_list_next (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_glxwindow_unhook_context(sink->hook);
|
gst_glxwindow_unhook_context (sink->hook);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glsink_set_clock (GstElement *element, GstClock *clock)
|
gst_glsink_set_clock (GstElement * element, GstClock * clock)
|
||||||
{
|
{
|
||||||
GstGLSink *sink = GST_GLSINK (element);
|
GstGLSink *sink = GST_GLSINK (element);
|
||||||
|
|
||||||
sink->clock = clock;
|
sink->clock = clock;
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
gst_glsink_chain (GstPad *pad, GstData *_data)
|
gst_glsink_chain (GstPad * pad, GstData * _data)
|
||||||
{
|
{
|
||||||
//g_warning("in glsink_chain!\n");
|
//g_warning("in glsink_chain!\n");
|
||||||
GstBuffer *buf = GST_BUFFER (_data);
|
GstBuffer *buf = GST_BUFFER (_data);
|
||||||
@ -489,30 +499,30 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
|
|||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
default:
|
default:
|
||||||
gst_pad_event_default (pad, event);
|
gst_pad_event_default (pad, event);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GST_DEBUG ("glsink: clock wait: %llu %u",
|
GST_DEBUG ("glsink: clock wait: %llu %u",
|
||||||
GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
|
GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
|
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
|
||||||
static int frame_drops = 0;
|
static int frame_drops = 0;
|
||||||
|
|
||||||
if (sink->clock && time != -1) {
|
if (sink->clock && time != -1) {
|
||||||
if (time < gst_clock_get_time(sink->clock))
|
if (time < gst_clock_get_time (sink->clock)) {
|
||||||
{
|
g_warning ("Frame drop (%d consecutive) !!", frame_drops);
|
||||||
g_warning("Frame drop (%d consecutive) !!", frame_drops);
|
/* we are going to drop late buffers */
|
||||||
/* we are going to drop late buffers */
|
gst_buffer_unref (buf);
|
||||||
gst_buffer_unref (buf);
|
frame_drops++;
|
||||||
frame_drops++;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
frame_drops = 0; // we made it - reset time
|
||||||
frame_drops = 0; // we made it - reset time
|
|
||||||
|
|
||||||
GstClockReturn ret;
|
GstClockReturn ret;
|
||||||
GstClockID id = gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
|
GstClockID id =
|
||||||
|
gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
|
||||||
|
|
||||||
ret = gst_element_clock_wait (GST_ELEMENT (sink), id, NULL);
|
ret = gst_element_clock_wait (GST_ELEMENT (sink), id, NULL);
|
||||||
gst_clock_id_free (id);
|
gst_clock_id_free (id);
|
||||||
@ -529,51 +539,50 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
|
|||||||
sink->frames_displayed++;
|
sink->frames_displayed++;
|
||||||
g_object_notify (G_OBJECT (sink), "frames_displayed");
|
g_object_notify (G_OBJECT (sink), "frames_displayed");
|
||||||
|
|
||||||
if (!sink->muted)
|
if (!sink->muted) {
|
||||||
{
|
if (glXGetCurrentContext () == NULL) {
|
||||||
if (glXGetCurrentContext() == NULL)
|
printf ("Rehooking window !\n");
|
||||||
{
|
gst_glxwindow_hook_context (sink->hook);
|
||||||
printf("Rehooking window !\n");
|
|
||||||
gst_glxwindow_hook_context(sink->hook);
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
GST_DEBUG("Initializing OpenGL parameters\n");
|
GST_DEBUG ("Initializing OpenGL parameters\n");
|
||||||
/* initialize OpenGL drawing */
|
/* initialize OpenGL drawing */
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
glClearDepth(1.0f);
|
glClearDepth (1.0f);
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor (0, 0, 0, 0);
|
||||||
|
|
||||||
glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
|
glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable (GL_CULL_FACE);
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
glPolygonMode (GL_FRONT, GL_FILL);
|
||||||
glPolygonMode(GL_BACK, GL_FILL);
|
glPolygonMode (GL_BACK, GL_FILL);
|
||||||
|
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel (GL_SMOOTH);
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
|
|
||||||
GstGLImageInfo *window = (GstGLImageInfo *)sink->hook;
|
GstGLImageInfo *window = (GstGLImageInfo *) sink->hook;
|
||||||
int w=window->width, h = window->height;
|
int w = window->width, h = window->height;
|
||||||
|
|
||||||
glViewport(0, 0, (GLint) w, (GLint) h);
|
glViewport (0, 0, (GLint) w, (GLint) h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity ();
|
||||||
|
|
||||||
GLfloat aspect = (GLfloat) w / (GLfloat) h;
|
GLfloat aspect = (GLfloat) w / (GLfloat) h;
|
||||||
glFrustum(-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
|
|
||||||
|
glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
gst_glxwindow_unhook_context(sink->hook);
|
gst_glxwindow_unhook_context (sink->hook);
|
||||||
gst_glxwindow_hook_context(sink->hook);
|
gst_glxwindow_hook_context (sink->hook);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
#if 0
|
#if 0
|
||||||
sink->hook->free_info(sink->hook);
|
sink->hook->free_info (sink->hook);
|
||||||
printf("Reallocating window brutally !\n");
|
printf ("Reallocating window brutally !\n");
|
||||||
gst_glxwindow_new(sink);
|
gst_glxwindow_new (sink);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free last_image, if any */
|
/* free last_image, if any */
|
||||||
if (sink->last_image != NULL)
|
if (sink->last_image != NULL)
|
||||||
@ -584,16 +593,20 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
|
|||||||
sink->hook->demo = sink->demo;
|
sink->hook->demo = sink->demo;
|
||||||
sink->hook->dumpvideo = sink->dumpvideo;
|
sink->hook->dumpvideo = sink->dumpvideo;
|
||||||
|
|
||||||
sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
|
sink->plugin->put_image (sink->hook,
|
||||||
|
(GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
|
||||||
sink->last_image = buf;
|
sink->last_image = buf;
|
||||||
} else {
|
} else {
|
||||||
buffer = gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
|
buffer =
|
||||||
0, GST_BUFFER_SIZE (buf));
|
gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
|
||||||
|
0, GST_BUFFER_SIZE (buf));
|
||||||
memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
|
memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
|
||||||
GST_BUFFER_SIZE (buf) > GST_BUFFER_SIZE (buffer) ?
|
GST_BUFFER_SIZE (buf) >
|
||||||
GST_BUFFER_SIZE (buffer) : GST_BUFFER_SIZE (buf));
|
GST_BUFFER_SIZE (buffer) ? GST_BUFFER_SIZE (buffer) :
|
||||||
|
GST_BUFFER_SIZE (buf));
|
||||||
|
|
||||||
sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
|
sink->plugin->put_image (sink->hook,
|
||||||
|
(GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
|
||||||
|
|
||||||
sink->last_image = buffer;
|
sink->last_image = buffer;
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
@ -606,7 +619,8 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
gst_glsink_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
//g_warning("in set_property!\n");
|
//g_warning("in set_property!\n");
|
||||||
GstGLSink *sink;
|
GstGLSink *sink;
|
||||||
@ -625,8 +639,7 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
|
|||||||
sink->frame_time = g_value_get_int (value);
|
sink->frame_time = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_HOOK:
|
case ARG_HOOK:
|
||||||
if (sink->hook)
|
if (sink->hook) {
|
||||||
{
|
|
||||||
sink->hook->free_info (sink->hook);
|
sink->hook->free_info (sink->hook);
|
||||||
}
|
}
|
||||||
sink->hook = g_value_get_pointer (value);
|
sink->hook = g_value_get_pointer (value);
|
||||||
@ -645,7 +658,8 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
|
|||||||
break;
|
break;
|
||||||
case ARG_REPAINT:
|
case ARG_REPAINT:
|
||||||
if (sink->last_image != NULL) {
|
if (sink->last_image != NULL) {
|
||||||
sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
|
sink->plugin->put_image (sink->hook,
|
||||||
|
(GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -655,13 +669,14 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
gst_glsink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
//g_warning("in get_property!\n");
|
//g_warning("in get_property!\n");
|
||||||
GstGLSink *sink;
|
GstGLSink *sink;
|
||||||
|
|
||||||
/* it's not null if we got it, but it might not be ours */
|
/* it's not null if we got it, but it might not be ours */
|
||||||
sink = GST_GLSINK(object);
|
sink = GST_GLSINK (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_WIDTH:
|
case ARG_WIDTH:
|
||||||
@ -674,7 +689,7 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
|
|||||||
g_value_set_int (value, sink->frames_displayed);
|
g_value_set_int (value, sink->frames_displayed);
|
||||||
break;
|
break;
|
||||||
case ARG_FRAME_TIME:
|
case ARG_FRAME_TIME:
|
||||||
g_value_set_int (value, sink->frame_time/1000000);
|
g_value_set_int (value, sink->frame_time / 1000000);
|
||||||
break;
|
break;
|
||||||
case ARG_MUTE:
|
case ARG_MUTE:
|
||||||
g_value_set_boolean (value, sink->muted);
|
g_value_set_boolean (value, sink->muted);
|
||||||
@ -693,7 +708,7 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
|
|||||||
|
|
||||||
|
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_glsink_change_state (GstElement *element)
|
gst_glsink_change_state (GstElement * element)
|
||||||
{
|
{
|
||||||
//g_warning("in change_state!\n");
|
//g_warning("in change_state!\n");
|
||||||
GstGLSink *sink;
|
GstGLSink *sink;
|
||||||
@ -704,23 +719,23 @@ gst_glsink_change_state (GstElement *element)
|
|||||||
case GST_STATE_NULL_TO_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
case GST_STATE_READY_TO_PAUSED:
|
||||||
{
|
{
|
||||||
//g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
|
//g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
{
|
{
|
||||||
//g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
|
//g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
if (sink->conn)
|
if (sink->conn)
|
||||||
sink->conn->close_conn (sink->conn, sink->hook);
|
sink->conn->close_conn (sink->conn, sink->hook);
|
||||||
if (sink->last_image) {
|
if (sink->last_image) {
|
||||||
gst_buffer_unref (sink->last_image);
|
gst_buffer_unref (sink->last_image);
|
||||||
sink->last_image = NULL;
|
sink->last_image = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
@ -734,18 +749,15 @@ gst_glsink_change_state (GstElement *element)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin *plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
/* Loading the library containing GstVideoSink, our parent object */
|
/* Loading the library containing GstVideoSink, our parent object */
|
||||||
if (!gst_library_load ("gstvideo"))
|
if (!gst_library_load ("gstvideo"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* this is needed later on in the _real_ init (during a gst-launch) */
|
/* this is needed later on in the _real_ init (during a gst-launch) */
|
||||||
sink_template = gst_pad_template_new (
|
sink_template = gst_pad_template_new ("sink",
|
||||||
"sink",
|
GST_PAD_SINK, GST_PAD_ALWAYS, NULL);
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "glsink", GST_RANK_NONE, GST_TYPE_GLSINK))
|
if (!gst_element_register (plugin, "glsink", GST_RANK_NONE, GST_TYPE_GLSINK))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -753,14 +765,8 @@ plugin_init (GstPlugin *plugin)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
GST_VERSION_MAJOR,
|
GST_VERSION_MINOR,
|
||||||
GST_VERSION_MINOR,
|
"glsink",
|
||||||
"glsink",
|
"An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
|
||||||
"An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
|
||||||
plugin_init,
|
|
||||||
VERSION,
|
|
||||||
GST_LICENSE,
|
|
||||||
GST_PACKAGE,
|
|
||||||
GST_ORIGIN
|
|
||||||
);
|
|
||||||
|
@ -25,72 +25,81 @@
|
|||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif /* __cplusplus */
|
{
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#define MAX_FLIP_BUFFERS 1
|
#define MAX_FLIP_BUFFERS 1
|
||||||
|
|
||||||
typedef struct _GstImageInfo GstImageInfo;
|
typedef struct _GstImageInfo GstImageInfo;
|
||||||
struct _GstImageInfo {
|
struct _GstImageInfo
|
||||||
gulong id;
|
{
|
||||||
int demo;
|
gulong id;
|
||||||
int dumpvideo;
|
int demo;
|
||||||
void (*free_info) (GstImageInfo *info);
|
int dumpvideo;
|
||||||
};
|
void (*free_info) (GstImageInfo * info);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GstImageData GstImageData;
|
typedef struct _GstImageData GstImageData;
|
||||||
struct _GstImageData {
|
struct _GstImageData
|
||||||
gint size;
|
{
|
||||||
gchar *data;
|
gint size;
|
||||||
};
|
gchar *data;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _GstImageConnection GstImageConnection;
|
typedef struct _GstImageConnection GstImageConnection;
|
||||||
struct _GstImageConnection {
|
struct _GstImageConnection
|
||||||
void (*open_conn) (GstImageConnection *conn, GstImageInfo *info);
|
{
|
||||||
void (*close_conn) (GstImageConnection *conn, GstImageInfo *info);
|
void (*open_conn) (GstImageConnection * conn, GstImageInfo * info);
|
||||||
void (*free_conn) (GstImageConnection *conn);
|
void (*close_conn) (GstImageConnection * conn, GstImageInfo * info);
|
||||||
};
|
void (*free_conn) (GstImageConnection * conn);
|
||||||
|
};
|
||||||
|
|
||||||
typedef GstCaps * (*GstImagePluginGetCapsFunc) (GstImageInfo *info);
|
typedef GstCaps *(*GstImagePluginGetCapsFunc) (GstImageInfo * info);
|
||||||
typedef GstImageConnection * (*GstImagePluginSetCapsFunc) (GstImageInfo *info, GstCaps *caps);
|
typedef GstImageConnection *(*GstImagePluginSetCapsFunc) (GstImageInfo * info,
|
||||||
typedef GstImageData* (*GstImagePluginGetImageFunc) (GstImageInfo *info, GstImageConnection *conn);
|
GstCaps * caps);
|
||||||
typedef void (*GstImagePluginPutImageFunc) (GstImageInfo *info, GstImageData *image);
|
typedef GstImageData *(*GstImagePluginGetImageFunc) (GstImageInfo * info,
|
||||||
typedef void (*GstImagePluginFreeImageFunc) (GstImageData *image);
|
GstImageConnection * conn);
|
||||||
|
typedef void (*GstImagePluginPutImageFunc) (GstImageInfo * info,
|
||||||
|
GstImageData * image);
|
||||||
|
typedef void (*GstImagePluginFreeImageFunc) (GstImageData * image);
|
||||||
|
|
||||||
typedef struct _GstImagePlugin GstImagePlugin;
|
typedef struct _GstImagePlugin GstImagePlugin;
|
||||||
struct _GstImagePlugin {
|
struct _GstImagePlugin
|
||||||
GstImagePluginGetCapsFunc get_caps;
|
{
|
||||||
GstImagePluginSetCapsFunc set_caps;
|
GstImagePluginGetCapsFunc get_caps;
|
||||||
GstImagePluginGetImageFunc get_image;
|
GstImagePluginSetCapsFunc set_caps;
|
||||||
GstImagePluginPutImageFunc put_image;
|
GstImagePluginGetImageFunc get_image;
|
||||||
GstImagePluginFreeImageFunc free_image;
|
GstImagePluginPutImageFunc put_image;
|
||||||
};
|
GstImagePluginFreeImageFunc free_image;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _GstGLImageInfo GstGLImageInfo;
|
typedef struct _GstGLImageInfo GstGLImageInfo;
|
||||||
/* stuff about our window grouped together */
|
/* stuff about our window grouped together */
|
||||||
struct _GstGLImageInfo {
|
struct _GstGLImageInfo
|
||||||
GstImageInfo info;
|
{
|
||||||
Display *dpy;
|
GstImageInfo info;
|
||||||
int screen;
|
Display *dpy;
|
||||||
Window win;
|
int screen;
|
||||||
GLXContext ctx;
|
Window win;
|
||||||
XSetWindowAttributes attr;
|
GLXContext ctx;
|
||||||
Bool fs;
|
XSetWindowAttributes attr;
|
||||||
//XF86VidModeModeInfo deskMode;
|
Bool fs;
|
||||||
int x, y;
|
//XF86VidModeModeInfo deskMode;
|
||||||
unsigned int width, height;
|
int x, y;
|
||||||
unsigned int depth;
|
unsigned int width, height;
|
||||||
/* window specific from here */
|
unsigned int depth;
|
||||||
GstElement *sink;
|
/* window specific from here */
|
||||||
gulong handler_id;
|
GstElement *sink;
|
||||||
float rotX,rotY,zoom, zoomdir;
|
gulong handler_id;
|
||||||
};
|
float rotX, rotY, zoom, zoomdir;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_VIDEOSINK_H__ */
|
#endif /* __GST_VIDEOSINK_H__ */
|
||||||
|
@ -17,12 +17,11 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include "gstglsink.h"
|
#include "gstglsink.h"
|
||||||
#include <string.h> /* strncmp */
|
#include <string.h> /* strncmp */
|
||||||
|
|
||||||
/* attributes for a single buffered visual in RGBA format with at least
|
/* attributes for a single buffered visual in RGBA format with at least
|
||||||
* 4 bits per color and a 16 bit depth buffer */
|
* 4 bits per color and a 16 bit depth buffer */
|
||||||
static int attrListSgl[] =
|
static int attrListSgl[] = {
|
||||||
{
|
|
||||||
GLX_RGBA, GLX_RED_SIZE, 4,
|
GLX_RGBA, GLX_RED_SIZE, 4,
|
||||||
GLX_GREEN_SIZE, 4,
|
GLX_GREEN_SIZE, 4,
|
||||||
GLX_BLUE_SIZE, 4,
|
GLX_BLUE_SIZE, 4,
|
||||||
@ -32,113 +31,105 @@ static int attrListSgl[] =
|
|||||||
|
|
||||||
/* attributes for a double buffered visual in RGBA format with at least
|
/* attributes for a double buffered visual in RGBA format with at least
|
||||||
* 4 bits per color and a 16 bit depth buffer */
|
* 4 bits per color and a 16 bit depth buffer */
|
||||||
static int attrListDbl[] =
|
static int attrListDbl[] = {
|
||||||
{
|
GLX_RGBA, GLX_DOUBLEBUFFER,
|
||||||
GLX_RGBA, GLX_DOUBLEBUFFER,
|
GLX_RED_SIZE, 4,
|
||||||
GLX_RED_SIZE, 4,
|
GLX_GREEN_SIZE, 4,
|
||||||
GLX_GREEN_SIZE, 4,
|
GLX_BLUE_SIZE, 4,
|
||||||
GLX_BLUE_SIZE, 4,
|
GLX_DEPTH_SIZE, 16,
|
||||||
GLX_DEPTH_SIZE, 16,
|
None
|
||||||
None
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
|
GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
|
||||||
GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
|
GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
|
||||||
GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
|
GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_glxwindow_unhook_context(GstImageInfo *info)
|
gst_glxwindow_unhook_context (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
||||||
|
|
||||||
if (window->ctx)
|
if (window->ctx) {
|
||||||
{
|
if (!glXMakeCurrent (window->dpy, None, NULL)) {
|
||||||
if (!glXMakeCurrent(window->dpy, None, NULL))
|
printf ("Could not release drawing context.\n");
|
||||||
{
|
} else
|
||||||
printf("Could not release drawing context.\n");
|
printf ("Released drawing context.\n");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
printf("Released drawing context.\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_glxwindow_hook_context(GstImageInfo *info)
|
gst_glxwindow_hook_context (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
||||||
|
|
||||||
if (window->ctx && window->win && window->ctx)
|
if (window->ctx && window->win && window->ctx) {
|
||||||
{
|
if (!glXMakeCurrent (window->dpy, window->win, window->ctx)) {
|
||||||
if (!glXMakeCurrent(window->dpy, window->win, window->ctx))
|
printf ("Could not acquire GLX drawing context.\n");
|
||||||
{
|
} else
|
||||||
printf("Could not acquire GLX drawing context.\n");
|
printf ("Acquired drawing context.\n");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
printf("Acquired drawing context.\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glxwindow_free (GstImageInfo *info)
|
gst_glxwindow_free (GstImageInfo * info)
|
||||||
{
|
{
|
||||||
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
GstGLImageInfo *window = (GstGLImageInfo *) info;
|
||||||
|
|
||||||
g_signal_handler_disconnect (window->sink, window->handler_id);
|
g_signal_handler_disconnect (window->sink, window->handler_id);
|
||||||
|
|
||||||
if (window->ctx)
|
if (window->ctx) {
|
||||||
{
|
if (!glXMakeCurrent (window->dpy, None, NULL)) {
|
||||||
if (!glXMakeCurrent(window->dpy, None, NULL))
|
printf ("Could not release drawing context.\n");
|
||||||
{
|
|
||||||
printf("Could not release drawing context.\n");
|
|
||||||
}
|
|
||||||
glXDestroyContext(window->dpy, window->ctx);
|
|
||||||
window->ctx = NULL;
|
|
||||||
}
|
}
|
||||||
|
glXDestroyContext (window->dpy, window->ctx);
|
||||||
|
window->ctx = NULL;
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
/* switch back to original desktop resolution if we were in fs */
|
/* switch back to original desktop resolution if we were in fs */
|
||||||
if (GLWin.fs)
|
if (GLWin.fs) {
|
||||||
{
|
XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen, &GLWin.deskMode);
|
||||||
XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode);
|
XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0);
|
||||||
XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
XCloseDisplay (window->dpy);
|
XCloseDisplay (window->dpy);
|
||||||
g_free (window);
|
g_free (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
|
gst_glxwindow_callback (GObject * object, GParamSpec * pspec,
|
||||||
|
GstGLImageInfo * data)
|
||||||
{
|
{
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
XGetWindowAttributes(data->dpy, data->win, &attr);
|
|
||||||
|
|
||||||
if (strncmp (pspec->name, "width", 5) == 0 || strncmp (pspec->name, "height", 6) == 0)
|
XGetWindowAttributes (data->dpy, data->win, &attr);
|
||||||
{
|
|
||||||
|
if (strncmp (pspec->name, "width", 5) == 0
|
||||||
|
|| strncmp (pspec->name, "height", 6) == 0) {
|
||||||
gint w = 0;
|
gint w = 0;
|
||||||
gint h = 0;
|
gint h = 0;
|
||||||
|
|
||||||
g_object_get (object, "width", &w, NULL);
|
g_object_get (object, "width", &w, NULL);
|
||||||
g_object_get (object, "height", &h, NULL);
|
g_object_get (object, "height", &h, NULL);
|
||||||
if (w != attr.width || h != attr.height)
|
if (w != attr.width || h != attr.height) {
|
||||||
{
|
|
||||||
attr.width = w;
|
attr.width = w;
|
||||||
attr.height = h;
|
attr.height = h;
|
||||||
XResizeWindow (data->dpy, data->win, attr.width, attr.height);
|
XResizeWindow (data->dpy, data->win, attr.width, attr.height);
|
||||||
XMapRaised (data->dpy, data->win);
|
XMapRaised (data->dpy, data->win);
|
||||||
|
|
||||||
// resize OpenGL
|
// resize OpenGL
|
||||||
g_warning("resizing in OpenGL");
|
g_warning ("resizing in OpenGL");
|
||||||
glViewport(0, 0, (GLint) w, (GLint) h);
|
glViewport (0, 0, (GLint) w, (GLint) h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity ();
|
||||||
|
|
||||||
GLfloat aspect = (GLfloat) h / (GLfloat) w;
|
GLfloat aspect = (GLfloat) h / (GLfloat) w;
|
||||||
glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
|
|
||||||
|
glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attr.width != data->width || attr.height != data->height)
|
if (attr.width != data->width || attr.height != data->height) {
|
||||||
{
|
|
||||||
data->width = attr.width;
|
data->width = attr.width;
|
||||||
data->height = attr.height;
|
data->height = attr.height;
|
||||||
}
|
}
|
||||||
@ -146,23 +137,23 @@ gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_glxwindow_new (GstElement *sink)
|
gst_glxwindow_new (GstElement * sink)
|
||||||
{
|
{
|
||||||
//XGCValues values;
|
//XGCValues values;
|
||||||
GstGLImageInfo *new;
|
GstGLImageInfo *new;
|
||||||
int glxMajorVersion, glxMinorVersion;
|
int glxMajorVersion, glxMinorVersion;
|
||||||
|
|
||||||
//XSetWindowAttributes attrib;
|
//XSetWindowAttributes attrib;
|
||||||
XVisualInfo *vi;
|
XVisualInfo *vi;
|
||||||
Atom wmDelete;
|
Atom wmDelete;
|
||||||
Window winDummy;
|
Window winDummy;
|
||||||
unsigned int borderDummy;
|
unsigned int borderDummy;
|
||||||
Colormap cmap;
|
Colormap cmap;
|
||||||
char* title = "GLSink (experimental)";
|
char *title = "GLSink (experimental)";
|
||||||
|
|
||||||
new = g_new0 (GstGLImageInfo, 1);
|
new = g_new0 (GstGLImageInfo, 1);
|
||||||
|
|
||||||
if (sink == NULL)
|
if (sink == NULL) {
|
||||||
{
|
|
||||||
sink = gst_element_factory_make ("glsink", "glsink");
|
sink = gst_element_factory_make ("glsink", "glsink");
|
||||||
g_assert (sink != NULL);
|
g_assert (sink != NULL);
|
||||||
}
|
}
|
||||||
@ -177,26 +168,23 @@ gst_glxwindow_new (GstElement *sink)
|
|||||||
g_free (new);
|
g_free (new);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new->screen = DefaultScreen(new->dpy);
|
new->screen = DefaultScreen (new->dpy);
|
||||||
/* get an appropriate visual */
|
/* get an appropriate visual */
|
||||||
vi = glXChooseVisual(new->dpy, new->screen, attrListDbl);
|
vi = glXChooseVisual (new->dpy, new->screen, attrListDbl);
|
||||||
if (vi == NULL)
|
if (vi == NULL) {
|
||||||
{
|
vi = glXChooseVisual (new->dpy, new->screen, attrListSgl);
|
||||||
vi = glXChooseVisual(new->dpy, new->screen, attrListSgl);
|
GST_DEBUG ("Only Singlebuffered Visual!\n");
|
||||||
GST_DEBUG("Only Singlebuffered Visual!\n");
|
} else {
|
||||||
}
|
GST_DEBUG ("Got Doublebuffered Visual!\n");
|
||||||
else
|
}
|
||||||
{
|
glXQueryVersion (new->dpy, &glxMajorVersion, &glxMinorVersion);
|
||||||
GST_DEBUG("Got Doublebuffered Visual!\n");
|
GST_DEBUG ("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
|
||||||
}
|
|
||||||
glXQueryVersion(new->dpy, &glxMajorVersion, &glxMinorVersion);
|
|
||||||
GST_DEBUG("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
|
|
||||||
|
|
||||||
/* create a GLX context */
|
/* create a GLX context */
|
||||||
new->ctx = glXCreateContext(new->dpy, vi, 0, GL_TRUE);
|
new->ctx = glXCreateContext (new->dpy, vi, 0, GL_TRUE);
|
||||||
/* create a color map */
|
/* create a color map */
|
||||||
cmap = XCreateColormap(new->dpy, RootWindow(new->dpy, vi->screen),
|
cmap = XCreateColormap (new->dpy, RootWindow (new->dpy, vi->screen),
|
||||||
vi->visual, AllocNone);
|
vi->visual, AllocNone);
|
||||||
new->attr.colormap = cmap;
|
new->attr.colormap = cmap;
|
||||||
new->attr.border_pixel = 0;
|
new->attr.border_pixel = 0;
|
||||||
|
|
||||||
@ -212,66 +200,66 @@ gst_glxwindow_new (GstElement *sink)
|
|||||||
new->zoomdir = 0.01;
|
new->zoomdir = 0.01;
|
||||||
|
|
||||||
{
|
{
|
||||||
/* create a window in window mode*/
|
/* create a window in window mode */
|
||||||
new->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
|
new->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
|
||||||
StructureNotifyMask;
|
StructureNotifyMask;
|
||||||
new->win = XCreateWindow(new->dpy, RootWindow(new->dpy, vi->screen),
|
new->win = XCreateWindow (new->dpy, RootWindow (new->dpy, vi->screen),
|
||||||
new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput, vi->visual,
|
new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput,
|
||||||
CWBorderPixel | CWColormap | CWEventMask, &new->attr);
|
vi->visual, CWBorderPixel | CWColormap | CWEventMask, &new->attr);
|
||||||
if (!new->win)
|
if (!new->win) {
|
||||||
{
|
g_warning ("create window failed\n");
|
||||||
g_warning ("create window failed\n");
|
g_free (new);
|
||||||
g_free (new);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
/* only set window title and handle wm_delete_events if in windowed mode */
|
/* only set window title and handle wm_delete_events if in windowed mode */
|
||||||
wmDelete = XInternAtom(new->dpy, "WM_DELETE_WINDOW", True);
|
wmDelete = XInternAtom (new->dpy, "WM_DELETE_WINDOW", True);
|
||||||
XSetWMProtocols(new->dpy, new->win, &wmDelete, 1);
|
XSetWMProtocols (new->dpy, new->win, &wmDelete, 1);
|
||||||
XSetStandardProperties(new->dpy, new->win, title,
|
XSetStandardProperties (new->dpy, new->win, title,
|
||||||
title, None, NULL, 0, NULL);
|
title, None, NULL, 0, NULL);
|
||||||
XMapRaised(new->dpy, new->win);
|
XMapRaised (new->dpy, new->win);
|
||||||
}
|
}
|
||||||
/* connect the glx-context to the window */
|
/* connect the glx-context to the window */
|
||||||
glXMakeCurrent(new->dpy, new->win, new->ctx);
|
glXMakeCurrent (new->dpy, new->win, new->ctx);
|
||||||
XGetGeometry(new->dpy, new->win, &winDummy, &new->x, &new->y,
|
XGetGeometry (new->dpy, new->win, &winDummy, &new->x, &new->y,
|
||||||
&new->width, &new->height, &borderDummy, &new->depth);
|
&new->width, &new->height, &borderDummy, &new->depth);
|
||||||
printf("Depth %d\n", new->depth);
|
printf ("Depth %d\n", new->depth);
|
||||||
if (glXIsDirect(new->dpy, new->ctx))
|
if (glXIsDirect (new->dpy, new->ctx))
|
||||||
GST_DEBUG ("Congrats, you have Direct Rendering!\n");
|
GST_DEBUG ("Congrats, you have Direct Rendering!\n");
|
||||||
else
|
else
|
||||||
GST_DEBUG ("Sorry, no Direct Rendering possible!\n");
|
GST_DEBUG ("Sorry, no Direct Rendering possible!\n");
|
||||||
|
|
||||||
g_warning("Initializing OpenGL parameters\n");
|
g_warning ("Initializing OpenGL parameters\n");
|
||||||
/* initialize OpenGL drawing */
|
/* initialize OpenGL drawing */
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
//glShadeModel(GL_SMOOTH);
|
//glShadeModel(GL_SMOOTH);
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable (GL_CULL_FACE);
|
||||||
glClearDepth(1.0f);
|
glClearDepth (1.0f);
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor (0, 0, 0, 0);
|
||||||
|
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
|
glLightfv (GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
|
glLightfv (GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION,LightPosition); /* set light position. */
|
glLightfv (GL_LIGHT0, GL_POSITION, LightPosition); /* set light position. */
|
||||||
|
|
||||||
//glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
|
//glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
|
||||||
//glEnable(GL_LIGHTING); // Enable Lighting
|
//glEnable(GL_LIGHTING); // Enable Lighting
|
||||||
glDisable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
glDisable (GL_COLOR_MATERIAL); // Enable Material Coloring
|
||||||
glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
|
glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
glPolygonMode (GL_FRONT, GL_FILL);
|
||||||
glPolygonMode(GL_BACK, GL_FILL);
|
glPolygonMode (GL_BACK, GL_FILL);
|
||||||
|
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel (GL_SMOOTH);
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
|
|
||||||
XSelectInput (new->dpy, new->win, ExposureMask | StructureNotifyMask);
|
XSelectInput (new->dpy, new->win, ExposureMask | StructureNotifyMask);
|
||||||
|
|
||||||
g_object_set (sink, "hook", new, NULL);
|
g_object_set (sink, "hook", new, NULL);
|
||||||
new->sink = sink;
|
new->sink = sink;
|
||||||
new->handler_id = g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback), new);
|
new->handler_id =
|
||||||
|
g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback),
|
||||||
|
new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,313 +23,378 @@ unsigned char *UPlane;
|
|||||||
unsigned char *VPlane;
|
unsigned char *VPlane;
|
||||||
|
|
||||||
// YUV 4:2:2 example
|
// YUV 4:2:2 example
|
||||||
unsigned int Ywidth=512, Yheight=512;
|
unsigned int Ywidth = 512, Yheight = 512;
|
||||||
unsigned int UVwidth=256, UVheight=512;
|
unsigned int UVwidth = 256, UVheight = 512;
|
||||||
|
|
||||||
int tex_xsize, tex_ysize;
|
int tex_xsize, tex_ysize;
|
||||||
|
|
||||||
void GenerateRGBTables(unsigned char *Ytable, // Y-palette
|
void
|
||||||
unsigned char *Utable, // U-palette
|
GenerateRGBTables (unsigned char *Ytable, // Y-palette
|
||||||
unsigned char *Vtable, // V-palette
|
unsigned char *Utable, // U-palette
|
||||||
float *bias, // bias (fourth vector to be added)
|
unsigned char *Vtable, // V-palette
|
||||||
float *Uscale, // scaling color for U
|
float *bias, // bias (fourth vector to be added)
|
||||||
float *Vscale) // scaling color for V
|
float *Uscale, // scaling color for U
|
||||||
|
float *Vscale) // scaling color for V
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const float mat[9]= { // the modified YUV->RGB matrix
|
const float mat[9] = { // the modified YUV->RGB matrix
|
||||||
+1.130469478f,-0.058755723f,+1.596026304f,
|
+1.130469478f, -0.058755723f, +1.596026304f,
|
||||||
+1.130469478f,-0.450515935f,-0.812967512f,
|
+1.130469478f, -0.450515935f, -0.812967512f,
|
||||||
+1.130469478f,+1.958477882f, 0.0f
|
+1.130469478f, +1.958477882f, 0.0f
|
||||||
};
|
};
|
||||||
#define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
|
#define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
|
||||||
#define fCOMPRESS(a) (0.5f*(a)+0.5f);
|
#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.
|
#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[0] = fCOMPRESS (-0.842580964f);
|
||||||
bias[1]=fCOMPRESS(+0.563287723f);
|
bias[1] = fCOMPRESS (+0.563287723f);
|
||||||
bias[2]=fCOMPRESS(-1.0f);
|
bias[2] = fCOMPRESS (-1.0f);
|
||||||
bias[3]=0.0f;
|
bias[3] = 0.0f;
|
||||||
Uscale[0]=8.0f/255.0f;
|
Uscale[0] = 8.0f / 255.0f;
|
||||||
Uscale[1]=60.0f/255.0f;
|
Uscale[1] = 60.0f / 255.0f;
|
||||||
Uscale[2]=250.0f/255.0f;
|
Uscale[2] = 250.0f / 255.0f;
|
||||||
Uscale[3]=0.0f;
|
Uscale[3] = 0.0f;
|
||||||
Vscale[0]=204.0f/255.0f;
|
Vscale[0] = 204.0f / 255.0f;
|
||||||
Vscale[1]=105.0f/255.0f;
|
Vscale[1] = 105.0f / 255.0f;
|
||||||
Vscale[2]=0.5f;
|
Vscale[2] = 0.5f;
|
||||||
Vscale[3]=0.0f;
|
Vscale[3] = 0.0f;
|
||||||
for (i=0; i<256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
// Y-table holds unsigned values
|
// Y-table holds unsigned values
|
||||||
Ytable[3*i ]=(unsigned char)XCLAMP(mat[0]*(float)i); // R
|
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 + 1] = (unsigned char) XCLAMP (mat[3] * (float) i); // G
|
||||||
Ytable[3*i+2]=(unsigned char)XCLAMP(mat[6]*(float)i); // B
|
Ytable[3 * i + 2] = (unsigned char) XCLAMP (mat[6] * (float) i); // B
|
||||||
// U-table holds signed values
|
// U-table holds signed values
|
||||||
Utable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/ 16.0f*mat[1]*(float)i)); // R
|
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 + 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
|
Utable[3 * i + 2] = (unsigned char) XCLAMP (COMPRESS (255.0f / 500.0f * mat[7] * (float) i)); // B
|
||||||
// V-table holds signed values
|
// V-table holds signed values
|
||||||
Vtable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/408.0f*mat[2]*(float)i)); // R
|
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 + 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
|
Vtable[3 * i + 2] = (unsigned char) (128.0f - 14.0f); // G constant
|
||||||
}
|
}
|
||||||
#undef fCOMPRESS
|
#undef fCOMPRESS
|
||||||
#undef COMPRESS
|
#undef COMPRESS
|
||||||
#undef XCLAMP
|
#undef XCLAMP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets the constants. Call once prior to rendering.
|
// Sets the constants. Call once prior to rendering.
|
||||||
void SetConsts(float *bias, float *Uscale, float *Vscale) {
|
void
|
||||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
SetConsts (float *bias, float *Uscale, float *Vscale)
|
||||||
glColor3fv(bias);
|
{
|
||||||
//printf("%f %f %f\n",bias[0],bias[1],bias[2]);
|
glEnable (GL_REGISTER_COMBINERS_NV);
|
||||||
glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,Uscale);
|
glColor3fv (bias);
|
||||||
glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,Vscale);
|
//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
|
* SOFTWARE PATH
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void map_EXPAND_NORMAL(float *v) {
|
inline void
|
||||||
v[0]=2.0f*v[0]-1.0f;
|
map_EXPAND_NORMAL (float *v)
|
||||||
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];
|
v[0] = 2.0f * v[0] - 1.0f;
|
||||||
float SPARE1[3];
|
v[1] = 2.0f * v[1] - 1.0f;
|
||||||
float A[3],B[3],C[3],D[3];
|
v[2] = 2.0f * v[2] - 1.0f;
|
||||||
float TEX0[3],TEX1[3],TEX2[3];
|
}
|
||||||
float ZERO[3]={0.0f,0.0f,0.0f};
|
|
||||||
|
|
||||||
TEX0[0]=(float)tex0[0]/255.0f;
|
inline void
|
||||||
TEX0[1]=(float)tex0[1]/255.0f;
|
map_UNSIGNED_INVERT (float *v)
|
||||||
TEX0[2]=(float)tex0[2]/255.0f;
|
{
|
||||||
|
v[0] = 1.0f - v[0];
|
||||||
|
v[1] = 1.0f - v[1];
|
||||||
|
v[2] = 1.0f - v[2];
|
||||||
|
}
|
||||||
|
|
||||||
TEX1[0]=(float)tex1[0]/255.0f;
|
inline void
|
||||||
TEX1[1]=(float)tex1[1]/255.0f;
|
map_UNSIGNED_IDENTITY (float *v)
|
||||||
TEX1[2]=(float)tex1[2]/255.0f;
|
{
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
TEX2[0]=(float)tex2[0]/255.0f;
|
inline void
|
||||||
TEX2[1]=(float)tex2[1]/255.0f;
|
map_SIGNED_IDENTITY (float *v)
|
||||||
TEX2[2]=(float)tex2[2]/255.0f;
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Combiner Stage 0:
|
inline void
|
||||||
memcpy(A,TEX0,3*sizeof(float)); map_UNSIGNED_IDENTITY(A);
|
omap_SCALE_BY_TWO (float *v)
|
||||||
memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
|
{
|
||||||
memcpy(C,COLOR0,3*sizeof(float)); map_EXPAND_NORMAL(C);
|
v[0] *= 2.0f;
|
||||||
memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
|
v[1] *= 2.0f;
|
||||||
SPARE0[0]=A[0]*B[0]+C[0]*D[0];
|
v[2] *= 2.0f;
|
||||||
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:
|
inline void
|
||||||
memcpy(A,TEX1,3*sizeof(float)); map_EXPAND_NORMAL(A);
|
omap_SCALE_BY_ONE_HALF (float *v)
|
||||||
memcpy(B,CONST0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
|
{
|
||||||
memcpy(C,TEX2,3*sizeof(float)); map_EXPAND_NORMAL(C);
|
v[0] *= 0.5f;
|
||||||
memcpy(D,CONST1,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
|
v[1] *= 0.5f;
|
||||||
SPARE1[0]=A[0]*B[0]+C[0]*D[0];
|
v[2] *= 0.5f;
|
||||||
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:
|
inline void
|
||||||
memcpy(A,SPARE0,3*sizeof(float)); map_SIGNED_IDENTITY(A);
|
omap_RANGE (float *v)
|
||||||
memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
|
{
|
||||||
memcpy(C,SPARE1,3*sizeof(float)); map_SIGNED_IDENTITY(C);
|
v[0] = (v[0] < -1.0f ? -1.0f : (v[0] > 1.0f ? 1.0f : v[0]));
|
||||||
memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
|
v[1] = (v[1] < -1.0f ? -1.0f : (v[1] > 1.0f ? 1.0f : v[1]));
|
||||||
SPARE0[0]=A[0]*B[0]+C[0]*D[0];
|
v[2] = (v[2] < -1.0f ? -1.0f : (v[2] > 1.0f ? 1.0f : v[2]));
|
||||||
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);
|
inline void
|
||||||
memcpy(B,SPARE0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
|
omap_CLAMP_01 (float *v)
|
||||||
memcpy(C,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(C);
|
{
|
||||||
memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
|
v[0] = (v[0] < 0.0f ? 0.0f : (v[0] > 1.0f ? 1.0f : v[0]));
|
||||||
SPARE0[0]=A[0]*B[0]+(1.0f-A[0])*C[0]+D[0];
|
v[1] = (v[1] < 0.0f ? 0.0f : (v[1] > 1.0f ? 1.0f : v[1]));
|
||||||
SPARE0[1]=A[1]*B[1]+(1.0f-A[1])*C[1]+D[1];
|
v[2] = (v[2] < 0.0f ? 0.0f : (v[2] > 1.0f ? 1.0f : v[2]));
|
||||||
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);
|
void
|
||||||
Result[1]=(unsigned char)(SPARE0[1]*255.0f);
|
PerformSWCombiner (unsigned char *Result,
|
||||||
Result[2]=(unsigned char)(SPARE0[2]*255.0f);
|
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
|
// Sets up the register combiners. Call once prior to rendering
|
||||||
void SetupCombiners(void)
|
void
|
||||||
|
SetupCombiners (void)
|
||||||
{
|
{
|
||||||
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,3);
|
glCombinerParameteriNV (GL_NUM_GENERAL_COMBINERS_NV, 3);
|
||||||
// Combiner Stage 0: th. OK
|
// 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_A_NV, GL_TEXTURE0_ARB,
|
||||||
glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
GL_UNSIGNED_IDENTITY_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_B_NV, GL_ZERO,
|
||||||
glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
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);
|
glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
|
||||||
// Combiner Stage 1: th. OK
|
GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
|
||||||
glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
|
glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
|
||||||
glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||||
glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_C_NV,GL_TEXTURE2_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
|
glCombinerOutputNV (GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
|
||||||
glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_D_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
GL_SPARE0_NV, GL_SCALE_BY_ONE_HALF_NV, GL_NONE, GL_FALSE, GL_FALSE,
|
||||||
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);
|
GL_FALSE);
|
||||||
// Combiner Stage 2: th. OK
|
// Combiner Stage 1: th. OK
|
||||||
glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_A_NV,GL_SPARE0_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
|
glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
|
||||||
glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
GL_EXPAND_NORMAL_NV, GL_RGB);
|
||||||
glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_C_NV,GL_SPARE1_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
|
glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV,
|
||||||
glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_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);
|
glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB,
|
||||||
// Final Sage: th. OK
|
GL_EXPAND_NORMAL_NV, GL_RGB);
|
||||||
glFinalCombinerInputNV(GL_VARIABLE_A_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV,
|
||||||
glFinalCombinerInputNV(GL_VARIABLE_B_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
GL_CONSTANT_COLOR1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
|
||||||
glFinalCombinerInputNV(GL_VARIABLE_C_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
glCombinerOutputNV (GL_COMBINER1_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
|
||||||
glFinalCombinerInputNV(GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
GL_SPARE1_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
glFinalCombinerInputNV(GL_VARIABLE_G_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
// 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
|
||||||
unsigned int bitsum=0;
|
PowerOfTwo (unsigned int i)
|
||||||
unsigned int shifts=0;
|
{
|
||||||
unsigned int j=(unsigned int)i;
|
unsigned int bitsum = 0;
|
||||||
// Check wether i is a power of two - may contain at most one set bit
|
unsigned int shifts = 0;
|
||||||
do {
|
unsigned int j = (unsigned int) i;
|
||||||
bitsum+=j&1;
|
|
||||||
j=j>>1;
|
// Check wether i is a power of two - may contain at most one set bit
|
||||||
++shifts;
|
do {
|
||||||
} while (j>0);
|
bitsum += j & 1;
|
||||||
if (bitsum==1) return i;
|
j = j >> 1;
|
||||||
else return (1<<shifts);
|
++shifts;
|
||||||
|
} while (j > 0);
|
||||||
|
if (bitsum == 1)
|
||||||
|
return i;
|
||||||
|
else
|
||||||
|
return (1 << shifts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initializes textures. Call once prior to rendering
|
// Initializes textures. Call once prior to rendering
|
||||||
void InitYUVPlanes(GLuint *Yhandle, GLuint *Uhandle, GLuint *Vhandle,
|
void
|
||||||
unsigned int Ywidth, unsigned int Yheight,
|
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 int UVwidth, unsigned int UVheight,
|
unsigned char *Ypal, unsigned char *Upal, unsigned char *Vpal)
|
||||||
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, Yhandle);
|
||||||
glGenTextures(1,Uhandle);
|
glGenTextures (1, Uhandle);
|
||||||
glGenTextures(1,Vhandle);
|
glGenTextures (1, Vhandle);
|
||||||
glBindTexture(GL_TEXTURE_2D,(*Yhandle));
|
glBindTexture (GL_TEXTURE_2D, (*Yhandle));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
|
glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
|
||||||
#else // Hopefully Linux
|
#else // Hopefully Linux
|
||||||
glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
|
glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
|
||||||
#endif
|
#endif
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_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_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
tex_xsize = PowerOfTwo(Ywidth);
|
tex_xsize = PowerOfTwo (Ywidth);
|
||||||
tex_ysize = PowerOfTwo(Yheight);
|
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);
|
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));
|
glBindTexture (GL_TEXTURE_2D, (*Uhandle));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
|
glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
|
||||||
#else // Hopefully Linux
|
#else // Hopefully Linux
|
||||||
glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
|
glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
|
||||||
#endif
|
#endif
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_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_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,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);
|
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));
|
glBindTexture (GL_TEXTURE_2D, (*Vhandle));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
|
glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
|
||||||
#else // Hopefully Linux
|
#else // Hopefully Linux
|
||||||
glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
|
glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
|
||||||
#endif
|
#endif
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_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_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,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);
|
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,
|
void
|
||||||
unsigned int Ywidth, unsigned int Yheight,
|
LoadYUVPlanes (GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
|
||||||
unsigned int UVwidth, unsigned int UVheight,
|
unsigned int Ywidth, unsigned int Yheight,
|
||||||
unsigned char *Ydata,
|
unsigned int UVwidth, unsigned int UVheight,
|
||||||
unsigned char *Udata,
|
unsigned char *Ydata, unsigned char *Udata, unsigned char *Vdata)
|
||||||
unsigned char *Vdata)
|
|
||||||
{
|
{
|
||||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
glActiveTextureARB (GL_TEXTURE0_ARB);
|
||||||
glBindTexture(GL_TEXTURE_2D,Yhandle);
|
glBindTexture (GL_TEXTURE_2D, Yhandle);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Ywidth,Yheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Ydata);
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, Ywidth, Yheight, GL_COLOR_INDEX,
|
||||||
glEnable(GL_TEXTURE_2D);
|
GL_UNSIGNED_BYTE, Ydata);
|
||||||
|
glEnable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
glActiveTextureARB (GL_TEXTURE1_ARB);
|
||||||
glBindTexture(GL_TEXTURE_2D,Uhandle);
|
glBindTexture (GL_TEXTURE_2D, Uhandle);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Udata);
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
|
||||||
glEnable(GL_TEXTURE_2D);
|
GL_UNSIGNED_BYTE, Udata);
|
||||||
|
glEnable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
glActiveTextureARB(GL_TEXTURE2_ARB);
|
glActiveTextureARB (GL_TEXTURE2_ARB);
|
||||||
glBindTexture(GL_TEXTURE_2D,Vhandle);
|
glBindTexture (GL_TEXTURE_2D, Vhandle);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Vdata);
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
|
||||||
glEnable(GL_TEXTURE_2D);
|
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)
|
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);
|
printf ("Reinitializing register combiner backend with res %d x %d!\n",
|
||||||
|
Ywidth, Yheight);
|
||||||
//if (!GL_ARB_multitexture_Init()) exit(0);
|
//if (!GL_ARB_multitexture_Init()) exit(0);
|
||||||
//if (!GL_EXT_paletted_texture_Init()) exit(0);
|
//if (!GL_EXT_paletted_texture_Init()) exit(0);
|
||||||
//if (!GL_NV_register_combiners_Init()) exit(0);
|
//if (!GL_NV_register_combiners_Init()) exit(0);
|
||||||
@ -339,16 +404,20 @@ void Initialize_Backend(unsigned int Ywidth, unsigned int Yheight, unsigned int
|
|||||||
float bias[4];
|
float bias[4];
|
||||||
float Uscale[4];
|
float Uscale[4];
|
||||||
float Vscale[4];
|
float Vscale[4];
|
||||||
GenerateRGBTables(Ypal,Upal,Vpal,bias,Uscale,Vscale);
|
|
||||||
InitYUVPlanes(&Yhandle,&Uhandle,&Vhandle,Ywidth,Yheight,UVwidth,UVheight,filter,Ypal,Upal,Vpal);
|
GenerateRGBTables (Ypal, Upal, Vpal, bias, Uscale, Vscale);
|
||||||
SetupCombiners();
|
InitYUVPlanes (&Yhandle, &Uhandle, &Vhandle, Ywidth, Yheight, UVwidth,
|
||||||
SetConsts(bias,Uscale,Vscale);
|
UVheight, filter, Ypal, Upal, Vpal);
|
||||||
|
SetupCombiners ();
|
||||||
|
SetConsts (bias, Uscale, Vscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void initialize(GLenum filter) {
|
void
|
||||||
glShadeModel(GL_SMOOTH);
|
initialize (GLenum filter)
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
{
|
||||||
glClearColor(0.0f,0.0f,0.2f,1.0f);
|
glShadeModel (GL_SMOOTH);
|
||||||
Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,filter);
|
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
|
glClearColor (0.0f, 0.0f, 0.2f, 1.0f);
|
||||||
|
Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, filter);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user