t2 engine svn checkout

This commit is contained in:
loop 2024-01-07 04:36:33 +00:00
commit ff569bd2ae
988 changed files with 394180 additions and 0 deletions

798
platformX86UNIX/gl_func.h Normal file
View file

@ -0,0 +1,798 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
// Most of this is from...
/*
* Mesa 3-D graphics library
* Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//------------------------------------------------------------------------------
// GL functions
//------------------------------------------------------------------------------
/*
* Miscellaneous
*/
GL_FUNCTION(void, glClearIndex, ( GLfloat c ), return; )
GL_FUNCTION(void, glClearColor, ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ), return; )
GL_FUNCTION(void, glClear, ( GLbitfield mask ), return; )
GL_FUNCTION(void, glIndexMask, ( GLuint mask ), return; )
GL_FUNCTION(void, glColorMask, ( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ), return; )
GL_FUNCTION(void, glAlphaFunc, ( GLenum func, GLclampf ref ), return; )
GL_FUNCTION(void, glBlendFunc, ( GLenum sfactor, GLenum dfactor ), return; )
GL_FUNCTION(void, glLogicOp, ( GLenum opcode ), return; )
GL_FUNCTION(void, glCullFace, ( GLenum mode ), return; )
GL_FUNCTION(void, glFrontFace, ( GLenum mode ), return; )
GL_FUNCTION(void, glPointSize, ( GLfloat size ), return; )
GL_FUNCTION(void, glLineWidth, ( GLfloat width ), return; )
GL_FUNCTION(void, glLineStipple, ( GLint factor, GLushort pattern ), return; )
GL_FUNCTION(void, glPolygonMode, ( GLenum face, GLenum mode ), return; )
GL_FUNCTION(void, glPolygonOffset, ( GLfloat factor, GLfloat units ), return; )
GL_FUNCTION(void, glPolygonStipple, ( const GLubyte *mask ), return; )
GL_FUNCTION(void, glGetPolygonStipple, ( GLubyte *mask ), return; )
GL_FUNCTION(void, glEdgeFlag, ( GLboolean flag ), return; )
GL_FUNCTION(void, glEdgeFlagv, ( const GLboolean *flag ), return; )
GL_FUNCTION(void, glScissor, ( GLint x, GLint y, GLsizei width, GLsizei height), return; )
GL_FUNCTION(void, glClipPlane, ( GLenum plane, const GLdouble *equation ), return; )
GL_FUNCTION(void, glGetClipPlane, ( GLenum plane, GLdouble *equation ), return; )
GL_FUNCTION(void, glDrawBuffer, ( GLenum mode ), return; )
GL_FUNCTION(void, glReadBuffer, ( GLenum mode ), return; )
GL_FUNCTION(void, glEnable, ( GLenum cap ), return; )
GL_FUNCTION(void, glDisable, ( GLenum cap ), return; )
GL_FUNCTION(GLboolean, glIsEnabled, ( GLenum cap ), return GL_FALSE; )
GL_FUNCTION(void, glEnableClientState, ( GLenum cap ), return; ) /* 1.1 */
GL_FUNCTION(void, glDisableClientState, ( GLenum cap ), return; ) /* 1.1 */
GL_FUNCTION(void, glGetBooleanv, ( GLenum pname, GLboolean *params ), return; )
GL_FUNCTION(void, glGetDoublev, ( GLenum pname, GLdouble *params ), return; )
GL_FUNCTION(void, glGetFloatv, ( GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetIntegerv, ( GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glPushAttrib, ( GLbitfield mask ), return; )
GL_FUNCTION(void, glPopAttrib, ( void ), return; )
GL_FUNCTION(void, glPushClientAttrib, ( GLbitfield mask ), return; ) /* 1.1 */
GL_FUNCTION(void, glPopClientAttrib, ( void ), return; ) /* 1.1 */
GL_FUNCTION(GLint, glRenderMode, ( GLenum mode ), return 0; )
GL_FUNCTION(GLenum, glGetError, ( void ), return 0; )
GL_FUNCTION(const GLubyte*, glGetString, ( GLenum name ), return (const GLubyte*)""; )
GL_FUNCTION(void, glFinish, ( void ), return; )
GL_FUNCTION(void, glFlush, ( void ), return; )
GL_FUNCTION(void, glHint, ( GLenum target, GLenum mode ), return; )
/*
* Depth Buffer
*/
GL_FUNCTION(void, glClearDepth, ( GLclampd depth ), return; )
GL_FUNCTION(void, glDepthFunc, ( GLenum func ), return; )
GL_FUNCTION(void, glDepthMask, ( GLboolean flag ), return; )
GL_FUNCTION(void, glDepthRange, ( GLclampd near_val, GLclampd far_val ), return; )
/*
* Accumulation Buffer
*/
GL_FUNCTION(void, glClearAccum, ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ), return; )
GL_FUNCTION(void, glAccum, ( GLenum op, GLfloat value ), return; )
/*
* Transformation
*/
GL_FUNCTION(void, glMatrixMode, ( GLenum mode ), return; )
GL_FUNCTION(void, glOrtho, ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ), return; )
GL_FUNCTION(void, glFrustum, ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ), return; )
GL_FUNCTION(void, glViewport, ( GLint x, GLint y, GLsizei width, GLsizei height ), return; )
GL_FUNCTION(void, glPushMatrix, ( void ), return; )
GL_FUNCTION(void, glPopMatrix, ( void ), return; )
GL_FUNCTION(void, glLoadIdentity, ( void ), return; )
GL_FUNCTION(void, glLoadMatrixd, ( const GLdouble *m ), return; )
GL_FUNCTION(void, glLoadMatrixf, ( const GLfloat *m ), return; )
GL_FUNCTION(void, glMultMatrixd, ( const GLdouble *m ), return; )
GL_FUNCTION(void, glMultMatrixf, ( const GLfloat *m ), return; )
GL_FUNCTION(void, glRotated, ( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ), return; )
GL_FUNCTION(void, glRotatef, ( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ), return; )
GL_FUNCTION(void, glScaled, ( GLdouble x, GLdouble y, GLdouble z ), return; )
GL_FUNCTION(void, glScalef, ( GLfloat x, GLfloat y, GLfloat z ), return; )
GL_FUNCTION(void, glTranslated, ( GLdouble x, GLdouble y, GLdouble z ), return; )
GL_FUNCTION(void, glTranslatef, ( GLfloat x, GLfloat y, GLfloat z ), return; )
/*
* Display Lists
*/
GL_FUNCTION(GLboolean, glIsList, ( GLuint list ), return GL_FALSE; )
GL_FUNCTION(void, glDeleteLists, ( GLuint list, GLsizei range ), return; )
GL_FUNCTION(GLuint, glGenLists, ( GLsizei range ), return 0; )
GL_FUNCTION(void, glNewList, ( GLuint list, GLenum mode ), return; )
GL_FUNCTION(void, glEndList, ( void ), return; )
GL_FUNCTION(void, glCallList, ( GLuint list ), return; )
GL_FUNCTION(void, glCallLists, ( GLsizei n, GLenum type, const GLvoid *lists ), return; )
GL_FUNCTION(void, glListBase, ( GLuint base ), return; )
/*
* Drawing Functions
*/
GL_FUNCTION(void, glBegin, ( GLenum mode ), return; )
GL_FUNCTION(void, glEnd, ( void ), return; )
GL_FUNCTION(void, glVertex2d, ( GLdouble x, GLdouble y ), return; )
GL_FUNCTION(void, glVertex2f, ( GLfloat x, GLfloat y ), return; )
GL_FUNCTION(void, glVertex2i, ( GLint x, GLint y ), return; )
GL_FUNCTION(void, glVertex2s, ( GLshort x, GLshort y ), return; )
GL_FUNCTION(void, glVertex3d, ( GLdouble x, GLdouble y, GLdouble z ), return; )
GL_FUNCTION(void, glVertex3f, ( GLfloat x, GLfloat y, GLfloat z ), return; )
GL_FUNCTION(void, glVertex3i, ( GLint x, GLint y, GLint z ), return; )
GL_FUNCTION(void, glVertex3s, ( GLshort x, GLshort y, GLshort z ), return; )
GL_FUNCTION(void, glVertex4d, ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ), return; )
GL_FUNCTION(void, glVertex4f, ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ), return; )
GL_FUNCTION(void, glVertex4i, ( GLint x, GLint y, GLint z, GLint w ), return; )
GL_FUNCTION(void, glVertex4s, ( GLshort x, GLshort y, GLshort z, GLshort w ), return; )
GL_FUNCTION(void, glVertex2dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glVertex2fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glVertex2iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glVertex2sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glVertex3dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glVertex3fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glVertex3iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glVertex3sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glVertex4dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glVertex4fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glVertex4iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glVertex4sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glNormal3b, ( GLbyte nx, GLbyte ny, GLbyte nz ), return; )
GL_FUNCTION(void, glNormal3d, ( GLdouble nx, GLdouble ny, GLdouble nz ), return; )
GL_FUNCTION(void, glNormal3f, ( GLfloat nx, GLfloat ny, GLfloat nz ), return; )
GL_FUNCTION(void, glNormal3i, ( GLint nx, GLint ny, GLint nz ), return; )
GL_FUNCTION(void, glNormal3s, ( GLshort nx, GLshort ny, GLshort nz ), return; )
GL_FUNCTION(void, glNormal3bv, ( const GLbyte *v ), return; )
GL_FUNCTION(void, glNormal3dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glNormal3fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glNormal3iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glNormal3sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glIndexd, ( GLdouble c ), return; )
GL_FUNCTION(void, glIndexf, ( GLfloat c ), return; )
GL_FUNCTION(void, glIndexi, ( GLint c ), return; )
GL_FUNCTION(void, glIndexs, ( GLshort c ), return; )
GL_FUNCTION(void, glIndexub, ( GLubyte c ), return; ) /* 1.1 */
GL_FUNCTION(void, glIndexdv, ( const GLdouble *c ), return; )
GL_FUNCTION(void, glIndexfv, ( const GLfloat *c ), return; )
GL_FUNCTION(void, glIndexiv, ( const GLint *c ), return; )
GL_FUNCTION(void, glIndexsv, ( const GLshort *c ), return; )
GL_FUNCTION(void, glIndexubv, ( const GLubyte *c ), return; ) /* 1.1 */
GL_FUNCTION(void, glColor3b, ( GLbyte red, GLbyte green, GLbyte blue ), return; )
GL_FUNCTION(void, glColor3d, ( GLdouble red, GLdouble green, GLdouble blue ), return; )
GL_FUNCTION(void, glColor3f, ( GLfloat red, GLfloat green, GLfloat blue ), return; )
GL_FUNCTION(void, glColor3i, ( GLint red, GLint green, GLint blue ), return; )
GL_FUNCTION(void, glColor3s, ( GLshort red, GLshort green, GLshort blue ), return; )
GL_FUNCTION(void, glColor3ub, ( GLubyte red, GLubyte green, GLubyte blue ), return; )
GL_FUNCTION(void, glColor3ui, ( GLuint red, GLuint green, GLuint blue ), return; )
GL_FUNCTION(void, glColor3us, ( GLushort red, GLushort green, GLushort blue ), return; )
GL_FUNCTION(void, glColor4b, ( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ), return; )
GL_FUNCTION(void, glColor4d, ( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ), return; )
GL_FUNCTION(void, glColor4f, ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ), return; )
GL_FUNCTION(void, glColor4i, ( GLint red, GLint green, GLint blue, GLint alpha ), return; )
GL_FUNCTION(void, glColor4s, ( GLshort red, GLshort green, GLshort blue, GLshort alpha ), return; )
GL_FUNCTION(void, glColor4ub, ( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ), return; )
GL_FUNCTION(void, glColor4ui, ( GLuint red, GLuint green, GLuint blue, GLuint alpha ), return; )
GL_FUNCTION(void, glColor4us, ( GLushort red, GLushort green, GLushort blue, GLushort alpha ), return; )
GL_FUNCTION(void, glColor3bv, ( const GLbyte *v ), return; )
GL_FUNCTION(void, glColor3dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glColor3fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glColor3iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glColor3sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glColor3ubv, ( const GLubyte *v ), return; )
GL_FUNCTION(void, glColor3uiv, ( const GLuint *v ), return; )
GL_FUNCTION(void, glColor3usv, ( const GLushort *v ), return; )
GL_FUNCTION(void, glColor4bv, ( const GLbyte *v ), return; )
GL_FUNCTION(void, glColor4dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glColor4fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glColor4iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glColor4sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glColor4ubv, ( const GLubyte *v ), return; )
GL_FUNCTION(void, glColor4uiv, ( const GLuint *v ), return; )
GL_FUNCTION(void, glColor4usv, ( const GLushort *v ), return; )
GL_FUNCTION(void, glTexCoord1d, ( GLdouble s ), return; )
GL_FUNCTION(void, glTexCoord1f, ( GLfloat s ), return; )
GL_FUNCTION(void, glTexCoord1i, ( GLint s ), return; )
GL_FUNCTION(void, glTexCoord1s, ( GLshort s ), return; )
GL_FUNCTION(void, glTexCoord2d, ( GLdouble s, GLdouble t ), return; )
GL_FUNCTION(void, glTexCoord2f, ( GLfloat s, GLfloat t ), return; )
GL_FUNCTION(void, glTexCoord2i, ( GLint s, GLint t ), return; )
GL_FUNCTION(void, glTexCoord2s, ( GLshort s, GLshort t ), return; )
GL_FUNCTION(void, glTexCoord3d, ( GLdouble s, GLdouble t, GLdouble r ), return; )
GL_FUNCTION(void, glTexCoord3f, ( GLfloat s, GLfloat t, GLfloat r ), return; )
GL_FUNCTION(void, glTexCoord3i, ( GLint s, GLint t, GLint r ), return; )
GL_FUNCTION(void, glTexCoord3s, ( GLshort s, GLshort t, GLshort r ), return; )
GL_FUNCTION(void, glTexCoord4d, ( GLdouble s, GLdouble t, GLdouble r, GLdouble q ), return; )
GL_FUNCTION(void, glTexCoord4f, ( GLfloat s, GLfloat t, GLfloat r, GLfloat q ), return; )
GL_FUNCTION(void, glTexCoord4i, ( GLint s, GLint t, GLint r, GLint q ), return; )
GL_FUNCTION(void, glTexCoord4s, ( GLshort s, GLshort t, GLshort r, GLshort q ), return; )
GL_FUNCTION(void, glTexCoord1dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glTexCoord1fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glTexCoord1iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glTexCoord1sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glTexCoord2dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glTexCoord2fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glTexCoord2iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glTexCoord2sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glTexCoord3dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glTexCoord3fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glTexCoord3iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glTexCoord3sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glTexCoord4dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glTexCoord4fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glTexCoord4iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glTexCoord4sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glRasterPos2d, ( GLdouble x, GLdouble y ), return; )
GL_FUNCTION(void, glRasterPos2f, ( GLfloat x, GLfloat y ), return; )
GL_FUNCTION(void, glRasterPos2i, ( GLint x, GLint y ), return; )
GL_FUNCTION(void, glRasterPos2s, ( GLshort x, GLshort y ), return; )
GL_FUNCTION(void, glRasterPos3d, ( GLdouble x, GLdouble y, GLdouble z ), return; )
GL_FUNCTION(void, glRasterPos3f, ( GLfloat x, GLfloat y, GLfloat z ), return; )
GL_FUNCTION(void, glRasterPos3i, ( GLint x, GLint y, GLint z ), return; )
GL_FUNCTION(void, glRasterPos3s, ( GLshort x, GLshort y, GLshort z ), return; )
GL_FUNCTION(void, glRasterPos4d, ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ), return; )
GL_FUNCTION(void, glRasterPos4f, ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ), return; )
GL_FUNCTION(void, glRasterPos4i, ( GLint x, GLint y, GLint z, GLint w ), return; )
GL_FUNCTION(void, glRasterPos4s, ( GLshort x, GLshort y, GLshort z, GLshort w ), return; )
GL_FUNCTION(void, glRasterPos2dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glRasterPos2fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glRasterPos2iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glRasterPos2sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glRasterPos3dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glRasterPos3fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glRasterPos3iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glRasterPos3sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glRasterPos4dv, ( const GLdouble *v ), return; )
GL_FUNCTION(void, glRasterPos4fv, ( const GLfloat *v ), return; )
GL_FUNCTION(void, glRasterPos4iv, ( const GLint *v ), return; )
GL_FUNCTION(void, glRasterPos4sv, ( const GLshort *v ), return; )
GL_FUNCTION(void, glRectd, ( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ), return; )
GL_FUNCTION(void, glRectf, ( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ), return; )
GL_FUNCTION(void, glRecti, ( GLint x1, GLint y1, GLint x2, GLint y2 ), return; )
GL_FUNCTION(void, glRects, ( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ), return; )
GL_FUNCTION(void, glRectdv, ( const GLdouble *v1, const GLdouble *v2 ), return; )
GL_FUNCTION(void, glRectfv, ( const GLfloat *v1, const GLfloat *v2 ), return; )
GL_FUNCTION(void, glRectiv, ( const GLint *v1, const GLint *v2 ), return; )
GL_FUNCTION(void, glRectsv, ( const GLshort *v1, const GLshort *v2 ), return; )
/*
* Vertex Arrays (1.1)
*/
GL_FUNCTION(void, glVertexPointer, ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glNormalPointer, ( GLenum type, GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glColorPointer, ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glIndexPointer, ( GLenum type, GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glTexCoordPointer, ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glEdgeFlagPointer, ( GLsizei stride, const GLvoid *ptr ), return; )
GL_FUNCTION(void, glGetPointerv, ( GLenum pname, void **params ), return; )
GL_FUNCTION(void, glArrayElement, ( GLint i ), return; )
GL_FUNCTION(void, glDrawArrays, ( GLenum mode, GLint first, GLsizei count ), return; )
GL_FUNCTION(void, glDrawElements, ( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ), return; )
GL_FUNCTION(void, glInterleavedArrays, ( GLenum format, GLsizei stride, const GLvoid *pointer ), return; )
/*
* Lighting
*/
GL_FUNCTION(void, glShadeModel, ( GLenum mode ), return; )
GL_FUNCTION(void, glLightf, ( GLenum light, GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glLighti, ( GLenum light, GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glLightfv, ( GLenum light, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glLightiv, ( GLenum light, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glGetLightfv, ( GLenum light, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetLightiv, ( GLenum light, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glLightModelf, ( GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glLightModeli, ( GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glLightModelfv, ( GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glLightModeliv, ( GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glMaterialf, ( GLenum face, GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glMateriali, ( GLenum face, GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glMaterialfv, ( GLenum face, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glMaterialiv, ( GLenum face, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glGetMaterialfv, ( GLenum face, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetMaterialiv, ( GLenum face, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glColorMaterial, ( GLenum face, GLenum mode ), return; )
/*
* Raster functions
*/
GL_FUNCTION(void, glPixelZoom, ( GLfloat xfactor, GLfloat yfactor ), return; )
GL_FUNCTION(void, glPixelStoref, ( GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glPixelStorei, ( GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glPixelTransferf, ( GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glPixelTransferi, ( GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glPixelMapfv, ( GLenum map, GLint mapsize, const GLfloat *values ), return; )
GL_FUNCTION(void, glPixelMapuiv, ( GLenum map, GLint mapsize, const GLuint *values ), return; )
GL_FUNCTION(void, glPixelMapusv, ( GLenum map, GLint mapsize, const GLushort *values ), return; )
GL_FUNCTION(void, glGetPixelMapfv, ( GLenum map, GLfloat *values ), return; )
GL_FUNCTION(void, glGetPixelMapuiv, ( GLenum map, GLuint *values ), return; )
GL_FUNCTION(void, glGetPixelMapusv, ( GLenum map, GLushort *values ), return; )
GL_FUNCTION(void, glBitmap, ( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ), return; )
GL_FUNCTION(void, glReadPixels, ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ), return; )
GL_FUNCTION(void, glDrawPixels, ( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glCopyPixels, ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ), return; )
/*
* Stenciling
*/
GL_FUNCTION(void, glStencilFunc, ( GLenum func, GLint ref, GLuint mask ), return; )
GL_FUNCTION(void, glStencilMask, ( GLuint mask ), return; )
GL_FUNCTION(void, glStencilOp, ( GLenum fail, GLenum zfail, GLenum zpass ), return; )
GL_FUNCTION(void, glClearStencil, ( GLint s ), return; )
/*
* Texture mapping
*/
GL_FUNCTION(void, glTexGend, ( GLenum coord, GLenum pname, GLdouble param ), return; )
GL_FUNCTION(void, glTexGenf, ( GLenum coord, GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glTexGeni, ( GLenum coord, GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glTexGendv, ( GLenum coord, GLenum pname, const GLdouble *params ), return; )
GL_FUNCTION(void, glTexGenfv, ( GLenum coord, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glTexGeniv, ( GLenum coord, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glGetTexGendv, ( GLenum coord, GLenum pname, GLdouble *params ), return; )
GL_FUNCTION(void, glGetTexGenfv, ( GLenum coord, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetTexGeniv, ( GLenum coord, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glTexEnvf, ( GLenum target, GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glTexEnvi, ( GLenum target, GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glTexEnvfv, ( GLenum target, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glTexEnviv, ( GLenum target, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glGetTexEnvfv, ( GLenum target, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetTexEnviv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glTexParameterf, ( GLenum target, GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glTexParameteri, ( GLenum target, GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glTexParameterfv, ( GLenum target, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glTexParameteriv, ( GLenum target, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glGetTexParameterfv, ( GLenum target, GLenum pname, GLfloat *params), return; )
GL_FUNCTION(void, glGetTexParameteriv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glGetTexLevelParameterfv, ( GLenum target, GLint level, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetTexLevelParameteriv, ( GLenum target, GLint level, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glTexImage1D, ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glTexImage2D, ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glGetTexImage, ( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ), return; )
/* 1.1 functions */
GL_FUNCTION(void, glGenTextures, ( GLsizei n, GLuint *textures ), return; )
GL_FUNCTION(void, glDeleteTextures, ( GLsizei n, const GLuint *textures), return; )
GL_FUNCTION(void, glBindTexture, ( GLenum target, GLuint texture ), return; )
GL_FUNCTION(void, glPrioritizeTextures, ( GLsizei n, const GLuint *textures, const GLclampf *priorities ), return; )
GL_FUNCTION(GLboolean, glAreTexturesResident, ( GLsizei n, const GLuint *textures, GLboolean *residences ), return GL_FALSE; )
GL_FUNCTION(GLboolean, glIsTexture, ( GLuint texture ), return GL_FALSE; )
GL_FUNCTION(void, glTexSubImage1D, ( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glTexSubImage2D, ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glCopyTexImage1D, ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ), return; )
GL_FUNCTION(void, glCopyTexImage2D, ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ), return; )
GL_FUNCTION(void, glCopyTexSubImage1D, ( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ), return; )
GL_FUNCTION(void, glCopyTexSubImage2D, ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ), return; )
/*
* Evaluators
*/
GL_FUNCTION(void, glMap1d, ( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ), return; )
GL_FUNCTION(void, glMap1f, ( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ), return; )
GL_FUNCTION(void, glMap2d, ( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ), return; )
GL_FUNCTION(void, glMap2f, ( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ), return; )
GL_FUNCTION(void, glGetMapdv, ( GLenum target, GLenum query, GLdouble *v ), return; )
GL_FUNCTION(void, glGetMapfv, ( GLenum target, GLenum query, GLfloat *v ), return; )
GL_FUNCTION(void, glGetMapiv, ( GLenum target, GLenum query, GLint *v ), return; )
GL_FUNCTION(void, glEvalCoord1d, ( GLdouble u ), return; )
GL_FUNCTION(void, glEvalCoord1f, ( GLfloat u ), return; )
GL_FUNCTION(void, glEvalCoord1dv, ( const GLdouble *u ), return; )
GL_FUNCTION(void, glEvalCoord1fv, ( const GLfloat *u ), return; )
GL_FUNCTION(void, glEvalCoord2d, ( GLdouble u, GLdouble v ), return; )
GL_FUNCTION(void, glEvalCoord2f, ( GLfloat u, GLfloat v ), return; )
GL_FUNCTION(void, glEvalCoord2dv, ( const GLdouble *u ), return; )
GL_FUNCTION(void, glEvalCoord2fv, ( const GLfloat *u ), return; )
GL_FUNCTION(void, glMapGrid1d, ( GLint un, GLdouble u1, GLdouble u2 ), return; )
GL_FUNCTION(void, glMapGrid1f, ( GLint un, GLfloat u1, GLfloat u2 ), return; )
GL_FUNCTION(void, glMapGrid2d, ( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ), return; )
GL_FUNCTION(void, glMapGrid2f, ( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ), return; )
GL_FUNCTION(void, glEvalPoint1, ( GLint i ), return; )
GL_FUNCTION(void, glEvalPoint2, ( GLint i, GLint j ), return; )
GL_FUNCTION(void, glEvalMesh1, ( GLenum mode, GLint i1, GLint i2 ), return; )
GL_FUNCTION(void, glEvalMesh2, ( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ), return; )
/*
* Fog
*/
GL_FUNCTION(void, glFogf, ( GLenum pname, GLfloat param ), return; )
GL_FUNCTION(void, glFogi, ( GLenum pname, GLint param ), return; )
GL_FUNCTION(void, glFogfv, ( GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glFogiv, ( GLenum pname, const GLint *params ), return; )
/*
* Selection and Feedback
*/
GL_FUNCTION(void, glFeedbackBuffer, ( GLsizei size, GLenum type, GLfloat *buffer ), return; )
GL_FUNCTION(void, glPassThrough, ( GLfloat token ), return; )
GL_FUNCTION(void, glSelectBuffer, ( GLsizei size, GLuint *buffer ), return; )
GL_FUNCTION(void, glInitNames, ( void ), return; )
GL_FUNCTION(void, glLoadName, ( GLuint name ), return; )
GL_FUNCTION(void, glPushName, ( GLuint name ), return; )
GL_FUNCTION(void, glPopName, ( void ), return; )
/* 1.2 functions */
GL_FUNCTION(void, glDrawRangeElements, ( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ), return; )
GL_FUNCTION(void, glTexImage3D, ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ), return; )
GL_FUNCTION(void, glTexSubImage3D, ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels), return; )
GL_FUNCTION(void, glCopyTexSubImage3D, ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ), return; )
/* 1.2 imaging extension functions */
GL_FUNCTION(void, glColorTable, ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ), return; )
GL_FUNCTION(void, glColorSubTable, ( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ), return; )
GL_FUNCTION(void, glColorTableParameteriv, (GLenum target, GLenum pname, const GLint *params), return; )
GL_FUNCTION(void, glColorTableParameterfv, (GLenum target, GLenum pname, const GLfloat *params), return; )
GL_FUNCTION(void, glCopyColorSubTable, ( GLenum target, GLsizei start, GLint x, GLint y, GLsizei width ), return; )
GL_FUNCTION(void, glCopyColorTable, ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ), return; )
GL_FUNCTION(void, glGetColorTable, ( GLenum target, GLenum format, GLenum type, GLvoid *table ), return; )
GL_FUNCTION(void, glGetColorTableParameterfv, ( GLenum target, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetColorTableParameteriv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glBlendEquation, ( GLenum mode ), return; )
GL_FUNCTION(void, glBlendColor, ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ), return; )
GL_FUNCTION(void, glHistogram, ( GLenum target, GLsizei width, GLenum internalformat, GLboolean sink ), return; )
GL_FUNCTION(void, glResetHistogram, ( GLenum target ), return; )
GL_FUNCTION(void, glGetHistogram, ( GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values ), return; )
GL_FUNCTION(void, glGetHistogramParameterfv, ( GLenum target, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetHistogramParameteriv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glMinmax, ( GLenum target, GLenum internalformat, GLboolean sink ), return; )
GL_FUNCTION(void, glResetMinmax, ( GLenum target ), return; )
GL_FUNCTION(void, glGetMinmax, ( GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values ), return; )
GL_FUNCTION(void, glGetMinmaxParameterfv, ( GLenum target, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetMinmaxParameteriv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glConvolutionFilter1D, ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image ), return; )
GL_FUNCTION(void, glConvolutionFilter2D, ( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image ), return; )
GL_FUNCTION(void, glConvolutionParameterf, ( GLenum target, GLenum pname, GLfloat params ), return; )
GL_FUNCTION(void, glConvolutionParameterfv, ( GLenum target, GLenum pname, const GLfloat *params ), return; )
GL_FUNCTION(void, glConvolutionParameteri, ( GLenum target, GLenum pname, GLint params ), return; )
GL_FUNCTION(void, glConvolutionParameteriv, ( GLenum target, GLenum pname, const GLint *params ), return; )
GL_FUNCTION(void, glCopyConvolutionFilter1D, ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ), return; )
GL_FUNCTION(void, glCopyConvolutionFilter2D, ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height), return; )
GL_FUNCTION(void, glGetConvolutionFilter, ( GLenum target, GLenum format, GLenum type, GLvoid *image ), return; )
GL_FUNCTION(void, glGetConvolutionParameterfv, ( GLenum target, GLenum pname, GLfloat *params ), return; )
GL_FUNCTION(void, glGetConvolutionParameteriv, ( GLenum target, GLenum pname, GLint *params ), return; )
GL_FUNCTION(void, glSeparableFilter2D, ( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column ), return; )
GL_FUNCTION(void, glGetSeparableFilter, ( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ), return; )
GL_FUNCTION(void, glActiveTextureARB, (GLenum texture), return; )
GL_FUNCTION(void, glClientActiveTextureARB, (GLenum texture), return; )
GL_FUNCTION(void, glMultiTexCoord1dARB, (GLenum target, GLdouble s), return; )
GL_FUNCTION(void, glMultiTexCoord1dvARB, (GLenum target, const GLdouble *v), return; )
GL_FUNCTION(void, glMultiTexCoord1fARB, (GLenum target, GLfloat s), return; )
GL_FUNCTION(void, glMultiTexCoord1fvARB, (GLenum target, const GLfloat *v), return; )
GL_FUNCTION(void, glMultiTexCoord1iARB, (GLenum target, GLint s), return; )
GL_FUNCTION(void, glMultiTexCoord1ivARB, (GLenum target, const GLint *v), return; )
GL_FUNCTION(void, glMultiTexCoord1sARB, (GLenum target, GLshort s), return; )
GL_FUNCTION(void, glMultiTexCoord1svARB, (GLenum target, const GLshort *v), return; )
GL_FUNCTION(void, glMultiTexCoord2dARB, (GLenum target, GLdouble s, GLdouble t), return; )
GL_FUNCTION(void, glMultiTexCoord2dvARB, (GLenum target, const GLdouble *v), return; )
GL_FUNCTION(void, glMultiTexCoord2fARB, (GLenum target, GLfloat s, GLfloat t), return; )
GL_FUNCTION(void, glMultiTexCoord2fvARB, (GLenum target, const GLfloat *v), return; )
GL_FUNCTION(void, glMultiTexCoord2iARB, (GLenum target, GLint s, GLint t), return; )
GL_FUNCTION(void, glMultiTexCoord2ivARB, (GLenum target, const GLint *v), return; )
GL_FUNCTION(void, glMultiTexCoord2sARB, (GLenum target, GLshort s, GLshort t), return; )
GL_FUNCTION(void, glMultiTexCoord2svARB, (GLenum target, const GLshort *v), return; )
GL_FUNCTION(void, glMultiTexCoord3dARB, (GLenum target, GLdouble s, GLdouble t, GLdouble r), return; )
GL_FUNCTION(void, glMultiTexCoord3dvARB, (GLenum target, const GLdouble *v), return; )
GL_FUNCTION(void, glMultiTexCoord3fARB, (GLenum target, GLfloat s, GLfloat t, GLfloat r), return; )
GL_FUNCTION(void, glMultiTexCoord3fvARB, (GLenum target, const GLfloat *v), return; )
GL_FUNCTION(void, glMultiTexCoord3iARB, (GLenum target, GLint s, GLint t, GLint r), return; )
GL_FUNCTION(void, glMultiTexCoord3ivARB, (GLenum target, const GLint *v), return; )
GL_FUNCTION(void, glMultiTexCoord3sARB, (GLenum target, GLshort s, GLshort t, GLshort r), return; )
GL_FUNCTION(void, glMultiTexCoord3svARB, (GLenum target, const GLshort *v), return; )
GL_FUNCTION(void, glMultiTexCoord4dARB, (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q), return; )
GL_FUNCTION(void, glMultiTexCoord4dvARB, (GLenum target, const GLdouble *v), return; )
GL_FUNCTION(void, glMultiTexCoord4fARB, (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q), return; )
GL_FUNCTION(void, glMultiTexCoord4fvARB, (GLenum target, const GLfloat *v), return; )
GL_FUNCTION(void, glMultiTexCoord4iARB, (GLenum target, GLint s, GLint t, GLint r, GLint q), return; )
GL_FUNCTION(void, glMultiTexCoord4ivARB, (GLenum target, const GLint *v), return; )
GL_FUNCTION(void, glMultiTexCoord4sARB, (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q), return; )
GL_FUNCTION(void, glMultiTexCoord4svARB, (GLenum target, const GLshort *v), return; )
/* EXT_paletted_texture */
GL_FUNCTION(void, glColorTableEXT, (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data), return; )
/* EXT_compiled_vertex_array */
GL_FUNCTION(void, glLockArraysEXT, (GLint first, GLsizei count), return; )
GL_FUNCTION(void, glUnlockArraysEXT, (), return; )
/* EXT_fog_coord */
GL_FUNCTION(void, glFogCoordfEXT, (GLfloat coord), return; )
GL_FUNCTION(void, glFogCoordPointerEXT, (GLenum type, GLsizei stride, void *pointer), return; )
/* EXT_vertex_buffer */
GL_FUNCTION(GLboolean, glAvailableVertexBufferEXT, (void), return GL_FALSE; )
GL_FUNCTION(GLint, glAllocateVertexBufferEXT, (GLsizei size, GLint format, GLboolean preserve), return 0; )
GL_FUNCTION(void*, glLockVertexBufferEXT, (GLint handle, GLsizei size), return NULL; )
GL_FUNCTION(void, glUnlockVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glSetVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glOffsetVertexBufferEXT, (GLint handle, GLuint offset), return; )
GL_FUNCTION(void, glFillVertexBufferEXT, (GLint handle, GLint first, GLsizei count), return; )
GL_FUNCTION(void, glFreeVertexBufferEXT, (GLint handle), return; )

939
platformX86UNIX/gl_types.h Normal file
View file

@ -0,0 +1,939 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIX_GL_TYPES_H_
#define _X86UNIX_GL_TYPES_H_
// added by JMQ:
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
#define GL_FOG_COORDINATE_EXT 0x8451
#define GL_FRAGMENT_DEPTH_EXT 0x8452
#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
#define GL_COMPRESSED_ALPHA_ARB 0x84E9
#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
#define GL_COMPRESSED_RGB_ARB 0x84ED
#define GL_COMPRESSED_RGBA_ARB 0x84EE
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
#ifndef GL_EXT_packed_pixels
#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
#endif
#ifndef GL_EXT_paletted_texture
#define GL_COLOR_INDEX1_EXT 0x80E2
#define GL_COLOR_INDEX2_EXT 0x80E3
#define GL_COLOR_INDEX4_EXT 0x80E4
#define GL_COLOR_INDEX8_EXT 0x80E5
#define GL_COLOR_INDEX12_EXT 0x80E6
#define GL_COLOR_INDEX16_EXT 0x80E7
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
#endif
#define GL_CLAMP_TO_EDGE_EXT 0x812F
#define GL_V12MTVFMT_EXT 0x8702
#define GL_V12MTNVFMT_EXT 0x8703
#define GL_V12FTVFMT_EXT 0x8704
#define GL_V12FMTVFMT_EXT 0x8705
#ifndef GL_EXT_texture_env_combine
#define GL_COMBINE_EXT 0x8570
#define GL_COMBINE_RGB_EXT 0x8571
#define GL_COMBINE_ALPHA_EXT 0x8572
#define GL_RGB_SCALE_EXT 0x8573
#define GL_ADD_SIGNED_EXT 0x8574
#define GL_INTERPOLATE_EXT 0x8575
#define GL_CONSTANT_EXT 0x8576
#define GL_PRIMARY_COLOR_EXT 0x8577
#define GL_PREVIOUS_EXT 0x8578
#define GL_SOURCE0_RGB_EXT 0x8580
#define GL_SOURCE1_RGB_EXT 0x8581
#define GL_SOURCE2_RGB_EXT 0x8582
#define GL_SOURCE3_RGB_EXT 0x8583
#define GL_SOURCE4_RGB_EXT 0x8584
#define GL_SOURCE5_RGB_EXT 0x8585
#define GL_SOURCE6_RGB_EXT 0x8586
#define GL_SOURCE7_RGB_EXT 0x8587
#define GL_SOURCE0_ALPHA_EXT 0x8588
#define GL_SOURCE1_ALPHA_EXT 0x8589
#define GL_SOURCE2_ALPHA_EXT 0x858A
#define GL_SOURCE3_ALPHA_EXT 0x858B
#define GL_SOURCE4_ALPHA_EXT 0x858C
#define GL_SOURCE5_ALPHA_EXT 0x858D
#define GL_SOURCE6_ALPHA_EXT 0x858E
#define GL_SOURCE7_ALPHA_EXT 0x858F
#define GL_OPERAND0_RGB_EXT 0x8590
#define GL_OPERAND1_RGB_EXT 0x8591
#define GL_OPERAND2_RGB_EXT 0x8592
#define GL_OPERAND3_RGB_EXT 0x8593
#define GL_OPERAND4_RGB_EXT 0x8594
#define GL_OPERAND5_RGB_EXT 0x8595
#define GL_OPERAND6_RGB_EXT 0x8596
#define GL_OPERAND7_RGB_EXT 0x8597
#define GL_OPERAND0_ALPHA_EXT 0x8598
#define GL_OPERAND1_ALPHA_EXT 0x8599
#define GL_OPERAND2_ALPHA_EXT 0x859A
#define GL_OPERAND3_ALPHA_EXT 0x859B
#define GL_OPERAND4_ALPHA_EXT 0x859C
#define GL_OPERAND5_ALPHA_EXT 0x859D
#define GL_OPERAND6_ALPHA_EXT 0x859E
#define GL_OPERAND7_ALPHA_EXT 0x859F
#endif
/*
* Mesa 3-D graphics library
* Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define GL_VERSION_1_1 1
#define GL_VERSION_1_2 1
/*
*
* Datatypes
*
*/
#ifdef CENTERLINE_CLPP
#define signed
#endif
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef void GLvoid;
typedef signed char GLbyte; /* 1-byte signed */
typedef short GLshort; /* 2-byte signed */
typedef int GLint; /* 4-byte signed */
typedef unsigned char GLubyte; /* 1-byte unsigned */
typedef unsigned short GLushort; /* 2-byte unsigned */
typedef unsigned int GLuint; /* 4-byte unsigned */
typedef int GLsizei; /* 4-byte signed */
typedef float GLfloat; /* single precision float */
typedef float GLclampf; /* single precision float in [0,1] */
typedef double GLdouble; /* double precision float */
typedef double GLclampd; /* double precision float in [0,1] */
/*
*
* Constants
*
*/
/* Boolean values */
#define GL_FALSE 0x0
#define GL_TRUE 0x1
/* Data types */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_DOUBLE 0x140A
#define GL_2_BYTES 0x1407
#define GL_3_BYTES 0x1408
#define GL_4_BYTES 0x1409
/* Primitives */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUADS 0x0007
#define GL_QUAD_STRIP 0x0008
#define GL_POLYGON 0x0009
/* Vertex Arrays */
#define GL_VERTEX_ARRAY 0x8074
#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
#define GL_INDEX_ARRAY 0x8077
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_EDGE_FLAG_ARRAY 0x8079
#define GL_VERTEX_ARRAY_SIZE 0x807A
#define GL_VERTEX_ARRAY_TYPE 0x807B
#define GL_VERTEX_ARRAY_STRIDE 0x807C
#define GL_NORMAL_ARRAY_TYPE 0x807E
#define GL_NORMAL_ARRAY_STRIDE 0x807F
#define GL_COLOR_ARRAY_SIZE 0x8081
#define GL_COLOR_ARRAY_TYPE 0x8082
#define GL_COLOR_ARRAY_STRIDE 0x8083
#define GL_INDEX_ARRAY_TYPE 0x8085
#define GL_INDEX_ARRAY_STRIDE 0x8086
#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
#define GL_VERTEX_ARRAY_POINTER 0x808E
#define GL_NORMAL_ARRAY_POINTER 0x808F
#define GL_COLOR_ARRAY_POINTER 0x8090
#define GL_INDEX_ARRAY_POINTER 0x8091
#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
#define GL_V2F 0x2A20
#define GL_V3F 0x2A21
#define GL_C4UB_V2F 0x2A22
#define GL_C4UB_V3F 0x2A23
#define GL_C3F_V3F 0x2A24
#define GL_N3F_V3F 0x2A25
#define GL_C4F_N3F_V3F 0x2A26
#define GL_T2F_V3F 0x2A27
#define GL_T4F_V4F 0x2A28
#define GL_T2F_C4UB_V3F 0x2A29
#define GL_T2F_C3F_V3F 0x2A2A
#define GL_T2F_N3F_V3F 0x2A2B
#define GL_T2F_C4F_N3F_V3F 0x2A2C
#define GL_T4F_C4F_N3F_V4F 0x2A2D
/* Matrix Mode */
#define GL_MATRIX_MODE 0x0BA0
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_TEXTURE 0x1702
/* Points */
#define GL_POINT_SMOOTH 0x0B10
#define GL_POINT_SIZE 0x0B11
#define GL_POINT_SIZE_GRANULARITY 0x0B13
#define GL_POINT_SIZE_RANGE 0x0B12
/* Lines */
#define GL_LINE_SMOOTH 0x0B20
#define GL_LINE_STIPPLE 0x0B24
#define GL_LINE_STIPPLE_PATTERN 0x0B25
#define GL_LINE_STIPPLE_REPEAT 0x0B26
#define GL_LINE_WIDTH 0x0B21
#define GL_LINE_WIDTH_GRANULARITY 0x0B23
#define GL_LINE_WIDTH_RANGE 0x0B22
/* Polygons */
#define GL_POINT 0x1B00
#define GL_LINE 0x1B01
#define GL_FILL 0x1B02
#define GL_CW 0x0900
#define GL_CCW 0x0901
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_POLYGON_MODE 0x0B40
#define GL_POLYGON_SMOOTH 0x0B41
#define GL_POLYGON_STIPPLE 0x0B42
#define GL_EDGE_FLAG 0x0B43
#define GL_CULL_FACE 0x0B44
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_POINT 0x2A01
#define GL_POLYGON_OFFSET_LINE 0x2A02
#define GL_POLYGON_OFFSET_FILL 0x8037
/* Display Lists */
#define GL_COMPILE 0x1300
#define GL_COMPILE_AND_EXECUTE 0x1301
#define GL_LIST_BASE 0x0B32
#define GL_LIST_INDEX 0x0B33
#define GL_LIST_MODE 0x0B30
/* Depth buffer */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
#define GL_DEPTH_TEST 0x0B71
#define GL_DEPTH_BITS 0x0D56
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_COMPONENT 0x1902
/* Lighting */
#define GL_LIGHTING 0x0B50
#define GL_LIGHT0 0x4000
#define GL_LIGHT1 0x4001
#define GL_LIGHT2 0x4002
#define GL_LIGHT3 0x4003
#define GL_LIGHT4 0x4004
#define GL_LIGHT5 0x4005
#define GL_LIGHT6 0x4006
#define GL_LIGHT7 0x4007
#define GL_SPOT_EXPONENT 0x1205
#define GL_SPOT_CUTOFF 0x1206
#define GL_CONSTANT_ATTENUATION 0x1207
#define GL_LINEAR_ATTENUATION 0x1208
#define GL_QUADRATIC_ATTENUATION 0x1209
#define GL_AMBIENT 0x1200
#define GL_DIFFUSE 0x1201
#define GL_SPECULAR 0x1202
#define GL_SHININESS 0x1601
#define GL_EMISSION 0x1600
#define GL_POSITION 0x1203
#define GL_SPOT_DIRECTION 0x1204
#define GL_AMBIENT_AND_DIFFUSE 0x1602
#define GL_COLOR_INDEXES 0x1603
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
#define GL_FRONT_AND_BACK 0x0408
#define GL_SHADE_MODEL 0x0B54
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
#define GL_COLOR_MATERIAL 0x0B57
#define GL_COLOR_MATERIAL_FACE 0x0B55
#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
#define GL_NORMALIZE 0x0BA1
/* User clipping planes */
#define GL_CLIP_PLANE0 0x3000
#define GL_CLIP_PLANE1 0x3001
#define GL_CLIP_PLANE2 0x3002
#define GL_CLIP_PLANE3 0x3003
#define GL_CLIP_PLANE4 0x3004
#define GL_CLIP_PLANE5 0x3005
/* Accumulation buffer */
#define GL_ACCUM_RED_BITS 0x0D58
#define GL_ACCUM_GREEN_BITS 0x0D59
#define GL_ACCUM_BLUE_BITS 0x0D5A
#define GL_ACCUM_ALPHA_BITS 0x0D5B
#define GL_ACCUM_CLEAR_VALUE 0x0B80
#define GL_ACCUM 0x0100
#define GL_ADD 0x0104
#define GL_LOAD 0x0101
#define GL_MULT 0x0103
#define GL_RETURN 0x0102
/* Alpha testing */
#define GL_ALPHA_TEST 0x0BC0
#define GL_ALPHA_TEST_REF 0x0BC2
#define GL_ALPHA_TEST_FUNC 0x0BC1
/* Blending */
#define GL_BLEND 0x0BE2
#define GL_BLEND_SRC 0x0BE1
#define GL_BLEND_DST 0x0BE0
#define GL_ZERO 0x0
#define GL_ONE 0x1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
#define GL_SRC_ALPHA_SATURATE 0x0308
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
/* Render Mode */
#define GL_FEEDBACK 0x1C01
#define GL_RENDER 0x1C00
#define GL_SELECT 0x1C02
/* Feedback */
#define GL_2D 0x0600
#define GL_3D 0x0601
#define GL_3D_COLOR 0x0602
#define GL_3D_COLOR_TEXTURE 0x0603
#define GL_4D_COLOR_TEXTURE 0x0604
#define GL_POINT_TOKEN 0x0701
#define GL_LINE_TOKEN 0x0702
#define GL_LINE_RESET_TOKEN 0x0707
#define GL_POLYGON_TOKEN 0x0703
#define GL_BITMAP_TOKEN 0x0704
#define GL_DRAW_PIXEL_TOKEN 0x0705
#define GL_COPY_PIXEL_TOKEN 0x0706
#define GL_PASS_THROUGH_TOKEN 0x0700
#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
/* Selection */
#define GL_SELECTION_BUFFER_POINTER 0x0DF3
#define GL_SELECTION_BUFFER_SIZE 0x0DF4
/* Fog */
#define GL_FOG 0x0B60
#define GL_FOG_MODE 0x0B65
#define GL_FOG_DENSITY 0x0B62
#define GL_FOG_COLOR 0x0B66
#define GL_FOG_INDEX 0x0B61
#define GL_FOG_START 0x0B63
#define GL_FOG_END 0x0B64
#define GL_LINEAR 0x2601
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
/* Logic Ops */
#define GL_LOGIC_OP 0x0BF1
#define GL_INDEX_LOGIC_OP 0x0BF1
#define GL_COLOR_LOGIC_OP 0x0BF2
#define GL_LOGIC_OP_MODE 0x0BF0
#define GL_CLEAR 0x1500
#define GL_SET 0x150F
#define GL_COPY 0x1503
#define GL_COPY_INVERTED 0x150C
#define GL_NOOP 0x1505
#define GL_INVERT 0x150A
#define GL_AND 0x1501
#define GL_NAND 0x150E
#define GL_OR 0x1507
#define GL_NOR 0x1508
#define GL_XOR 0x1506
#define GL_EQUIV 0x1509
#define GL_AND_REVERSE 0x1502
#define GL_AND_INVERTED 0x1504
#define GL_OR_REVERSE 0x150B
#define GL_OR_INVERTED 0x150D
/* Stencil */
#define GL_STENCIL_TEST 0x0B90
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BITS 0x0D57
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_INDEX 0x1901
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
/* Buffers, Pixel Drawing/Reading */
#define GL_NONE 0x0
#define GL_LEFT 0x0406
#define GL_RIGHT 0x0407
/*GL_FRONT 0x0404 */
/*GL_BACK 0x0405 */
/*GL_FRONT_AND_BACK 0x0408 */
#define GL_FRONT_LEFT 0x0400
#define GL_FRONT_RIGHT 0x0401
#define GL_BACK_LEFT 0x0402
#define GL_BACK_RIGHT 0x0403
#define GL_AUX0 0x0409
#define GL_AUX1 0x040A
#define GL_AUX2 0x040B
#define GL_AUX3 0x040C
#define GL_COLOR_INDEX 0x1900
#define GL_RED 0x1903
#define GL_GREEN 0x1904
#define GL_BLUE 0x1905
#define GL_ALPHA 0x1906
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#define GL_ALPHA_BITS 0x0D55
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_INDEX_BITS 0x0D51
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_AUX_BUFFERS 0x0C00
#define GL_READ_BUFFER 0x0C02
#define GL_DRAW_BUFFER 0x0C01
#define GL_DOUBLEBUFFER 0x0C32
#define GL_STEREO 0x0C33
#define GL_BITMAP 0x1A00
#define GL_COLOR 0x1800
#define GL_DEPTH 0x1801
#define GL_STENCIL 0x1802
#define GL_DITHER 0x0BD0
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
/* Implementation limits */
#define GL_MAX_LIST_NESTING 0x0B31
#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
#define GL_MAX_NAME_STACK_DEPTH 0x0D37
#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
#define GL_MAX_EVAL_ORDER 0x0D30
#define GL_MAX_LIGHTS 0x0D31
#define GL_MAX_CLIP_PLANES 0x0D32
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
/* Gets */
#define GL_ATTRIB_STACK_DEPTH 0x0BB0
#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_CURRENT_INDEX 0x0B01
#define GL_CURRENT_COLOR 0x0B00
#define GL_CURRENT_NORMAL 0x0B02
#define GL_CURRENT_RASTER_COLOR 0x0B04
#define GL_CURRENT_RASTER_DISTANCE 0x0B09
#define GL_CURRENT_RASTER_INDEX 0x0B05
#define GL_CURRENT_RASTER_POSITION 0x0B07
#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
#define GL_CURRENT_TEXTURE_COORDS 0x0B03
#define GL_INDEX_CLEAR_VALUE 0x0C20
#define GL_INDEX_MODE 0x0C30
#define GL_INDEX_WRITEMASK 0x0C21
#define GL_MODELVIEW_MATRIX 0x0BA6
#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
#define GL_NAME_STACK_DEPTH 0x0D70
#define GL_PROJECTION_MATRIX 0x0BA7
#define GL_PROJECTION_STACK_DEPTH 0x0BA4
#define GL_RENDER_MODE 0x0C40
#define GL_RGBA_MODE 0x0C31
#define GL_TEXTURE_MATRIX 0x0BA8
#define GL_TEXTURE_STACK_DEPTH 0x0BA5
#define GL_VIEWPORT 0x0BA2
/* Evaluators */
#define GL_AUTO_NORMAL 0x0D80
#define GL_MAP1_COLOR_4 0x0D90
#define GL_MAP1_GRID_DOMAIN 0x0DD0
#define GL_MAP1_GRID_SEGMENTS 0x0DD1
#define GL_MAP1_INDEX 0x0D91
#define GL_MAP1_NORMAL 0x0D92
#define GL_MAP1_TEXTURE_COORD_1 0x0D93
#define GL_MAP1_TEXTURE_COORD_2 0x0D94
#define GL_MAP1_TEXTURE_COORD_3 0x0D95
#define GL_MAP1_TEXTURE_COORD_4 0x0D96
#define GL_MAP1_VERTEX_3 0x0D97
#define GL_MAP1_VERTEX_4 0x0D98
#define GL_MAP2_COLOR_4 0x0DB0
#define GL_MAP2_GRID_DOMAIN 0x0DD2
#define GL_MAP2_GRID_SEGMENTS 0x0DD3
#define GL_MAP2_INDEX 0x0DB1
#define GL_MAP2_NORMAL 0x0DB2
#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
#define GL_MAP2_VERTEX_3 0x0DB7
#define GL_MAP2_VERTEX_4 0x0DB8
#define GL_COEFF 0x0A00
#define GL_DOMAIN 0x0A02
#define GL_ORDER 0x0A01
/* Hints */
#define GL_FOG_HINT 0x0C54
#define GL_LINE_SMOOTH_HINT 0x0C52
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
#define GL_POINT_SMOOTH_HINT 0x0C51
#define GL_POLYGON_SMOOTH_HINT 0x0C53
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* Scissor box */
#define GL_SCISSOR_TEST 0x0C11
#define GL_SCISSOR_BOX 0x0C10
/* Pixel Mode / Transfer */
#define GL_MAP_COLOR 0x0D10
#define GL_MAP_STENCIL 0x0D11
#define GL_INDEX_SHIFT 0x0D12
#define GL_INDEX_OFFSET 0x0D13
#define GL_RED_SCALE 0x0D14
#define GL_RED_BIAS 0x0D15
#define GL_GREEN_SCALE 0x0D18
#define GL_GREEN_BIAS 0x0D19
#define GL_BLUE_SCALE 0x0D1A
#define GL_BLUE_BIAS 0x0D1B
#define GL_ALPHA_SCALE 0x0D1C
#define GL_ALPHA_BIAS 0x0D1D
#define GL_DEPTH_SCALE 0x0D1E
#define GL_DEPTH_BIAS 0x0D1F
#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
#define GL_PIXEL_MAP_S_TO_S 0x0C71
#define GL_PIXEL_MAP_I_TO_I 0x0C70
#define GL_PIXEL_MAP_I_TO_R 0x0C72
#define GL_PIXEL_MAP_I_TO_G 0x0C73
#define GL_PIXEL_MAP_I_TO_B 0x0C74
#define GL_PIXEL_MAP_I_TO_A 0x0C75
#define GL_PIXEL_MAP_R_TO_R 0x0C76
#define GL_PIXEL_MAP_G_TO_G 0x0C77
#define GL_PIXEL_MAP_B_TO_B 0x0C78
#define GL_PIXEL_MAP_A_TO_A 0x0C79
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_PACK_LSB_FIRST 0x0D01
#define GL_PACK_ROW_LENGTH 0x0D02
#define GL_PACK_SKIP_PIXELS 0x0D04
#define GL_PACK_SKIP_ROWS 0x0D03
#define GL_PACK_SWAP_BYTES 0x0D00
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_UNPACK_LSB_FIRST 0x0CF1
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#define GL_UNPACK_SWAP_BYTES 0x0CF0
#define GL_ZOOM_X 0x0D16
#define GL_ZOOM_Y 0x0D17
/* Texture mapping */
#define GL_TEXTURE_ENV 0x2300
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_1D 0x0DE0
#define GL_TEXTURE_2D 0x0DE1
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_ENV_COLOR 0x2201
#define GL_TEXTURE_GEN_S 0x0C60
#define GL_TEXTURE_GEN_T 0x0C61
#define GL_TEXTURE_GEN_MODE 0x2500
#define GL_TEXTURE_BORDER_COLOR 0x1004
#define GL_TEXTURE_WIDTH 0x1000
#define GL_TEXTURE_HEIGHT 0x1001
#define GL_TEXTURE_BORDER 0x1005
#define GL_TEXTURE_COMPONENTS 0x1003
#define GL_TEXTURE_RED_SIZE 0x805C
#define GL_TEXTURE_GREEN_SIZE 0x805D
#define GL_TEXTURE_BLUE_SIZE 0x805E
#define GL_TEXTURE_ALPHA_SIZE 0x805F
#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
#define GL_TEXTURE_INTENSITY_SIZE 0x8061
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
#define GL_OBJECT_LINEAR 0x2401
#define GL_OBJECT_PLANE 0x2501
#define GL_EYE_LINEAR 0x2400
#define GL_EYE_PLANE 0x2502
#define GL_SPHERE_MAP 0x2402
#define GL_DECAL 0x2101
#define GL_MODULATE 0x2100
#define GL_NEAREST 0x2600
#define GL_REPEAT 0x2901
#define GL_CLAMP 0x2900
#define GL_S 0x2000
#define GL_T 0x2001
#define GL_R 0x2002
#define GL_Q 0x2003
#define GL_TEXTURE_GEN_R 0x0C62
#define GL_TEXTURE_GEN_Q 0x0C63
/* GL 1.1 texturing */
#define GL_PROXY_TEXTURE_1D 0x8063
#define GL_PROXY_TEXTURE_2D 0x8064
#define GL_TEXTURE_PRIORITY 0x8066
#define GL_TEXTURE_RESIDENT 0x8067
#define GL_TEXTURE_BINDING_1D 0x8068
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
/* GL 1.2 texturing */
#define GL_PACK_SKIP_IMAGES 0x806B
#define GL_PACK_IMAGE_HEIGHT 0x806C
#define GL_UNPACK_SKIP_IMAGES 0x806D
#define GL_UNPACK_IMAGE_HEIGHT 0x806E
#define GL_TEXTURE_3D 0x806F
#define GL_PROXY_TEXTURE_3D 0x8070
#define GL_TEXTURE_DEPTH 0x8071
#define GL_TEXTURE_WRAP_R 0x8072
#define GL_MAX_3D_TEXTURE_SIZE 0x8073
#define GL_TEXTURE_BINDING_3D 0x806A
/* Internal texture formats (GL 1.1) */
#define GL_ALPHA4 0x803B
#define GL_ALPHA8 0x803C
#define GL_ALPHA12 0x803D
#define GL_ALPHA16 0x803E
#define GL_LUMINANCE4 0x803F
#define GL_LUMINANCE8 0x8040
#define GL_LUMINANCE12 0x8041
#define GL_LUMINANCE16 0x8042
#define GL_LUMINANCE4_ALPHA4 0x8043
#define GL_LUMINANCE6_ALPHA2 0x8044
#define GL_LUMINANCE8_ALPHA8 0x8045
#define GL_LUMINANCE12_ALPHA4 0x8046
#define GL_LUMINANCE12_ALPHA12 0x8047
#define GL_LUMINANCE16_ALPHA16 0x8048
#define GL_INTENSITY 0x8049
#define GL_INTENSITY4 0x804A
#define GL_INTENSITY8 0x804B
#define GL_INTENSITY12 0x804C
#define GL_INTENSITY16 0x804D
#define GL_R3_G3_B2 0x2A10
#define GL_RGB4 0x804F
#define GL_RGB5 0x8050
#define GL_RGB8 0x8051
#define GL_RGB10 0x8052
#define GL_RGB12 0x8053
#define GL_RGB16 0x8054
#define GL_RGBA2 0x8055
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGBA8 0x8058
#define GL_RGB10_A2 0x8059
#define GL_RGBA12 0x805A
#define GL_RGBA16 0x805B
/* Utility */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* Errors */
#define GL_NO_ERROR 0x0
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_OPERATION 0x0502
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#define GL_OUT_OF_MEMORY 0x0505
/* OpenGL 1.2 */
#define GL_RESCALE_NORMAL 0x803A
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
#define GL_MAX_ELEMENTS_INDICES 0x80E9
#define GL_BGR 0x80E0
#define GL_BGRA 0x80E1
#define GL_UNSIGNED_BYTE_3_3_2 0x8032
#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
#define GL_UNSIGNED_INT_8_8_8_8 0x8035
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
#define GL_UNSIGNED_INT_10_10_10_2 0x8036
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
#define GL_SINGLE_COLOR 0x81F9
#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
#define GL_TEXTURE_MIN_LOD 0x813A
#define GL_TEXTURE_MAX_LOD 0x813B
#define GL_TEXTURE_BASE_LEVEL 0x813C
#define GL_TEXTURE_MAX_LEVEL 0x813D
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
/*
* OpenGL 1.2 imaging subset (NOT IMPLEMENTED BY MESA)
*/
/* GL_EXT_color_table */
#define GL_COLOR_TABLE 0x80D0
#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
#define GL_PROXY_COLOR_TABLE 0x80D3
#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
#define GL_COLOR_TABLE_SCALE 0x80D6
#define GL_COLOR_TABLE_BIAS 0x80D7
#define GL_COLOR_TABLE_FORMAT 0x80D8
#define GL_COLOR_TABLE_WIDTH 0x80D9
#define GL_COLOR_TABLE_RED_SIZE 0x80DA
#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
/* GL_EXT_convolution and GL_HP_convolution_border_modes */
#define GL_CONVOLUTION_1D 0x8010
#define GL_CONVOLUTION_2D 0x8011
#define GL_SEPARABLE_2D 0x8012
#define GL_CONVOLUTION_BORDER_MODE 0x8013
#define GL_CONVOLUTION_FILTER_SCALE 0x8014
#define GL_CONVOLUTION_FILTER_BIAS 0x8015
#define GL_REDUCE 0x8016
#define GL_CONVOLUTION_FORMAT 0x8017
#define GL_CONVOLUTION_WIDTH 0x8018
#define GL_CONVOLUTION_HEIGHT 0x8019
#define GL_MAX_CONVOLUTION_WIDTH 0x801A
#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
#define GL_CONSTANT_BORDER 0x8151
#define GL_REPLICATE_BORDER 0x8153
#define GL_CONVOLUTION_BORDER_COLOR 0x8154
/* GL_SGI_color_matrix */
#define GL_COLOR_MATRIX 0x80B1
#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
/* GL_EXT_histogram */
#define GL_HISTOGRAM 0x8024
#define GL_PROXY_HISTOGRAM 0x8025
#define GL_HISTOGRAM_WIDTH 0x8026
#define GL_HISTOGRAM_FORMAT 0x8027
#define GL_HISTOGRAM_RED_SIZE 0x8028
#define GL_HISTOGRAM_GREEN_SIZE 0x8029
#define GL_HISTOGRAM_BLUE_SIZE 0x802A
#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
#define GL_HISTOGRAM_SINK 0x802D
#define GL_MINMAX 0x802E
#define GL_MINMAX_FORMAT 0x802F
#define GL_MINMAX_SINK 0x8030
#define GL_TABLE_TOO_LARGE 0x8031
/* GL_EXT_blend_color, GL_EXT_blend_minmax */
#define GL_BLEND_EQUATION 0x8009
#define GL_MIN 0x8007
#define GL_MAX 0x8008
#define GL_FUNC_ADD 0x8006
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
#define GL_BLEND_COLOR 0x8005
/* glPush/PopAttrib bits */
#define GL_CURRENT_BIT 0x00000001
#define GL_POINT_BIT 0x00000002
#define GL_LINE_BIT 0x00000004
#define GL_POLYGON_BIT 0x00000008
#define GL_POLYGON_STIPPLE_BIT 0x00000010
#define GL_PIXEL_MODE_BIT 0x00000020
#define GL_LIGHTING_BIT 0x00000040
#define GL_FOG_BIT 0x00000080
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_ACCUM_BUFFER_BIT 0x00000200
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_VIEWPORT_BIT 0x00000800
#define GL_TRANSFORM_BIT 0x00001000
#define GL_ENABLE_BIT 0x00002000
#define GL_COLOR_BUFFER_BIT 0x00004000
#define GL_HINT_BIT 0x00008000
#define GL_EVAL_BIT 0x00010000
#define GL_LIST_BIT 0x00020000
#define GL_TEXTURE_BIT 0x00040000
#define GL_SCISSOR_BIT 0x00080000
#define GL_ALL_ATTRIB_BITS 0x000FFFFF
#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF
/*
* GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
*/
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
#define GL_TEXTURE2_ARB 0x84C2
#define GL_TEXTURE3_ARB 0x84C3
#define GL_TEXTURE4_ARB 0x84C4
#define GL_TEXTURE5_ARB 0x84C5
#define GL_TEXTURE6_ARB 0x84C6
#define GL_TEXTURE7_ARB 0x84C7
#define GL_TEXTURE8_ARB 0x84C8
#define GL_TEXTURE9_ARB 0x84C9
#define GL_TEXTURE10_ARB 0x84CA
#define GL_TEXTURE11_ARB 0x84CB
#define GL_TEXTURE12_ARB 0x84CC
#define GL_TEXTURE13_ARB 0x84CD
#define GL_TEXTURE14_ARB 0x84CE
#define GL_TEXTURE15_ARB 0x84CF
#define GL_TEXTURE16_ARB 0x84D0
#define GL_TEXTURE17_ARB 0x84D1
#define GL_TEXTURE18_ARB 0x84D2
#define GL_TEXTURE19_ARB 0x84D3
#define GL_TEXTURE20_ARB 0x84D4
#define GL_TEXTURE21_ARB 0x84D5
#define GL_TEXTURE22_ARB 0x84D6
#define GL_TEXTURE23_ARB 0x84D7
#define GL_TEXTURE24_ARB 0x84D8
#define GL_TEXTURE25_ARB 0x84D9
#define GL_TEXTURE26_ARB 0x84DA
#define GL_TEXTURE27_ARB 0x84DB
#define GL_TEXTURE28_ARB 0x84DC
#define GL_TEXTURE29_ARB 0x84DD
#define GL_TEXTURE30_ARB 0x84DE
#define GL_TEXTURE31_ARB 0x84DF
#define GL_ACTIVE_TEXTURE_ARB 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
#endif // #ifndef _X86UNIX_GL_TYPES_H_

View file

@ -0,0 +1,14 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// GLU functions
//------------------------------------------------------------------------------
GL_FUNCTION(int, gluProject, (GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz), return 0; )
GL_FUNCTION(int, gluUnProject, (GLdouble winx, GLdouble winy, GLdouble winz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *objx, GLdouble *objy, GLdouble *objz), return 0; )

View file

@ -0,0 +1,147 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _PLATFORMAL_H_
#define _PLATFORMAL_H_
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#define AL_NO_PROTOTYPES
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>
// extra enums for win32/miles implementation
enum {
// error values
AL_CONTEXT_ALREADY_INSTANTIATED = 0xbaadf00d,
AL_ENVIRONMENT_ALREADY_INSTANTIATED,
AL_UNSUPPORTED,
AL_INVALID_BUFFER,
AL_ERROR,
// context extention
ALC_PROVIDER,
ALC_PROVIDER_COUNT,
ALC_PROVIDER_NAME,
ALC_SPEAKER,
ALC_SPEAKER_COUNT,
ALC_SPEAKER_NAME,
ALC_BUFFER_DYNAMIC_MEMORY_SIZE,
ALC_BUFFER_DYNAMIC_MEMORY_USAGE,
ALC_BUFFER_DYNAMIC_COUNT,
ALC_BUFFER_MEMORY_USAGE,
ALC_BUFFER_COUNT,
ALC_BUFFER_LATENCY,
// misc 3d params
AL_MIN_DISTANCE,
AL_MAX_DISTANCE,
AL_CONE_OUTER_GAIN,
// relative with pos(0,0,0) won't work for ambient sounds with miles
AL_SOURCE_AMBIENT,
AL_PAN,
// other extensions
AL_BUFFER_KEEP_RESIDENT,
AL_FORMAT_WAVE_EXT,
// Environment extensions:
AL_ENV_EFFECT_VOLUME_EXT,
AL_ENV_FLAGS_EXT,
AL_ENV_DAMPING_EXT,
AL_ENV_ENVIRONMENT_SIZE_EXT,
AL_ENV_ROOM_VOLUME_EXT,
};
enum {
// sample level environment:
AL_ENV_SAMPLE_REVERB_MIX_EXT = 0,
AL_ENV_SAMPLE_DIRECT_EXT,
AL_ENV_SAMPLE_DIRECT_HF_EXT,
AL_ENV_SAMPLE_ROOM_EXT,
AL_ENV_SAMPLE_ROOM_HF_EXT,
AL_ENV_SAMPLE_OBSTRUCTION_EXT,
AL_ENV_SAMPLE_OBSTRUCTION_LF_RATIO_EXT,
AL_ENV_SAMPLE_OCCLUSION_EXT,
AL_ENV_SAMPLE_OCCLUSION_LF_RATIO_EXT,
AL_ENV_SAMPLE_OCCLUSION_ROOM_RATIO_EXT,
AL_ENV_SAMPLE_ROOM_ROLLOFF_EXT,
AL_ENV_SAMPLE_AIR_ABSORPTION_EXT,
AL_ENV_SAMPLE_OUTSIDE_VOLUME_HF_EXT,
AL_ENV_SAMPLE_FLAGS_EXT,
AL_ENV_SAMPLE_COUNT,
};
// room types: same as miles/eax
enum {
AL_ENVIRONMENT_GENERIC = 0,
AL_ENVIRONMENT_PADDEDCELL,
AL_ENVIRONMENT_ROOM,
AL_ENVIRONMENT_BATHROOM,
AL_ENVIRONMENT_LIVINGROOM,
AL_ENVIRONMENT_STONEROOM,
AL_ENVIRONMENT_AUDITORIUM,
AL_ENVIRONMENT_CONCERTHALL,
AL_ENVIRONMENT_CAVE,
AL_ENVIRONMENT_ARENA,
AL_ENVIRONMENT_HANGAR,
AL_ENVIRONMENT_CARPETEDHALLWAY,
AL_ENVIRONMENT_HALLWAY,
AL_ENVIRONMENT_STONECORRIDOR,
AL_ENVIRONMENT_ALLEY,
AL_ENVIRONMENT_FOREST,
AL_ENVIRONMENT_CITY,
AL_ENVIRONMENT_MOUNTAINS,
AL_ENVIRONMENT_QUARRY,
AL_ENVIRONMENT_PLAIN,
AL_ENVIRONMENT_PARKINGLOT,
AL_ENVIRONMENT_SEWERPIPE,
AL_ENVIRONMENT_UNDERWATER,
AL_ENVIRONMENT_DRUGGED,
AL_ENVIRONMENT_DIZZY,
AL_ENVIRONMENT_PSYCHOTIC,
AL_ENVIRONMENT_COUNT
};
// declare OpenAL functions
#define AL_EXTENSION(ext_name) extern bool gDoesSupport_##ext_name;
#define AL_FUNCTION(fn_return,fn_name,fn_args) extern fn_return (FN_CDECL *fn_name)fn_args;
#define AL_EXT_FUNCTION(ext_name,fn_return,fn_name,fn_args) extern fn_return (FN_CDECL *fn_name)fn_args;
#ifndef _OPENALFN_H_
#include <openALFn.h>
#endif
namespace Audio
{
bool libraryInit(const char *library);
void libraryInitExtensions();
void libraryShutdown();
inline bool doesSupportIASIG()
{
return gDoesSupport_AL_EXT_IASIG;
}
inline bool doesSupportDynamix()
{
return gDoesSupport_AL_EXT_DYNAMIX;
}
// helpers
F32 DBToLinear(F32 value);
F32 linearToDB(F32 value);
} // end namespace Audio
#endif // _H_PLATFORMAL_

2552
platformX86UNIX/platformGL.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,84 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _PLATFORMX86UNIX_H_
#define _PLATFORMX86UNIX_H_
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#include <stdio.h>
#include <string.h>
/* files needed for X11 */
//#include <X11/Xlib.h>
//#include <X11/Xutil.h>
//#include <X11/Xos.h>
//#include <X11/Xatom.h>
//#include <GL/glx.h>
class x86UNIXPlatformState
{
public:
S32 desktopBitsPixel;
S32 desktopWidth;
S32 desktopHeight;
S32 width;
S32 height;
S32 bpp;
bool videoInitted;
U32 currentTime;
struct __GLXcontextRec *ctx;
// GLXContext ctx;
/* X11 specific */
// Display *display;
// int screen_num;
// Window win;
// Screen *screen_ptr;
x86UNIXPlatformState( ) {
width = 0;
height = 0;
bpp = 0;
videoInitted = false;
currentTime = 0;
}
};
extern x86UNIXPlatformState x86UNIXState;
extern bool QGL_Init( const char* glName, const char* gluName );
extern bool QGL_EXT_Init( void );
extern void QGL_Shutdown( void );
extern void GetDesktopState( void );
extern char* dStrncat( char* d, const char* s, size_t n );
extern void x86UNIXInitTicks( void );
#ifdef DEDICATED
extern void x86UNIXPostQuitMessage( void );
#endif
extern void createFontInit( void );
extern void createFontShutdown( void );
extern void installRedBookDevices( void );
extern void PlatformBlitInit( void );
extern U8 getHatState( U8 hat );
extern void setHatState( U8 hat, U8 state );
#endif

View file

@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "terrain/terrData.h"
#include "math/mMath.h"
#include "dgl/dgl.h"
#include "dgl/gBitmap.h"
#include "terrain/terrRender.h"
//--------------------------------------------------------------------------
void bitmapExtrude5551_asm(const void *srcMip, void *mip, U32 height, U32 width)
{
const U16 *src = (const U16 *) srcMip;
U16 *dst = (U16 *) mip;
U32 stride = width << 1;
for(U32 y = 0; y < height; y++)
{
for(U32 x = 0; x < width; x++)
{
U32 a = src[0];
U32 b = src[1];
U32 c = src[stride];
U32 d = src[stride+1];
dst[x] = ((((a >> 11) + (b >> 11) + (c >> 11) + (d >> 11)) >> 2) << 11) |
((( ((a >> 6) & 0x1f) + ((b >> 6) & 0x1f) + ((c >> 6) & 0x1f) + ((d >> 6) & 0x1F) ) >> 2) << 6) |
((( ((a >> 1) & 0x1F) + ((b >> 1) & 0x1F) + ((c >> 1) & 0x1f) + ((d >> 1) & 0x1f)) >> 2) << 1);
src += 2;
}
src += stride;
dst += width;
}
}
//--------------------------------------------------------------------------
void PlatformBlitInit()
{
bitmapExtrude5551 = bitmapExtrude5551_asm;
bitmapExtrudeRGB = bitmapExtrudeRGB_c;
if (Platform::SystemInfo.processor.properties & CPU_PROP_MMX)
{
}
// terrMipBlit = terrMipBlit_asm;
}

View file

@ -0,0 +1,94 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include "console/console.h"
#include "core/stringTable.h"
#include <math.h>
Platform::SystemInfo_struct Platform::SystemInfo;
extern void PlatformBlitInit();
/* used in the asm */
U32 time[2];
U32 clockticks = 0;
void Processor::init()
{
// Reference:
// www.cyrix.com
// www.amd.com
// www.intel.com
// http://developer.intel.com/design/PentiumII/manuals/24512701.pdf
Platform::SystemInfo.processor.type = CPU_X86Compatible;
Platform::SystemInfo.processor.name = StringTable->insert("Unknown x86 Compatible");
Platform::SystemInfo.processor.mhz = 0;
Platform::SystemInfo.processor.properties = CPU_PROP_C;
//--------------------------------------
// calculate the aproximate Mhz of the CPU
const U32 MS_INTERVAL = 750;
__asm__("
pushl %eax
pushl %edx
//db 0fh, 31h
rdtsc
movl %eax, (time)
movl %edx, (time+4)
popl %edx
popl %eax
");
U32 ms = Platform::getRealMilliseconds();
while ( Platform::getRealMilliseconds() < ms+MS_INTERVAL )
{ /* empty */ }
ms = Platform::getRealMilliseconds()-ms;
asm("
pushl %eax
pushl %edx
//db 0fh, 31h
rdtsc
sub (time+4), %edx
sbb (time), %eax
mov %eax, (clockticks)
popl %edx
popl %eax
");
U32 mhz = F32(clockticks) / F32(ms) / 1000.0f;
// catch-22 the timing method used above to calc Mhz is generally
// wrong by a few percent so we want to round to the nearest clock
// multiple but we also want to be careful to not touch overclocked results
// measure how close the Raw Mhz number is to the center of each clock bucket
U32 bucket25 = mhz % 25;
U32 bucket33 = mhz % 33;
U32 bucket50 = mhz % 50;
if (bucket50 < 8 || bucket50 > 42)
Platform::SystemInfo.processor.mhz = U32((mhz+(50.0f/2.0f))/50.0f) * 50;
else if (bucket25 < 5 || bucket25 > 20)
Platform::SystemInfo.processor.mhz = U32((mhz+(25.0f/2.0f))/25.0f) * 25;
else if (bucket33 < 5 || bucket33 > 28)
Platform::SystemInfo.processor.mhz = U32((mhz+(33.0f/2.0f))/33.0f) * 33;
else
Platform::SystemInfo.processor.mhz = U32(mhz);
Con::printf("Processor Init:");
Con::printf(" %s, %d Mhz", Platform::SystemInfo.processor.name, Platform::SystemInfo.processor.mhz);
if (Platform::SystemInfo.processor.properties & CPU_PROP_FPU)
Con::printf(" FPU detected");
if (Platform::SystemInfo.processor.properties & CPU_PROP_MMX)
Con::printf(" MMX detected");
if (Platform::SystemInfo.processor.properties & CPU_PROP_3DNOW)
Con::printf(" 3DNow detected");
if (Platform::SystemInfo.processor.properties & CPU_PROP_SSE)
Con::printf(" SSE detected");
Con::printf(" ");
PlatformBlitInit();
}

View file

@ -0,0 +1,257 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platformX86UNIX/x86UNIXStdConsole.h"
#include "platform/event.h"
#include "platform/gameInterface.h"
#include <unistd.h>
#include <stdarg.h>
#include <termios.h>
#include <ctype.h>
#include <fcntl.h>
StdConsole *stdConsole = NULL;
ConsoleFunction(enableWinConsole, void, 2, 2, "enableWinConsole(bool);")
{
argc;
stdConsole->enable(dAtob(argv[1]));
}
void StdConsole::create()
{
stdConsole = new StdConsole();
}
void StdConsole::destroy()
{
delete stdConsole;
stdConsole = NULL;
}
void StdConsole::enable(bool enabled)
{
stdConsoleEnabled = enabled;
if (stdConsoleEnabled)
{
stdOut = dup(1);
stdIn = dup(0);
stdErr = dup(2);
/* setup the proper terminal modes */
struct termios termModes;
tcgetattr(fileno(stdin), &termModes);
termModes.c_lflag &= ~ICANON; // enable non-canonical mode
termModes.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHOKE);
termModes.c_cc[VMIN] = 0;
termModes.c_cc[VTIME] = 5;
tcsetattr(stdIn, TCSAFLUSH, &termModes);
/* turn on non-blocking mode so that if no data is available at read(), then it returns */
fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
printf("%s", Con::getVariable("Con::Prompt"));
}
}
bool StdConsole::isEnabled()
{
if ( stdConsole )
return stdConsole->stdConsoleEnabled;
return false;
}
static void stdConsoleConsumer(ConsoleLogEntry::Level, const char *line)
{
stdConsole->processConsoleLine(line);
}
StdConsole::StdConsole()
{
for (S32 iIndex = 0; iIndex < MAX_CMDS; iIndex ++)
rgCmds[iIndex][0] = '\0';
iCmdIndex = 0;
stdConsoleEnabled = false;
Con::addConsumer(stdConsoleConsumer);
inpos = 0;
lineOutput = false;
}
void StdConsole::printf(const char *s, ...)
{
static char buffer[512];
long bytes;
va_list args;
va_start(args, s);
vsprintf(buffer, s, args);
write(stdOut, buffer, strlen(buffer));
fflush(stdout);
}
void StdConsole::processConsoleLine(const char *consoleLine)
{
if(stdConsoleEnabled)
{
inbuf[inpos] = 0;
if(lineOutput)
printf("%s\n", consoleLine);
else
printf("%c%s\n%s%s", '\r', consoleLine, Con::getVariable("Con::Prompt"), inbuf);
}
}
void StdConsole::process()
{
if(stdConsoleEnabled)
{
U16 key;
char typedData[64]; // damn, if you can type this fast... :-D
int numEvents = read(stdIn, typedData, 64);
if (numEvents == -1) return;
typedData[numEvents] = '\0';
//if (typedData[0] == 27) {
// fprintf(stdout, "1 = %c, 2 = %c\n", typedData[1], typedData[2]);
//}
// fprintf(stdout, "read %d elements\n",numEvents);fflush(NULL);
//
// int numEvents = read(stdIn, &key, sizeof(char));
if (numEvents > 0)
{
char outbuf[256];
S32 outpos = 0;
for (int i = 0; i < numEvents; i++)
{
switch(typedData[i])
{
case 8:
case 127:
/* backspace */
if (inpos > 0)
{
outbuf[outpos++] = '\b';
outbuf[outpos++] = ' ';
outbuf[outpos++] = '\b';
inpos--;
}
break;
case '\n':
/* new line */
outbuf[outpos++] = '\n';
inbuf[inpos] = 0;
outbuf[outpos] = 0;
printf("%s", outbuf);
S32 eventSize;
eventSize = 1;
dStrcpy(postEvent.data, inbuf);
postEvent.size = eventSize + dStrlen(inbuf) + 1;
Game->postEvent(postEvent);
// If we've gone off the end of our array, wrap
// back to the beginning
if (iCmdIndex >= MAX_CMDS)
iCmdIndex %= MAX_CMDS;
// Put the new command into the array
strcpy(rgCmds[iCmdIndex ++], inbuf);
printf("%s", Con::getVariable("Con::Prompt"));
inpos = outpos = 0;
break;
case 27:
if (typedData[++i] == 91) {
// an arrow key was pressed.
switch(typedData[++i])
{
case 'A':
/* up arrow */
// Go to the previous command in the cyclic array
if ((-- iCmdIndex) < 0)
iCmdIndex = MAX_CMDS - 1;
// If this command isn't empty ...
if (rgCmds[iCmdIndex][0] != '\0')
{
// Obliterate current displayed text
for (S32 i = outpos = 0; i < inpos; i ++)
{
outbuf[outpos++] = '\b';
outbuf[outpos++] = ' ';
outbuf[outpos++] = '\b';
}
// Copy command into command and display buffers
for (inpos = 0; inpos < (S32)strlen(rgCmds[iCmdIndex]); inpos++, outpos++)
{
outbuf[outpos] = rgCmds[iCmdIndex][inpos];
inbuf [inpos ] = rgCmds[iCmdIndex][inpos];
}
}
// If previous is empty, stay on current command
else if ((++ iCmdIndex) >= MAX_CMDS)
{
iCmdIndex = 0;
}
break;
case 'B':
/* down arrow */
// Go to the next command in the command array, if
// it isn't empty
if (rgCmds[iCmdIndex][0] != '\0' && (++ iCmdIndex) >= MAX_CMDS)
iCmdIndex = 0;
// Obliterate current displayed text
for (S32 i = outpos = 0; i < inpos; i ++)
{
outbuf[outpos++] = '\b';
outbuf[outpos++] = ' ';
outbuf[outpos++] = '\b';
}
// Copy command into command and display buffers
for (inpos = 0; inpos < (S32)strlen(rgCmds[iCmdIndex]); inpos++, outpos++)
{
outbuf[outpos] = rgCmds[iCmdIndex][inpos];
inbuf [inpos ] = rgCmds[iCmdIndex][inpos];
}
break;
case 'C':
/* right arrow */
break;
case 'D':
/* left arrow */
break;
}
// read again to get rid of a bad char.
//read(stdIn, &key, sizeof(char));
break;
} else {
inbuf[inpos++] = typedData[i];
outbuf[outpos++] = typedData[i];
break;
}
break;
default:
inbuf[inpos++] = typedData[i];
outbuf[outpos++] = typedData[i];
break;
}
if (outpos)
{
outbuf[outpos] = 0;
printf("%s", outbuf);
}
}
}
}
}

View file

@ -0,0 +1,95 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
// $Id: x86UNIXDedicatedStub.cc,v 1.1 2002/03/16 19:43:09 jmquigs Exp $
// GL stubs
#ifndef NULL
#define NULL 0
#endif
#include "platformX86UNIX/platformGL.h"
#include "platform/platformAL.h"
#include "platform/platformInput.h"
// declare stub functions
#define GL_FUNCTION(fn_return, fn_name, fn_args, fn_value) fn_return stub_##fn_name fn_args{ fn_value }
#include "platformX86UNIX/gl_func.h"
#include "platformX86UNIX/glu_func.h"
#undef GL_FUNCTION
// point gl function pointers at stub functions
#define GL_FUNCTION(fn_return,fn_name,fn_args, fn_value) fn_return (*fn_name)fn_args = stub_##fn_name;
#include "platformX86UNIX/gl_func.h"
#include "platformX86UNIX/glu_func.h"
#undef GL_FUNCTION
GLState gGLState;
bool gOpenGLDisablePT = false;
bool gOpenGLDisableCVA = false;
bool gOpenGLDisableTEC = false;
bool gOpenGLDisableARBMT = false;
bool gOpenGLDisableFC = false;
bool gOpenGLDisableTCompress = false;
bool gOpenGLNoEnvColor = false;
float gOpenGLGammaCorrection = 0.5;
bool gOpenGLNoDrawArraysAlpha = false;
// AL stubs
//#include <al/altypes.h>
///#include <al/alctypes.h>
//#define INITGUID
//#include <al/eaxtypes.h>
// Define the OpenAL and Extension Stub functions
#define AL_FUNCTION(fn_return, fn_name, fn_args, fn_value) fn_return stub_##fn_name fn_args{ fn_value }
#include <al/al_func.h>
#include <al/alc_func.h>
#include <al/eax_func.h>
#undef AL_FUNCTION
// Declare the OpenAL and Extension Function pointers
// And initialize them to the stub functions
#define AL_FUNCTION(fn_return,fn_name,fn_args, fn_value) fn_return (*fn_name)fn_args = stub_##fn_name;
#include <al/al_func.h>
#include <al/alc_func.h>
#include <al/eax_func.h>
#undef AL_FUNCTION
namespace Audio
{
bool OpenALDLLInit() { return false; }
void OpenALDLLShutdown() {}
}
// Platform Stubs
const char* Platform::getClipboard() { return ""; }
bool Platform::setClipboard(const char *text) { return false; }
GFont *createFont(const char *name, S32 size) { return NULL; }
void PlatformBlitInit( void ) {}
// #include <X11/Xlib.h>
// void NotifySelectionEvent(XEvent& event)
// {
// }
// Input stubs
void Input::init() {}
void Input::destroy() {}
bool Input::enable() { return false; }
void Input::disable() {}
void Input::activate() {}
void Input::deactivate() {}
void Input::reactivate() {}
U16 Input::getAscii( U16 keyCode, KEY_STATE keyState ) { return 0; }
U16 Input::getKeyCode( U16 asciiCode ) { return 0; }
bool Input::isEnabled() { return false; }
bool Input::isActive() { return false; }
void Input::process() {}
InputManager* Input::getManager() { return NULL; }

View file

@ -0,0 +1,785 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "core/fileio.h"
#include "core/tVector.h"
#include "core/stringTable.h"
#include "console/console.h"
#include <utime.h>
/* include sys/param.h for MAXPATHLEN */
#include <sys/param.h>
#ifndef MAX_PATH
#define MAX_PATH MAXPATHLEN
#endif
/* these are for reading directors, getting stats, etc. */
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
extern int x86UNIXOpen(const char *path, int oflag);
extern int x86UNIXClose(int fd);
extern ssize_t x86UNIXRead(int fd, void *buf, size_t nbytes);
extern ssize_t x86UNIXWrite(int fd, const void *buf, size_t nbytes);
//-------------------------------------- Helper Functions
static void forwardslash(char *str)
{
while(*str)
{
if(*str == '\\')
*str = '/';
str++;
}
}
static void backslash(char *str)
{
while(*str)
{
if(*str == '/')
*str = '\\';
str++;
}
}
//-----------------------------------------------------------------------------
bool dFileDelete(const char * name)
{
if(!name || (dStrlen(name) >= MAX_PATH))
return(false);
if (remove(name) == -1)
return(false);
return(true);
}
bool dFileTouch(const char * name)
{
// change the modified time to the current time (0byte WriteFile fails!)
return(utime(name, 0) != -1);
}
//-----------------------------------------------------------------------------
// Constructors & Destructor
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// After construction, the currentStatus will be Closed and the capabilities
// will be 0.
//-----------------------------------------------------------------------------
File::File()
: currentStatus(Closed), capability(0)
{
// AssertFatal(sizeof(int) == sizeof(void *), "File::File: cannot cast void* to int");
handle = (void *)NULL;
}
//-----------------------------------------------------------------------------
// insert a copy constructor here... (currently disabled)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Destructor
//-----------------------------------------------------------------------------
File::~File()
{
close();
handle = (void *)NULL;
}
//-----------------------------------------------------------------------------
// Open a file in the mode specified by openMode (Read, Write, or ReadWrite).
// Truncate the file if the mode is either Write or ReadWrite and truncate is
// true.
//
// Sets capability appropriate to the openMode.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::open(const char *filename, const AccessMode openMode)
{
static char filebuf[2048];
dStrcpy(filebuf, filename);
filename = filebuf;
AssertFatal(NULL != filename, "File::open: NULL filename");
AssertWarn(NULL == handle, "File::open: handle already valid");
// Close the file if it was already open...
if (Closed != currentStatus)
close();
int fd;
handle = (void *)dRealMalloc(sizeof(int));
// create the appropriate type of file...
switch (openMode)
{
case Read:
fd = x86UNIXOpen(filename, O_RDONLY);
dMemcpy(handle, &fd, sizeof(int));
// handle = (void *)&x86UNIXOpen(filename, O_RDONLY);
break;
case Write:
fd = x86UNIXOpen(filename, O_WRONLY | O_CREAT);
dMemcpy(handle, &fd, sizeof(int));
// handle = (void *)x86UNIXOpen(filename, O_WRONLY | O_CREAT);
break;
case ReadWrite:
fd = x86UNIXOpen(filename, O_RDWR);
dMemcpy(handle, &fd, sizeof(int));
// handle = (void *)x86UNIXOpen(filename, O_RDWR);
break;
case WriteAppend:
fd = x86UNIXOpen(filename, O_APPEND);
dMemcpy(handle, &fd, sizeof(int));
// handle = (void *)x86UNIXOpen(filename, O_APPEND);
break;
default:
AssertFatal(false, "File::open: bad access mode"); // impossible
}
#ifdef DEBUG
// fprintf(stdout,"fd = %d, handle = %d\n", fd, *((int *)handle));
#endif
if (*((int *)handle) == -1) // handle not created successfully
return setStatus();
else
{
// successfully created file, so set the file capabilities...
switch (openMode)
{
case Read:
capability = U32(FileRead);
break;
case Write:
case WriteAppend:
capability = U32(FileWrite);
break;
case ReadWrite:
capability = U32(FileRead) |
U32(FileWrite);
break;
default:
AssertFatal(false, "File::open: bad access mode");
}
return currentStatus = Ok; // success!
}
}
//-----------------------------------------------------------------------------
// Get the current position of the file pointer.
//-----------------------------------------------------------------------------
U32 File::getPosition() const
{
AssertFatal(Closed != currentStatus, "File::getPosition: file closed");
AssertFatal(NULL != handle, "File::getPosition: invalid file handle");
#ifdef DEBUG
// fprintf(stdout, "handle = %d\n",*((int *)handle));fflush(stdout);
#endif
return (U32) lseek(*((int *)handle), 0, SEEK_CUR);
}
//-----------------------------------------------------------------------------
// Set the position of the file pointer.
// Absolute and relative positioning is supported via the absolutePos
// parameter.
//
// If positioning absolutely, position MUST be positive - an IOError results if
// position is negative.
// Position can be negative if positioning relatively, however positioning
// before the start of the file is an IOError.
//
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::setPosition(S32 position, bool absolutePos)
{
AssertFatal(Closed != currentStatus, "File::setPosition: file closed");
AssertFatal(NULL != handle, "File::setPosition: invalid file handle");
if (Ok != currentStatus && EOS != currentStatus)
return currentStatus;
U32 finalPos;
switch (absolutePos)
{
case true: // absolute position
AssertFatal(0 <= position, "File::setPosition: negative absolute position");
// position beyond EOS is OK
finalPos = lseek(*((int *)handle), position, SEEK_SET);
break;
case false: // relative position
AssertFatal((getPosition() >= (U32)abs(position) && 0 > position) || 0 <= position, "File::setPosition: negative relative position");
// position beyond EOS is OK
finalPos = lseek(*((int *)handle), position, SEEK_CUR);
break;
}
if (0xffffffff == finalPos)
return setStatus(); // unsuccessful
else if (finalPos >= getSize())
return currentStatus = EOS; // success, at end of file
else
return currentStatus = Ok; // success!
}
//-----------------------------------------------------------------------------
// Get the size of the file in bytes.
// It is an error to query the file size for a Closed file, or for one with an
// error status.
//-----------------------------------------------------------------------------
U32 File::getSize() const
{
AssertWarn(Closed != currentStatus, "File::getSize: file closed");
AssertFatal(NULL != handle, "File::getSize: invalid file handle");
if (Ok == currentStatus || EOS == currentStatus)
{
long currentOffset = getPosition(); // keep track of our current position
long fileSize;
lseek(*((int *)handle), 0, SEEK_END); // seek to the end of the file
fileSize = getPosition(); // get the file size
lseek(*((int *)handle), currentOffset, SEEK_SET); // seek back to our old offset
return fileSize; // success!
}
else
return 0; // unsuccessful
}
//-----------------------------------------------------------------------------
// Flush the file.
// It is an error to flush a read-only file.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::flush()
{
AssertFatal(Closed != currentStatus, "File::flush: file closed");
AssertFatal(NULL != handle, "File::flush: invalid file handle");
AssertFatal(true == hasCapability(FileWrite), "File::flush: cannot flush a read-only file");
if (fdatasync(*((int *)handle)) == 0)
return currentStatus = Ok; // success!
else
return setStatus(); // unsuccessful
}
//-----------------------------------------------------------------------------
// Close the File.
//
// Returns the currentStatus
//-----------------------------------------------------------------------------
File::Status File::close()
{
// check if it's already closed...
if (Closed == currentStatus)
return currentStatus;
// it's not, so close it...
if (NULL != handle)
{
if (x86UNIXClose(*((int *)handle)) != 0)
return setStatus(); // unsuccessful
}
handle = (void *)NULL;
return currentStatus = Closed;
}
//-----------------------------------------------------------------------------
// Self-explanatory.
//-----------------------------------------------------------------------------
File::Status File::getStatus() const
{
return currentStatus;
}
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus when an error has been encountered.
//-----------------------------------------------------------------------------
File::Status File::setStatus()
{
switch (errno)
{
case EINVAL:
case EBADFD:
case EIO:
return currentStatus = IOError;
default:
return currentStatus = Ok;
}
}
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus to status.
//-----------------------------------------------------------------------------
File::Status File::setStatus(File::Status status)
{
return currentStatus = status;
}
//-----------------------------------------------------------------------------
// Read from a file.
// The number of bytes to read is passed in size, the data is returned in src.
// The number of bytes read is available in bytesRead if a non-Null pointer is
// provided.
//-----------------------------------------------------------------------------
File::Status File::read(U32 size, char *dst, U32 *bytesRead)
{
#ifdef DEBUG
// fprintf(stdout,"reading %d bytes\n",size);fflush(stdout);
#endif
AssertFatal(Closed != currentStatus, "File::read: file closed");
AssertFatal(NULL != handle, "File::read: invalid file handle");
AssertFatal(NULL != dst, "File::read: NULL destination pointer");
AssertFatal(true == hasCapability(FileRead), "File::read: file lacks capability");
AssertWarn(0 != size, "File::read: size of zero");
/* show stats for this file */
#ifdef DEBUG
//struct stat st;
//fstat(*((int *)handle), &st);
//fprintf(stdout,"file size = %d\n", st.st_size);
#endif
/****************************/
if (Ok != currentStatus || 0 == size)
return currentStatus;
else
{
long lastBytes;
long *bytes = (NULL == bytesRead) ? &lastBytes : (long *)bytesRead;
//if ((FILE *)handle == NULL || dst == NULL) {
//fprintf(stdout, "ack!\n");
//}
//fprintf(stdout, "%d-%p\n",strlen(dst),dst);
//fprintf(stdout, "feof() = %d\n",feof((FILE *)handle));
//fprintf(stdout, "sizeof(U32) = %d\nsize = %d\n",sizeof(U32), size);
//fprintf(stdout, "bytesRead = %d\n", *((U32 *)bytes) = x86UNIXRead(fileno((FILE *)handle), dst, size) );
// (*((U32 *)bytes)) = fread(dst, sizeof(U32), size, (FILE *)handle);
//fprintf(stdout, "bytes = %d\n", (*(int *)bytes));fflush(NULL);
//exit(*((int *)bytes));
// if (0 != (*((size_t *)bytes) = fread(dst, sizeof(U32), size, (FILE *)handle)) )
if ( (*((U32 *)bytes) = x86UNIXRead(*((int *)handle), dst, size)) == -1)
{
#ifdef DEBUG
// fprintf(stdout,"unsuccessful: %d\n", *((U32 *)bytes));fflush(stdout);
#endif
return setStatus(); // unsuccessful
} else {
// dst[*((U32 *)bytes)] = '\0';
if (*((U32 *)bytes) != size || *((U32 *)bytes) == 0) {
#ifdef DEBUG
// fprintf(stdout,"end of stream: %d\n", *((U32 *)bytes));fflush(stdout);
#endif
return currentStatus = EOS; // end of stream
}
}
}
// dst[*bytesRead] = '\0';
#ifdef DEBUG
//fprintf(stdout, "We read:\n");
//fprintf(stdout, "====================================================\n");
//fprintf(stdout, "%s\n",dst);
//fprintf(stdout, "====================================================\n");
//fprintf(stdout,"read ok: %d\n", *bytesRead);fflush(stdout);
#endif
return currentStatus = Ok; // successfully read size bytes
}
//-----------------------------------------------------------------------------
// Write to a file.
// The number of bytes to write is passed in size, the data is passed in src.
// The number of bytes written is available in bytesWritten if a non-Null
// pointer is provided.
//-----------------------------------------------------------------------------
File::Status File::write(U32 size, const char *src, U32 *bytesWritten)
{
AssertFatal(Closed != currentStatus, "File::write: file closed");
AssertFatal(NULL != handle, "File::write: invalid file handle");
AssertFatal(NULL != src, "File::write: NULL source pointer");
AssertFatal(true == hasCapability(FileWrite), "File::write: file lacks capability");
AssertWarn(0 != size, "File::write: size of zero");
if ((Ok != currentStatus && EOS != currentStatus) || 0 == size)
return currentStatus;
else
{
long lastBytes;
long *bytes = (NULL == bytesWritten) ? &lastBytes : (long *)bytesWritten;
if (0 != (*((U32 *)bytes) = x86UNIXWrite(*((int *)handle), src, size)))
return currentStatus = Ok; // success!
else
return setStatus(); // unsuccessful
}
}
//-----------------------------------------------------------------------------
// Self-explanatory.
//-----------------------------------------------------------------------------
bool File::hasCapability(Capability cap) const
{
return (0 != (U32(cap) & capability));
}
S32 Platform::compareFileTimes(const FileTime &a, const FileTime &b)
{
if(a > b)
return 1;
if(a < b)
return -1;
if(a > b)
return 1;
if(a < b)
return -1;
return 0;
}
static bool recurseDumpPath(const char *path, const char *pattern, Vector<Platform::FileInfo> &fileVector)
{
char search[1024];
dSprintf(search, sizeof(search), "%s", path, pattern);
DIR *directory = opendir(search);
if (directory == NULL)
return false;
struct dirent *fEntry;
fEntry = readdir(directory); // read the first "file" in the directory
if (fEntry == NULL)
return false;
do
{
char filename[BUFSIZ+1];
struct stat fStat;
dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name
stat(filename, &fStat); // get the file stats
if ( (fStat.st_mode & S_IFMT) == S_IFDIR )
{
// Directory
// skip . and .. directories
if (dStrcmp(fEntry->d_name, ".") == 0 || dStrcmp(fEntry->d_name, "..") == 0)
continue;
char child[1024];
dSprintf(child, sizeof(child), "%s/%s", path, fEntry->d_name);
recurseDumpPath(child, pattern, fileVector);
}
else
{
// File
// add it to the list
fileVector.increment();
Platform::FileInfo& rInfo = fileVector.last();
rInfo.pFullPath = StringTable->insert(path);
rInfo.pFileName = StringTable->insert(fEntry->d_name);
rInfo.fileSize = fStat.st_size;
}
} while( (fEntry = readdir(directory)) != NULL );
closedir(directory);
return true;
}
//static bool _recurseDumpPath(const char* in_pBasePath,
// const char* in_pCurPath,
// Vector<Platform::FileInfo>& out_rFileVector)
//{
// char buf[1024];
// char curPath[1024];
// char basePath[1024];
// char scratchBuf[1024];
//
// if(in_pCurPath)
// dStrcpy(curPath, in_pCurPath);
// else
// curPath[0] = 0;
//
// dStrcpy(basePath, in_pBasePath);
// in_pBasePath = basePath;
//
//
// if (curPath[0] != '\0')
// dSprintf(buf, sizeof(buf), "%s/%s", basePath, curPath);
// else
// dSprintf(buf, sizeof(buf), "%s", basePath);
//
//
// backslash(buf);
// DIR *directory = opendir(buf); // open the directory
//
// if (directory == (DIR *)NULL)
// return false;
//
// struct dirent *fEntry;
// fEntry = readdir(directory); // read the first "file" in the directory
//
// while (fEntry != (struct dirent *)NULL) {
// char filename[BUFSIZ+1];
// struct stat fStat;
//
// dSprintf(filename, sizeof(filename), "%s/%s", buf, fEntry->d_name); // "construct" the file name
// stat(filename, &fStat); // get the file stats
//
// /* we AND the st_mode and S_IFMT to get the type of file */
// if ( (fStat.st_mode & S_IFMT) == S_IFDIR ) {
// // Directory
// if (filename[0] != '.') {
// scratchBuf[0] = '\0';
// if (curPath[0] != '\0') {
// dStrcpy(scratchBuf, curPath);
// dStrcat(scratchBuf, "/");
// }
// dStrcat(scratchBuf, filename);
//
// _recurseDumpPath(basePath, scratchBuf, out_rFileVector);
// }
// } else {
// // File
// out_rFileVector.increment();
// Platform::FileInfo& rInfo = out_rFileVector.last();
//
// if (curPath[0] != '\0') {
// dSprintf(scratchBuf, sizeof(scratchBuf), "%s/%s", basePath, curPath);
// rInfo.pFullPath = StringTable->insert(scratchBuf);
// rInfo.pVirtPath = StringTable->insert(curPath);
// } else {
// rInfo.pFullPath = StringTable->insert(basePath);
// rInfo.pVirtPath = NULL;
// }
// rInfo.pFileName = StringTable->insert(filename);
// rInfo.fileSize = fStat.st_size;
// }
//
// if ( (fEntry = readdir(directory)) == (struct dirent *)NULL) {
// closedir(directory);
// fEntry = (struct dirent *)NULL;
// }
// }
//
// return true;
//}
//--------------------------------------
bool Platform::getFileTimes(const char *filePath, FileTime *createTime, FileTime *modifyTime)
{
struct stat fStat;
if (stat(filePath, &fStat) == -1)
return false;
if(createTime)
{
// no where does SysV/BSD UNIX keep a record of a file's
// creation time. instead of creation time I'll just use
// changed time for now.
createTime = (FileTime *)&fStat.st_ctime;
}
if(modifyTime)
{
modifyTime = (FileTime *)&fStat.st_mtime;
}
return true;
}
//--------------------------------------
bool Platform::createPath(const char *file)
{
char pathbuf[1024];
const char *dir;
pathbuf[0] = 0;
U32 pathLen = 0;
while((dir = dStrchr(file, '/')) != NULL)
{
dStrncpy(pathbuf + pathLen, file, dir - file);
pathbuf[pathLen + dir-file] = 0;
bool ret = mkdir(pathbuf, 0666);
pathLen += dir - file;
pathbuf[pathLen++] = '/';
file = dir + 1;
}
return true;
}
/* this will be a pain and it's not being used so we are leaving it out, for now :-D
- rjp
*/
/***************************************************************************************
bool Platform::cdFileExists(const char *filePath, const char *volumeName, S32 serialNum)
{
if (!filePath || !filePath[0])
return true;
//first find the CD device...
char fileBuf[256];
char drivesBuf[256];
S32 length = GetLogicalDriveStrings(256, drivesBuf);
char *drivePtr = drivesBuf;
while (S32(drivePtr - drivesBuf) < length)
{
char driveVolume[256], driveFileSystem[256];
U32 driveSerial, driveFNLength, driveFlags;
if ((dStricmp(drivePtr, "A:\\") != 0 && dStricmp(drivePtr, "B:\\") != 0) &&
GetVolumeInformation((const char*)drivePtr, &driveVolume[0], (unsigned long)255,
(unsigned long*)&driveSerial, (unsigned long*)&driveFNLength,
(unsigned long*)&driveFlags, &driveFileSystem[0], (unsigned long)255))
{
#if defined (DEBUG) || defined (INTERNAL_RELEASE)
Con::printf("Found Drive: %s, vol: %s, serial: %d", drivePtr, driveVolume, driveSerial);
#endif
//see if the volume and serial number match
if (!dStricmp(volumeName, driveVolume) && (!serialNum || (serialNum == driveSerial)))
{
//see if the file exists on this volume
if(dStrlen(drivePtr) == 3 && drivePtr[2] == '\\' && filePath[0] == '\\')
dSprintf(fileBuf, sizeof(fileBuf), "%s%s", drivePtr, filePath + 1);
else
dSprintf(fileBuf, sizeof(fileBuf), "%s%s", drivePtr, filePath);
#if defined (DEBUG) || defined (INTERNAL_RELEASE)
Con::printf("Looking for file: %s on %s", fileBuf, driveVolume);
#endif
WIN32_FIND_DATA findData;
HANDLE h = FindFirstFile(fileBuf, &findData);
if(h != INVALID_HANDLE_VALUE)
{
FindClose(h);
return true;
}
FindClose(h);
}
}
//check the next drive
drivePtr += dStrlen(drivePtr) + 1;
}
return false;
}
***************************************************************************************/
//--------------------------------------
bool Platform::dumpPath(const char *path, Vector<Platform::FileInfo> &fileVector)
{
return recurseDumpPath(path, "*", fileVector);
}
//--------------------------------------
StringTableEntry Platform::getWorkingDirectory()
{
static StringTableEntry cwd = NULL;
if (!cwd)
{
char cwd_buf[2048];
getcwd(cwd_buf, 2047);
cwd = StringTable->insert(cwd_buf);
}
return cwd;
}
//--------------------------------------
bool Platform::isFile(const char *pFilePath)
{
if (!pFilePath || !*pFilePath)
return false;
// Get file info
struct stat fStat;
if (stat(pFilePath, &fStat) < 0)
return false;
// if the file is a "regular file" then true
if ( (fStat.st_mode & S_IFMT) == S_IFREG)
return true;
// must be some other file (directory, device, etc.)
return false;
}
//--------------------------------------
bool Platform::isDirectory(const char *pDirPath)
{
if (!pDirPath || !*pDirPath)
return false;
// Get file info
struct stat fStat;
if (stat(pDirPath, &fStat) < 0)
return false;
// if the file is a Directory then true
if ( (fStat.st_mode & S_IFMT) == S_IFDIR)
return true;
return false;
}
//--------------------------------------
bool Platform::isSubDirectory(const char *pParent, const char *pDir)
{
if (!pParent || !*pDir)
return false;
// this is somewhat of a brute force method but we need to be 100% sure
// that the user cannot enter things like ../dir or /dir etc,...
DIR *directory;
directory = opendir(pParent);
if (directory == NULL)
return false;
struct dirent *fEntry;
fEntry = readdir(directory);
if ( fEntry == NULL )
return false;
do
{
char dirBuf[MAXPATHLEN];
struct stat fStat;
dSprintf(dirBuf, sizeof(dirBuf), "%s/%s", pParent, fEntry->d_name);
if (stat(dirBuf, &fStat) < 0)
return false;
// if it is a directory...
if ( (fStat.st_mode & S_IFMT) == S_IFDIR)
{
// and the names match
if (dStrcmp(pDir, fEntry->d_name ) == 0)
{
// then we have a real sub directory
closedir(directory);
return true;
}
}
} while( (fEntry = readdir(directory)) != NULL );
closedir(directory);
return false;
}

View file

@ -0,0 +1,132 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "dgl/gFont.h"
#include "dgl/gBitmap.h"
#include "math/mRect.h"
#include "console/console.h"
void createFontInit(void);
void createFontShutdown(void);
//void CopyCharToBitmap(GBitmap *pDstBMP, HDC hSrcHDC, const RectI &r);
void createFontInit()
{
// fontHDC = CreateCompatibleDC(NULL);
// fontBMP = CreateCompatibleBitmap(fontHDC, 256, 256);
}
void createFontShutdown()
{
// DeleteObject(fontBMP);
// DeleteObject(fontHDC);
}
//void CopyCharToBitmap(GBitmap *pDstBMP, HDC hSrcHDC, const RectI &r)
//{
// for (S32 i = r.point.y; i < r.point.y + r.extent.y; i++)
// {
// for (S32 j = r.point.x; j < r.point.x + r.extent.x; j++)
// {
// COLORREF color = GetPixel(hSrcHDC, j, i);
// if (color)
// *pDstBMP->getAddress(j, i) = 255;
// else
// *pDstBMP->getAddress(j, i) = 0;
// }
// }
//}
GFont *createFont(const char *name, S32 size)
{
/*
if(!name)
return NULL;
if(size < 1)
return NULL;
HFONT hNewFont = CreateFont(size,0,0,0,0,0,0,0,0,0,0,0,0,name);
if(!hNewFont)
return NULL;
GFont *retFont = new GFont;
static U8 scratchPad[65536];
TEXTMETRIC textMetric;
COLORREF backgroundColorRef = RGB( 0, 0, 0);
COLORREF foregroundColorRef = RGB(255, 255, 255);
SelectObject(fontHDC, fontBMP);
SelectObject(fontHDC, hNewFont);
SetBkColor(fontHDC, backgroundColorRef);
SetTextColor(fontHDC, foregroundColorRef);
GetTextMetrics(fontHDC, &textMetric);
MAT2 matrix;
GLYPHMETRICS metrics;
RectI clip;
FIXED zero;
zero.fract = 0;
zero.value = 0;
FIXED one;
one.fract = 0;
one.value = 1;
matrix.eM11 = one;
matrix.eM12 = zero;
matrix.eM21 = zero;
matrix.eM22 = one;
S32 glyphCount = 0;
for(S32 i = 32; i < 256; i++)
{
if(GetGlyphOutline(
fontHDC, // handle of device context
i, // character to query
GGO_GRAY8_BITMAP, // format of data to return
&metrics, // address of structure for metrics
sizeof(scratchPad), // size of buffer for data
scratchPad, // address of buffer for data
&matrix // address of transformation matrix structure
) != GDI_ERROR)
{
glyphCount++;
U32 rowStride = (metrics.gmBlackBoxX + 3) & ~3; // DWORD aligned
U32 size = rowStride * metrics.gmBlackBoxY;
for(U32 j = 0; j < size; j++)
{
U32 pad = U32(scratchPad[j]) << 2;
if(pad > 255)
pad = 255;
scratchPad[j] = pad;
}
S32 inc = metrics.gmCellIncX;
if(inc < 0)
inc = -inc;
retFont->insertBitmap(i, scratchPad, rowStride, metrics.gmBlackBoxX, metrics.gmBlackBoxY, metrics.gmptGlyphOrigin.x, metrics.gmptGlyphOrigin.y, metrics.gmCellIncX);
}
else
{
char b = i;
SIZE size;
GetTextExtentPoint32(fontHDC, &b, 1, &size);
if(size.cx)
retFont->insertBitmap(i, scratchPad, 0, 0, 0, 0, 0, size.cx);
}
}
retFont->pack(textMetric.tmHeight, textMetric.tmAscent);
//clean up local vars
DeleteObject(hNewFont);
if (!glyphCount)
Con::errorf(ConsoleLogEntry::General,"Error creating font: %s %d",name, size);
return retFont;
*/
}

View file

@ -0,0 +1,131 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformGL.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include <time.h>
#include "console/console.h"
#include "console/consoleTypes.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
GLState gGLState;
bool gOpenGLDisablePT = false;
bool gOpenGLDisableCVA = false;
bool gOpenGLDisableTEC = false;
bool gOpenGLDisableARBMT = false;
bool gOpenGLDisableFC = false;
bool gOpenGLDisableTCompress = false;
bool gOpenGLNoEnvColor = false;
float gOpenGLGammaCorrection = 0.5;
bool gOpenGLNoDrawArraysAlpha = false;
GLboolean (GLAPIENTRY* glAvailableVertexBufferEXT)(void);
GLint (GLAPIENTRY* glAllocateVertexBufferEXT)(GLsizei size, GLint format, GLboolean preserve);
void* (GLAPIENTRY* glLockVertexBufferEXT)(GLint handle, GLsizei size);
void (GLAPIENTRY* glUnlockVertexBufferEXT)(GLint handle);
void (GLAPIENTRY* glSetVertexBufferEXT)(GLint handle);
void (GLAPIENTRY* glOffsetVertexBufferEXT)(GLint handle, GLuint offset);
void (GLAPIENTRY* glFillVertexBufferEXT)(GLint handle, GLint first, GLsizei count);
void (GLAPIENTRY* glFreeVertexBufferEXT)(GLint handle);
// #define GL_EXT_abgr 1
// #define GL_EXT_blend_color 1
// #define GL_EXT_blend_minmax 1
// #define GL_EXT_blend_subtract 1
// #define GL_EXT_compiled_vertex_array 1
// #define GL_ARB_multitexture 1
// #define GL_APPLE_specular_vector 1
// #define GL_APPLE_transform_hint 1
bool QGL_EXT_Init( )
{
// Load extensions...
//
const char* pExtString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
// EXT_compiled_vertex_array
if (GL_EXT_compiled_vertex_array) //pExtString && dStrstr(pExtString, (const char*)"GL_EXT_compiled_vertex_array") != NULL)
{
//glLockArraysEXT = dllLockArraysEXT = (glLockArrays_t) qwglGetProcAddress("glLockArraysEXT");
//glUnlockArraysEXT = dllUnlockArraysEXT = (glUnlockArrays_t) qwglGetProcAddress("glUnlockArraysEXT");
gGLState.suppLockedArrays = true;
} else {
//glLockArraysEXT = dllLockArraysEXT = NULL;
//glUnlockArraysEXT = dllUnlockArraysEXT = NULL;
gGLState.suppLockedArrays = false;
}
// ARB_multitexture
if (GL_ARB_multitexture) //pExtString && dStrstr(pExtString, (const char*)"GL_ARB_multitexture") != NULL)
{
//glActiveTextureARB = dllActiveTextureARB = (glActiveTextureARB_t) qwglGetProcAddress("glActiveTextureARB");
//glClientActiveTextureARB = dllClientActiveTextureARB = (glClientActiveTextureARB_t) qwglGetProcAddress("glClientActiveTextureARB");
//glMultiTexCoord2fARB = dllMultiTexCoord2fARB = (glMultiTexCoord2fARB_t) qwglGetProcAddress("glMultiTexCoord2fARB");
//glMultiTexCoord2fvARB = dllMultiTexCoord2fvARB = (glMultiTexCoord2fvARB_t) qwglGetProcAddress("glMultiTexCoord2fvARB");
gGLState.suppARBMultitexture = true;
} else {
//glActiveTextureARB = dllActiveTextureARB = NULL;
//glClientActiveTextureARB = dllClientActiveTextureARB = NULL;
//glMultiTexCoord2fARB = dllMultiTexCoord2fARB = NULL;
//glMultiTexCoord2fvARB = dllMultiTexCoord2fvARB = NULL;
gGLState.suppARBMultitexture = false;
}
// NV_vertex_array_range
if (false) //pExtString && dStrstr(pExtString, (const char*)"GL_NV_vertex_array_range") != NULL)
{
//glVertexArrayRangeNV = dllVertexArrayRangeNV = (glVertexArrayRange_t) qwglGetProcAddress("glVertexArrayRangeNV");
//glFlushVertexArrayRangeNV = dllFlushVertexArrayRangeNV = (glFlushVertexArrayRange_t) qwglGetProcAddress("glFlushVertexArrayRangeNV");
gGLState.suppVertexArrayRange = true;
} else {
//glVertexArrayRangeNV = dllVertexArrayRangeNV = NULL;
//glFlushVertexArrayRangeNV = dllFlushVertexArrayRangeNV = NULL;
gGLState.suppVertexArrayRange = false;
}
// EXT_fog_coord
if (false) //pExtString && dStrstr(pExtString, (const char*)"GL_EXT_fog_coord") != NULL)
{
//glFogCoordfEXT = dllFogCoordfEXT = (glFogCoordf_t) qwglGetProcAddress("glFogCoordfEXT");
//glFogCoordPointerEXT = dllFogCoordPointerEXT = (glFogCoordPointer_t) qwglGetProcAddress("glFogCoordPointerEXT");
gGLState.suppFogCoord = true;
} else {
//glFogCoordfEXT = dllFogCoordfEXT = NULL;
//glFogCoordPointerEXT = dllFogCoordPointerEXT = NULL;
gGLState.suppFogCoord = false;
}
// Binary states, i.e., no supporting functions
// EXT_packed_pixels
// EXT_texture_env_combine
//
gGLState.suppPackedPixels = false; //pExtString? (dStrstr(pExtString, (const char*)"GL_EXT_packed_pixels") != NULL) : false;
gGLState.suppTextureEnvCombine = false; //pExtString? (dStrstr(pExtString, (const char*)"GL_EXT_texture_env_combine") != NULL) : false;
Con::printf("OpenGL Init: Enabled Extensions");
if (gGLState.suppARBMultitexture) Con::printf(" ARB_multitexture");
if (gGLState.suppLockedArrays) Con::printf(" EXT_compiled_vertex_array");
if (gGLState.suppVertexArrayRange) Con::printf(" NV_vertex_array_range");
if (gGLState.suppTextureEnvCombine) Con::printf(" EXT_texture_env_combine");
if (gGLState.suppPackedPixels) Con::printf(" EXT_packed_pixels");
if (gGLState.suppFogCoord) Con::printf(" EXT_fog_coord");
Con::warnf(ConsoleLogEntry::General, "OpenGL Init: Disabled Extensions");
if (!gGLState.suppARBMultitexture) Con::warnf(ConsoleLogEntry::General, " ARB_multitexture");
if (!gGLState.suppLockedArrays) Con::warnf(ConsoleLogEntry::General, " EXT_compiled_vertex_array");
if (!gGLState.suppVertexArrayRange) Con::warnf(ConsoleLogEntry::General, " NV_vertex_array_range");
if (!gGLState.suppTextureEnvCombine) Con::warnf(ConsoleLogEntry::General, " EXT_texture_env_combine");
if (!gGLState.suppPackedPixels) Con::warnf(ConsoleLogEntry::General, " EXT_packed_pixels");
if (!gGLState.suppFogCoord) Con::warnf(ConsoleLogEntry::General, " EXT_fog_coord");
Con::printf("");
return true;
}

View file

@ -0,0 +1,377 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIXGLX_H_
#define _X86UNIXGLX_H_
#ifdef __cplusplus
extern "C" {
#endif
/***************** GLX TOKENS ***************/
/* $XFree86: xc/include/GL/glxtokens.h,v 1.4 2000/06/17 00:02:46 martin Exp $ */
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
#define GLX_VERSION_1_1 1
#define GLX_VERSION_1_2 1
#define GLX_VERSION_1_3 1
/*
** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib)
*/
#define GLX_USE_GL 1 /* support GLX rendering */
#define GLX_BUFFER_SIZE 2 /* depth of the color buffer */
#define GLX_LEVEL 3 /* level in plane stacking */
#define GLX_RGBA 4 /* true if RGBA mode */
#define GLX_DOUBLEBUFFER 5 /* double buffering supported */
#define GLX_STEREO 6 /* stereo buffering supported */
#define GLX_AUX_BUFFERS 7 /* number of aux buffers */
#define GLX_RED_SIZE 8 /* number of red component bits */
#define GLX_GREEN_SIZE 9 /* number of green component bits */
#define GLX_BLUE_SIZE 10 /* number of blue component bits */
#define GLX_ALPHA_SIZE 11 /* number of alpha component bits */
#define GLX_DEPTH_SIZE 12 /* number of depth bits */
#define GLX_STENCIL_SIZE 13 /* number of stencil bits */
#define GLX_ACCUM_RED_SIZE 14 /* number of red accum bits */
#define GLX_ACCUM_GREEN_SIZE 15 /* number of green accum bits */
#define GLX_ACCUM_BLUE_SIZE 16 /* number of blue accum bits */
#define GLX_ACCUM_ALPHA_SIZE 17 /* number of alpha accum bits */
/*
** FBConfig-specific attributes
*/
#define GLX_X_VISUAL_TYPE 0x22
#define GLX_CONFIG_CAVEAT 0x20 /* Like visual_info VISUAL_CAVEAT_EXT */
#define GLX_TRANSPARENT_TYPE 0x23
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
#define GLX_TRANSPARENT_RED_VALUE 0x25
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_RENDER_TYPE 0x8011
#define GLX_X_RENDERABLE 0x8012
#define GLX_FBCONFIG_ID 0x8013
#define GLX_MAX_PBUFFER_WIDTH 0x8016
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
#define GLX_MAX_PBUFFER_PIXELS 0x8018
#define GLX_VISUAL_ID 0x800B
/*
** Error return values from glXGetConfig. Success is indicated by
** a value of 0.
*/
#define GLX_BAD_SCREEN 1 /* screen # is bad */
#define GLX_BAD_ATTRIBUTE 2 /* attribute to get is bad */
#define GLX_NO_EXTENSION 3 /* no glx extension on server */
#define GLX_BAD_VISUAL 4 /* visual # not known by GLX */
#define GLX_BAD_CONTEXT 5 /* returned only by import_context EXT? */
#define GLX_BAD_VALUE 6 /* returned only by glXSwapIntervalSGI? */
#define GLX_BAD_ENUM 7 /* unused? */
/* FBConfig attribute values */
/*
** Generic "don't care" value for glX ChooseFBConfig attributes (except
** GLX_LEVEL)
*/
#define GLX_DONT_CARE 0xFFFFFFFF
/* GLX_RENDER_TYPE bits */
#define GLX_RGBA_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
/* GLX_DRAWABLE_TYPE bits */
#define GLX_WINDOW_BIT 0x00000001
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_PBUFFER_BIT 0x00000004
/* GLX_CONFIG_CAVEAT attribute values */
#define GLX_NONE 0x8000
#define GLX_SLOW_CONFIG 0x8001
#define GLX_NON_CONFORMANT_CONFIG 0x800D
/* GLX_X_VISUAL_TYPE attribute values */
#define GLX_TRUE_COLOR 0x8002
#define GLX_DIRECT_COLOR 0x8003
#define GLX_PSEUDO_COLOR 0x8004
#define GLX_STATIC_COLOR 0x8005
#define GLX_GRAY_SCALE 0x8006
#define GLX_STATIC_GRAY 0x8007
/* GLX_TRANSPARENT_TYPE attribute values */
/* #define GLX_NONE 0x8000 */
#define GLX_TRANSPARENT_RGB 0x8008
#define GLX_TRANSPARENT_INDEX 0x8009
/* glXCreateGLXPbuffer attributes */
#define GLX_PRESERVED_CONTENTS 0x801B
#define GLX_LARGEST_PBUFFER 0x801C
#define GLX_PBUFFER_HEIGHT 0x8040 /* New for GLX 1.3 */
#define GLX_PBUFFER_WIDTH 0x8041 /* New for GLX 1.3 */
/* glXQueryGLXPBuffer attributes */
#define GLX_WIDTH 0x801D
#define GLX_HEIGHT 0x801E
#define GLX_EVENT_MASK 0x801F
/* glXCreateNewContext render_type attribute values */
#define GLX_RGBA_TYPE 0x8014
#define GLX_COLOR_INDEX_TYPE 0x8015
/* glXQueryContext attributes */
/* #define GLX_FBCONFIG_ID 0x8013 */
/* #define GLX_RENDER_TYPE 0x8011 */
#define GLX_SCREEN 0x800C
/* glXSelectEvent event mask bits */
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
/* GLXPbufferClobberEvent event_type values */
#define GLX_DAMAGED 0x8020
#define GLX_SAVED 0x8021
/* GLXPbufferClobberEvent draw_type values */
#define GLX_WINDOW 0x8022
#define GLX_PBUFFER 0x8023
/* GLXPbufferClobberEvent buffer_mask bits */
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_DEPTH_BUFFER_BIT 0x00000020
#define GLX_STENCIL_BUFFER_BIT 0x00000040
#define GLX_ACCUM_BUFFER_BIT 0x00000080
/*
** Extension return values from glXGetConfig. These are also
** accepted as parameter values for glXChooseVisual.
*/
#define GLX_X_VISUAL_TYPE_EXT 0x22 /* visual_info extension type */
#define GLX_TRANSPARENT_TYPE_EXT 0x23 /* visual_info extension */
#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 /* visual_info extension */
#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 /* visual_info extension */
#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 /* visual_info extension */
#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 /* visual_info extension */
#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 /* visual_info extension */
/* Property values for visual_type */
#define GLX_TRUE_COLOR_EXT 0x8002
#define GLX_DIRECT_COLOR_EXT 0x8003
#define GLX_PSEUDO_COLOR_EXT 0x8004
#define GLX_STATIC_COLOR_EXT 0x8005
#define GLX_GRAY_SCALE_EXT 0x8006
#define GLX_STATIC_GRAY_EXT 0x8007
/* Property values for transparent pixel */
#define GLX_NONE_EXT 0x8000
#define GLX_TRANSPARENT_RGB_EXT 0x8008
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
/* Property values for visual_rating */
#define GLX_VISUAL_CAVEAT_EXT 0x20 /* visual_rating extension type */
#define GLX_SLOW_VISUAL_EXT 0x8001
#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
/*
** Names for attributes to glXGetClientString.
*/
#define GLX_VENDOR 0x1
#define GLX_VERSION 0x2
#define GLX_EXTENSIONS 0x3
/*
** Names for attributes to glXQueryContextInfoEXT.
*/
#define GLX_SHARE_CONTEXT_EXT 0x800A /* id of share context */
#define GLX_VISUAL_ID_EXT 0x800B /* id of context's visual */
#define GLX_SCREEN_EXT 0x800C /* screen number */
/* GLX Extension Strings */
#define GLX_EXT_import_context 1
#define GLX_EXT_visual_info 1
#define GLX_EXT_visual_rating 1
#define GLX_ARB_get_proc_address 1
/************** END OF GLX TOKENS ***********/
/* $XFree86: xc/include/GL/glx.h,v 1.7 2000/06/30 18:27:00 dawes Exp $ */
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
/*
** GLX resources.
*/
typedef XID GLXContextID;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
typedef XID GLXPbuffer;
typedef XID GLXWindow;
typedef XID GLXFBConfigID;
/*
** GLXContext is a pointer to opaque data.
*/
typedef struct __GLXcontextRec *GLXContext;
/*
** GLXFBConfig is a pointer to opaque data.
*/
typedef struct __GLXFBConfigRec *GLXFBConfig;
/************************************************************************/
extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);
extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
extern void glXDestroyContext (Display *dpy, GLXContext ctx);
extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);
extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);
extern GLXContext glXGetCurrentContext (void);
extern GLXDrawable glXGetCurrentDrawable (void);
extern Bool glXIsDirect (Display *dpy, GLXContext ctx);
extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx);
extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);
extern Bool glXQueryVersion (Display *dpy, int *major, int *minor);
extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);
extern void glXUseXFont (Font font, int first, int count, int listBase);
extern void glXWaitGL (void);
extern void glXWaitX (void);
extern const char * glXGetClientString (Display *dpy, int name );
extern const char * glXQueryServerString (Display *dpy, int screen, int name );
extern const char * glXQueryExtensionsString (Display *dpy, int screen );
/* New for GLX 1.3 */
extern GLXFBConfig * glXGetFBConfigs (Display *dpy, int screen, int *nelements);
extern GLXFBConfig * glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);
extern int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);
extern XVisualInfo * glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
extern GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
extern void glXDestroyWindow (Display *dpy, GLXWindow win);
extern GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
extern void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);
extern GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);
extern void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);
extern void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
extern GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
extern Bool glXMakeContextCurrent (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
extern GLXDrawable glXGetCurrentReadDrawable (void);
extern Display * glXGetCurrentDisplay (void);
extern int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);
extern void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);
extern void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
/*** SGI GLX extensions */
extern GLXContextID glXGetContextIDEXT (const GLXContext ctx);
extern GLXDrawable glXGetCurrentDrawableEXT (void);
extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);
extern void glXFreeContextEXT (Display *dpy, GLXContext ctx);
extern int glXQueryContextInfoEXT (Display *dpy, GLXContext ctx, int attribute, int *value);
extern void (*glXGetProcAddressARB(const GLubyte *procName))( void );
/*** Should these go here, or in another header? */
/*
** GLX Events
*/
typedef struct {
int event_type; /* GLX_DAMAGED or GLX_SAVED */
int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came for SendEvent request */
Display *display; /* display the event was read from */
GLXDrawable drawable; /* XID of Drawable */
unsigned int buffer_mask; /* mask indicating which buffers are affected */
unsigned int aux_buffer; /* which aux buffer was affected */
int x, y;
int width, height;
int count; /* if nonzero, at least this many more */
} GLXPbufferClobberEvent;
typedef union __GLXEvent {
GLXPbufferClobberEvent glxpbufferclobber;
long pad[24];
} GLXEvent;
/* end of GLX stuff */
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,24 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int x86UNIXOpen(const char *path, int oflag)
{
return open(path, oflag);
}
int x86UNIXClose(int fd)
{
return close(fd);
}
ssize_t x86UNIXRead(int fd, void *buf, size_t nbytes)
{
return read(fd, buf, nbytes);
}
ssize_t x86UNIXWrite(int fd, const void *buf, size_t nbytes)
{
return write(fd, buf, nbytes);
}

View file

@ -0,0 +1,831 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformInput.h"
#include "platform/platformVideo.h"
#include "platform/event.h"
#include "platform/gameInterface.h"
#include "console/console.h"
#include <unistd.h>
#include <termios.h>
#include <ctype.h>
#ifdef LOG_INPUT
#include <time.h>
#include <stdarg.h>
#endif
// Static class variables:
InputManager* Input::smManager;
bool Input::smActive;
#ifdef LOG_INPUT
static HANDLE gInputLog;
#endif
static void fillAsciiTable();
//------------------------------------------------------------------------------
//
// This function gets the standard ASCII code corresponding to our key code
// and the existing modifier key state.
//
//------------------------------------------------------------------------------
struct AsciiData
{
struct KeyData
{
U16 ascii;
bool isDeadChar;
};
KeyData upper;
KeyData lower;
KeyData goofy;
};
#define NUM_KEYS ( KEY_OEM_102 + 1 )
#define KEY_FIRST KEY_ESCAPE
static AsciiData AsciiTable[NUM_KEYS];
//------------------------------------------------------------------------------
void Input::init()
{
Con::printf( "Input Init:" );
destroy();
smActive = false;
// struct termios termModes;
// tcgetattr(fileno(stdin), &termModes);
// termModes.c_lflag &= ~ICANON; // enable non-canonical mode
// termModes.c_cc[VMIN] = 1;
// termModes.c_cc[VTIME] = 0;
// tcsetattr(fileno(stdin), TCSAFLUSH, &termModes);
#ifdef LOG_INPUT
struct tm* newTime;
time_t aclock;
time( &aclock );
newTime = localtime( &aclock );
asctime( newTime );
gInputLog = CreateFile( "input.log", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
log( "Input log opened at %s\n", asctime( newTime ) );
#endif
/*
smActive = false;
OSVERSIONINFO OSVersionInfo;
dMemset( &OSVersionInfo, 0, sizeof( OSVERSIONINFO ) );
OSVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
if ( GetVersionEx( &OSVersionInfo ) )
{
#ifdef LOG_INPUT
log( "Operating System:\n" );
switch ( OSVersionInfo.dwPlatformId )
{
case VER_PLATFORM_WIN32s:
log( " Win32s on Windows 3.1 version %d.%d\n", OSVersionInfo.dwMajorVersion, OSVersionInfo.dwMinorVersion );
break;
case VER_PLATFORM_WIN32_WINDOWS:
log( " Windows 95 version %d.%d\n", OSVersionInfo.dwMajorVersion, OSVersionInfo.dwMinorVersion );
log( " Build number %d\n", LOWORD( OSVersionInfo.dwBuildNumber ) );
break;
case VER_PLATFORM_WIN32_NT:
log( " WinNT version %d.%d\n", OSVersionInfo.dwMajorVersion, OSVersionInfo.dwMinorVersion );
log( " Build number %d\n", OSVersionInfo.dwBuildNumber );
break;
}
if ( OSVersionInfo.szCSDVersion != NULL )
log( " %s\n", OSVersionInfo.szCSDVersion );
log( "\n" );
#endif
*/
fillAsciiTable();
Con::printf( "" );
}
//------------------------------------------------------------------------------
ConsoleFunction( isJoystickDetected, bool, 1, 1, "isJoystickDetected()" )
{
/*
argc; argv;
return( DInputDevice::joystickDetected() );
*/
}
//------------------------------------------------------------------------------
ConsoleFunction( getJoystickAxes, const char*, 2, 2, "getJoystickAxes( instance )" )
{
/*
argc;
DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );
if ( mgr )
return( mgr->getJoystickAxesString( dAtoi( argv[1] ) ) );
return( "" );
*/
}
//------------------------------------------------------------------------------
static void fillAsciiTable()
{
/*
#ifdef LOG_INPUT
char buf[256];
Input::log( "--- Filling the ASCII table! ---\n" );
#endif
//HKL layout = GetKeyboardLayout( 0 );
U8 state[256];
U16 ascii[2];
U32 dikCode, vKeyCode, keyCode;
S32 result;
dMemset( &AsciiTable, 0, sizeof( AsciiTable ) );
dMemset( &state, 0, sizeof( state ) );
for ( keyCode = KEY_FIRST; keyCode < NUM_KEYS; keyCode++ )
{
ascii[0] = ascii[1] = 0;
dikCode = Key_to_DIK( keyCode );
if ( dikCode )
{
//vKeyCode = MapVirtualKeyEx( dikCode, 1, layout );
vKeyCode = MapVirtualKey( dikCode, 1 );
#ifdef LOG_INPUT
dSprintf( buf, sizeof( buf ), "KC: %#04X DK: %#04X VK: %#04X\n",
keyCode, dikCode, vKeyCode );
Input::log( buf );
#endif
// Lower case:
ascii[0] = ascii[1] = 0;
//result = ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
result = ToAscii( vKeyCode, dikCode, state, ascii, 0 );
#ifdef LOG_INPUT
dSprintf( buf, sizeof( buf ), " LOWER- R: %d A[0]: %#06X A[1]: %#06X\n",
result, ascii[0], ascii[1] );
Input::log( buf );
#endif
if ( result == 2 )
AsciiTable[keyCode].lower.ascii = ascii[1] ? ascii[1] : ( ascii[0] >> 8 );
else if ( result == 1 )
AsciiTable[keyCode].lower.ascii = ascii[0];
else if ( result < 0 )
{
AsciiTable[keyCode].lower.ascii = ascii[0];
AsciiTable[keyCode].lower.isDeadChar = true;
// Need to clear the dead character from the keyboard layout:
//ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
ToAscii( vKeyCode, dikCode, state, ascii, 0 );
}
// Upper case:
ascii[0] = ascii[1] = 0;
state[VK_SHIFT] = 0x80;
//result = ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
result = ToAscii( vKeyCode, dikCode, state, ascii, 0 );
#ifdef LOG_INPUT
dSprintf( buf, sizeof( buf ), " UPPER- R: %d A[0]: %#06X A[1]: %#06X\n",
result, ascii[0], ascii[1] );
Input::log( buf );
#endif
if ( result == 2 )
AsciiTable[keyCode].upper.ascii = ascii[1] ? ascii[1] : ( ascii[0] >> 8 );
else if ( result == 1 )
AsciiTable[keyCode].upper.ascii = ascii[0];
else if ( result < 0 )
{
AsciiTable[keyCode].upper.ascii = ascii[0];
AsciiTable[keyCode].upper.isDeadChar = true;
// Need to clear the dead character from the keyboard layout:
//ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
ToAscii( vKeyCode, dikCode, state, ascii, 0 );
}
state[VK_SHIFT] = 0;
// Foreign mod case:
ascii[0] = ascii[1] = 0;
state[VK_CONTROL] = 0x80;
state[VK_MENU] = 0x80;
//result = ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
result = ToAscii( vKeyCode, dikCode, state, ascii, 0 );
#ifdef LOG_INPUT
dSprintf( buf, sizeof( buf ), " GOOFY- R: %d A[0]: %#06X A[1]: %#06X\n",
result, ascii[0], ascii[1] );
Input::log( buf );
#endif
if ( result == 2 )
AsciiTable[keyCode].goofy.ascii = ascii[1] ? ascii[1] : ( ascii[0] >> 8 );
else if ( result == 1 )
AsciiTable[keyCode].goofy.ascii = ascii[0];
else if ( result < 0 )
{
AsciiTable[keyCode].goofy.ascii = ascii[0];
AsciiTable[keyCode].goofy.isDeadChar = true;
// Need to clear the dead character from the keyboard layout:
//ToAsciiEx( vKeyCode, dikCode, state, ascii, 0, layout );
ToAscii( vKeyCode, dikCode, state, ascii, 0 );
}
state[VK_CONTROL] = 0;
state[VK_MENU] = 0;
}
}
#ifdef LOG_INPUT
Input::log( "--- Finished filling the ASCII table! ---\n\n" );
#endif
*/
}
//------------------------------------------------------------------------------
U16 Input::getKeyCode( U16 asciiCode )
{
U16 keyCode = 0;
U16 i;
// This is done three times so the lowerkey will always
// be found first. Some foreign keyboards have duplicate
// chars on some keys.
for ( i = KEY_FIRST; i < NUM_KEYS && !keyCode; i++ )
{
if ( AsciiTable[i].lower.ascii == asciiCode )
{
keyCode = i;
break;
};
}
for ( i = KEY_FIRST; i < NUM_KEYS && !keyCode; i++ )
{
if ( AsciiTable[i].upper.ascii == asciiCode )
{
keyCode = i;
break;
};
}
for ( i = KEY_FIRST; i < NUM_KEYS && !keyCode; i++ )
{
if ( AsciiTable[i].goofy.ascii == asciiCode )
{
keyCode = i;
break;
};
}
return( keyCode );
}
//------------------------------------------------------------------------------
U16 Input::getAscii( U16 keyCode, KEY_STATE keyState )
{
if ( keyCode >= NUM_KEYS )
return 0;
switch ( keyState )
{
case STATE_LOWER:
return AsciiTable[keyCode].lower.ascii;
case STATE_UPPER:
return AsciiTable[keyCode].upper.ascii;
case STATE_GOOFY:
return AsciiTable[keyCode].goofy.ascii;
default:
return(0);
}
}
//------------------------------------------------------------------------------
void Input::destroy()
{
#ifdef LOG_INPUT
if ( gInputLog )
{
log( "*** CLOSING LOG ***\n" );
CloseHandle( gInputLog );
gInputLog = NULL;
}
#endif
if ( smManager && smManager->isEnabled() )
{
smManager->disable();
delete smManager;
smManager = NULL;
}
}
//------------------------------------------------------------------------------
bool Input::enable()
{
if ( smManager && !smManager->isEnabled() )
return( smManager->enable() );
return( false );
}
//------------------------------------------------------------------------------
void Input::disable()
{
if ( smManager && smManager->isEnabled() )
smManager->disable();
}
//------------------------------------------------------------------------------
void Input::activate()
{
/*
DInputDevice::resetModifierKeys();
if ( !Con::getBoolVariable( "$enableDirectInput" ) )
return;
if ( smManager && smManager->isEnabled() && !smActive )
{
Con::printf( "Activating DirectInput..." );
#ifdef LOG_INPUT
Input::log( "Activating DirectInput...\n" );
#endif
smActive = true;
DInputManager* dInputManager = dynamic_cast<DInputManager*>( smManager );
if ( dInputManager )
{
if ( dInputManager->isKeyboardEnabled() )
dInputManager->activateKeyboard();
if ( Video::isFullScreen() )
{
// DirectInput Mouse Hook-Up:
if ( dInputManager->isMouseEnabled() )
dInputManager->activateMouse();
}
else
dInputManager->deactivateMouse();
if ( dInputManager->isJoystickEnabled() )
dInputManager->activateJoystick();
}
}
*/
}
//------------------------------------------------------------------------------
void Input::deactivate()
{
if ( smManager && smManager->isEnabled() && smActive )
{
#ifdef LOG_INPUT
Input::log( "Deactivating Input...\n" );
#endif
smActive = false;
Con::printf( "Input deactivated." );
}
}
//------------------------------------------------------------------------------
void Input::reactivate()
{
/*
// This is soo hacky...
SetForegroundWindow( winState.appWindow );
PostMessage( winState.appWindow, WM_ACTIVATE, WA_ACTIVE, NULL );
*/
}
//------------------------------------------------------------------------------
bool Input::isEnabled()
{
if ( smManager )
return smManager->isEnabled();
return false;
}
//------------------------------------------------------------------------------
bool Input::isActive()
{
return smActive;
}
//------------------------------------------------------------------------------
void Input::process()
{
/*
U16 key;
int i;
if ( ( i = read(fileno(stdin), &key, sizeof(char)) ) != 0) {
// Con::printf( "key: %d = '%c'", toascii(key), key);
// Con::printf( "posting event." );
InputEvent e;
e.deviceInst = 0;
e.deviceType = KeyboardDeviceType;
e.objType = SI_KEY;
e.objInst = TranslateOSKeyCode( key ); // NOTE: what is objInst?
e.action = SI_MAKE;
e.modifier = 0;
e.ascii = key;
e.fValue = 1.0f;
Game->postEvent(e);
}
// if ( smManager && smManager->isEnabled() && smActive )
// smManager->process();
*/
}
//------------------------------------------------------------------------------
InputManager* Input::getManager()
{
return( smManager );
}
#ifdef LOG_INPUT
//------------------------------------------------------------------------------
void Input::log( const char* format, ... )
{
/*
if ( !gInputLog )
return;
va_list argptr;
va_start( argptr, format );
char buffer[512];
dVsprintf( buffer, 511, format, argptr );
DWORD bytes;
WriteFile( gInputLog, buffer, dStrlen( buffer ), &bytes, NULL );
va_end( argptr );
*/
}
ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" )
{
/*
argc;
Input::log( "%s\n", argv[1] );
*/
}
#endif // LOG_INPUT
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static U8 VcodeRemap[256] =
{
0, // 0x00
0, // 0x01 VK_LBUTTON
0, // 0x02 VK_RBUTTON
0, // 0x03 VK_CANCEL
0, // 0x04 VK_MBUTTON
0, // 0x05
0, // 0x06
0, // 0x07
KEY_BACKSPACE, // 0x08 VK_BACK
KEY_TAB, // 0x09 VK_TAB
0, // 0x0A
0, // 0x0B
0, // 0x0C VK_CLEAR
KEY_RETURN, // 0x0D VK_RETURN
0, // 0x0E
0, // 0x0F
KEY_SHIFT, // 0x10 VK_SHIFT
KEY_CONTROL, // 0x11 VK_CONTROL
KEY_ALT, // 0x12 VK_MENU
KEY_PAUSE, // 0x13 VK_PAUSE
KEY_CAPSLOCK, // 0x14 VK_CAPITAL
0, // 0x15 VK_KANA, VK_HANGEUL, VK_HANGUL
0, // 0x16
0, // 0x17 VK_JUNJA
0, // 0x18 VK_FINAL
0, // 0x19 VK_HANJA, VK_KANJI
0, // 0x1A
KEY_ESCAPE, // 0x1B VK_ESCAPE
0, // 0x1C VK_CONVERT
0, // 0x1D VK_NONCONVERT
0, // 0x1E VK_ACCEPT
0, // 0x1F VK_MODECHANGE
KEY_SPACE, // 0x20 VK_SPACE
KEY_PAGE_UP, // 0x21 VK_PRIOR
KEY_PAGE_DOWN, // 0x22 VK_NEXT
KEY_END, // 0x23 VK_END
KEY_HOME, // 0x24 VK_HOME
KEY_LEFT, // 0x25 VK_LEFT
KEY_UP, // 0x26 VK_UP
KEY_RIGHT, // 0x27 VK_RIGHT
KEY_DOWN, // 0x28 VK_DOWN
0, // 0x29 VK_SELECT
KEY_PRINT, // 0x2A VK_PRINT
0, // 0x2B VK_EXECUTE
0, // 0x2C VK_SNAPSHOT
KEY_INSERT, // 0x2D VK_INSERT
KEY_DELETE, // 0x2E VK_DELETE
KEY_HELP, // 0x2F VK_HELP
KEY_0, // 0x30 VK_0 VK_0 thru VK_9 are the same as ASCII '0' thru '9' (// 0x30 - // 0x39)
KEY_1, // 0x31 VK_1
KEY_2, // 0x32 VK_2
KEY_3, // 0x33 VK_3
KEY_4, // 0x34 VK_4
KEY_5, // 0x35 VK_5
KEY_6, // 0x36 VK_6
KEY_7, // 0x37 VK_7
KEY_8, // 0x38 VK_8
KEY_9, // 0x39 VK_9
0, // 0x3A
0, // 0x3B
0, // 0x3C
0, // 0x3D
0, // 0x3E
0, // 0x3F
0, // 0x40
KEY_A, // 0x41 VK_A VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (// 0x41 - // 0x5A)
KEY_B, // 0x42 VK_B
KEY_C, // 0x43 VK_C
KEY_D, // 0x44 VK_D
KEY_E, // 0x45 VK_E
KEY_F, // 0x46 VK_F
KEY_G, // 0x47 VK_G
KEY_H, // 0x48 VK_H
KEY_I, // 0x49 VK_I
KEY_J, // 0x4A VK_J
KEY_K, // 0x4B VK_K
KEY_L, // 0x4C VK_L
KEY_M, // 0x4D VK_M
KEY_N, // 0x4E VK_N
KEY_O, // 0x4F VK_O
KEY_P, // 0x50 VK_P
KEY_Q, // 0x51 VK_Q
KEY_R, // 0x52 VK_R
KEY_S, // 0x53 VK_S
KEY_T, // 0x54 VK_T
KEY_U, // 0x55 VK_U
KEY_V, // 0x56 VK_V
KEY_W, // 0x57 VK_W
KEY_X, // 0x58 VK_X
KEY_Y, // 0x59 VK_Y
KEY_Z, // 0x5A VK_Z
KEY_WIN_LWINDOW, // 0x5B VK_LWIN
KEY_WIN_RWINDOW, // 0x5C VK_RWIN
KEY_WIN_APPS, // 0x5D VK_APPS
0, // 0x5E
0, // 0x5F
KEY_NUMPAD0, // 0x60 VK_NUMPAD0
KEY_NUMPAD1, // 0x61 VK_NUMPAD1
KEY_NUMPAD2, // 0x62 VK_NUMPAD2
KEY_NUMPAD3, // 0x63 VK_NUMPAD3
KEY_NUMPAD4, // 0x64 VK_NUMPAD4
KEY_NUMPAD5, // 0x65 VK_NUMPAD5
KEY_NUMPAD6, // 0x66 VK_NUMPAD6
KEY_NUMPAD7, // 0x67 VK_NUMPAD7
KEY_NUMPAD8, // 0x68 VK_NUMPAD8
KEY_NUMPAD9, // 0x69 VK_NUMPAD9
KEY_MULTIPLY, // 0x6A VK_MULTIPLY
KEY_ADD, // 0x6B VK_ADD
KEY_SEPARATOR, // 0x6C VK_SEPARATOR
KEY_SUBTRACT, // 0x6D VK_SUBTRACT
KEY_DECIMAL, // 0x6E VK_DECIMAL
KEY_DIVIDE, // 0x6F VK_DIVIDE
KEY_F1, // 0x70 VK_F1
KEY_F2, // 0x71 VK_F2
KEY_F3, // 0x72 VK_F3
KEY_F4, // 0x73 VK_F4
KEY_F5, // 0x74 VK_F5
KEY_F6, // 0x75 VK_F6
KEY_F7, // 0x76 VK_F7
KEY_F8, // 0x77 VK_F8
KEY_F9, // 0x78 VK_F9
KEY_F10, // 0x79 VK_F10
KEY_F11, // 0x7A VK_F11
KEY_F12, // 0x7B VK_F12
KEY_F13, // 0x7C VK_F13
KEY_F14, // 0x7D VK_F14
KEY_F15, // 0x7E VK_F15
KEY_F16, // 0x7F VK_F16
KEY_F17, // 0x80 VK_F17
KEY_F18, // 0x81 VK_F18
KEY_F19, // 0x82 VK_F19
KEY_F20, // 0x83 VK_F20
KEY_F21, // 0x84 VK_F21
KEY_F22, // 0x85 VK_F22
KEY_F23, // 0x86 VK_F23
KEY_F24, // 0x87 VK_F24
0, // 0x88
0, // 0x89
0, // 0x8A
0, // 0x8B
0, // 0x8C
0, // 0x8D
0, // 0x8E
0, // 0x8F
KEY_NUMLOCK, // 0x90 VK_NUMLOCK
KEY_SCROLLLOCK, // 0x91 VK_OEM_SCROLL
0, // 0x92
0, // 0x93
0, // 0x94
0, // 0x95
0, // 0x96
0, // 0x97
0, // 0x98
0, // 0x99
0, // 0x9A
0, // 0x9B
0, // 0x9C
0, // 0x9D
0, // 0x9E
0, // 0x9F
KEY_LSHIFT, // 0xA0 VK_LSHIFT
KEY_RSHIFT, // 0xA1 VK_RSHIFT
KEY_LCONTROL, // 0xA2 VK_LCONTROL
KEY_RCONTROL, // 0xA3 VK_RCONTROL
KEY_LALT, // 0xA4 VK_LMENU
KEY_RALT, // 0xA5 VK_RMENU
0, // 0xA6
0, // 0xA7
0, // 0xA8
0, // 0xA9
0, // 0xAA
0, // 0xAB
0, // 0xAC
0, // 0xAD
0, // 0xAE
0, // 0xAF
0, // 0xB0
0, // 0xB1
0, // 0xB2
0, // 0xB3
0, // 0xB4
0, // 0xB5
0, // 0xB6
0, // 0xB7
0, // 0xB8
0, // 0xB9
KEY_SEMICOLON, // 0xBA VK_OEM_1
KEY_EQUALS, // 0xBB VK_OEM_PLUS
KEY_COMMA, // 0xBC VK_OEM_COMMA
KEY_MINUS, // 0xBD VK_OEM_MINUS
KEY_PERIOD, // 0xBE VK_OEM_PERIOD
KEY_SLASH, // 0xBF VK_OEM_2
KEY_TILDE, // 0xC0 VK_OEM_3
0, // 0xC1
0, // 0xC2
0, // 0xC3
0, // 0xC4
0, // 0xC5
0, // 0xC6
0, // 0xC7
0, // 0xC8
0, // 0xC9
0, // 0xCA
0, // 0xCB
0, // 0xCC
0, // 0xCD
0, // 0xCE
0, // 0xCF
0, // 0xD0
0, // 0xD1
0, // 0xD2
0, // 0xD3
0, // 0xD4
0, // 0xD5
0, // 0xD6
0, // 0xD7
0, // 0xD8
0, // 0xD9
0, // 0xDA
KEY_LBRACKET, // 0xDB VK_OEM_4
KEY_BACKSLASH, // 0xDC VK_OEM_5
KEY_RBRACKET, // 0xDD VK_OEM_6
KEY_APOSTROPHE, // 0xDE VK_OEM_7
0, // 0xDF VK_OEM_8
0, // 0xE0
0, // 0xE1 VK_OEM_AX AX key on Japanese AX keyboard
KEY_OEM_102, // 0xE2 VK_OEM_102
0, // 0xE3
0, // 0xE4
0, // 0xE5 VK_PROCESSKEY
0, // 0xE6
0, // 0xE7
0, // 0xE8
0, // 0xE9
0, // 0xEA
0, // 0xEB
0, // 0xEC
0, // 0xED
0, // 0xEE
0, // 0xEF
0, // 0xF0
0, // 0xF1
0, // 0xF2
0, // 0xF3
0, // 0xF4
0, // 0xF5
0, // 0xF6 VK_ATTN
0, // 0xF7 VK_CRSEL
0, // 0xF8 VK_EXSEL
0, // 0xF9 VK_EREOF
0, // 0xFA VK_PLAY
0, // 0xFB VK_ZOOM
0, // 0xFC VK_NONAME
0, // 0xFD VK_PA1
0, // 0xFE VK_OEM_CLEAR
0 // 0xFF
};
//------------------------------------------------------------------------------
//
// This function translates a virtual key code to our corresponding internal
// key code using the preceding table.
//
//------------------------------------------------------------------------------
U8 TranslateOSKeyCode(U8 vcode)
{
return VcodeRemap[vcode];
}
//-----------------------------------------------------------------------------
// Clipboard functions
const char* Platform::getClipboard()
{
/*
HGLOBAL hGlobal;
LPVOID pGlobal;
//make sure we can access the clipboard
if (!IsClipboardFormatAvailable(CF_TEXT))
return "";
if (!OpenClipboard(NULL))
return "";
hGlobal = GetClipboardData(CF_TEXT);
pGlobal = GlobalLock(hGlobal);
S32 cbLength = strlen((char *)pGlobal);
char *returnBuf = Con::getReturnBuffer(cbLength + 1);
strcpy(returnBuf, (char *)pGlobal);
returnBuf[cbLength] = '\0';
GlobalUnlock(hGlobal);
CloseClipboard();
//note - this function never returns NULL
return returnBuf;
*/
}
//-----------------------------------------------------------------------------
bool Platform::setClipboard(const char *text)
{
/*
if (!text)
return false;
//make sure we can access the clipboard
if (!OpenClipboard(NULL))
return false;
S32 cbLength = strlen(text);
HGLOBAL hGlobal;
LPVOID pGlobal;
hGlobal = GlobalAlloc(GHND, cbLength + 1);
pGlobal = GlobalLock (hGlobal);
strcpy((char *)pGlobal, text);
GlobalUnlock(hGlobal);
EmptyClipboard();
SetClipboardData(CF_TEXT, hGlobal);
CloseClipboard();
return true;
*/
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,140 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
// $Id: x86UNIXInputManager.h,v 1.1 2002/01/26 23:58:06 jmquigs Exp $
#ifndef _X86UNIXINPUTMANAGER_H_
#define _X86UNIXINPUTMANAGER_H_
#include "platform/platformInput.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include <SDL/SDL_events.h>
// JMQTODO: make these not be defines
#define NUM_KEYS ( KEY_OEM_102 + 1 )
#define KEY_FIRST KEY_ESCAPE
struct AsciiData
{
struct KeyData
{
U16 ascii;
bool isDeadChar;
};
KeyData upper;
KeyData lower;
KeyData goofy;
};
typedef struct _SDL_Joystick;
//------------------------------------------------------------------------------
class JoystickInputDevice : public InputDevice
{
public:
JoystickInputDevice(U8 deviceID);
~JoystickInputDevice();
bool activate();
bool deactivate();
bool isActive() { return( mActive ); }
U8 getDeviceType() { return( JoystickDeviceType ); }
U8 getDeviceID() { return( mDeviceID ); }
const char* getName();
const char* getJoystickAxesString();
bool process();
private:
bool mActive;
U8 mDeviceID;
SDL_Joystick* mStick;
};
//------------------------------------------------------------------------------
class UInputManager : public InputManager
{
public:
UInputManager();
void init();
bool enable();
void disable();
void activate();
void deactivate();
void setWindowLocked(bool locked);
bool isActive() { return( mActive ); }
void onDeleteNotify( SimObject* object );
bool onAdd();
void onRemove();
void process();
bool enableKeyboard();
void disableKeyboard();
bool isKeyboardEnabled() { return( mKeyboardEnabled ); }
bool activateKeyboard();
void deactivateKeyboard();
bool isKeyboardActive() { return( mKeyboardActive ); }
bool enableMouse();
void disableMouse();
bool isMouseEnabled() { return( mMouseEnabled ); }
bool activateMouse();
void deactivateMouse();
bool isMouseActive() { return( mMouseActive ); }
bool enableJoystick();
void disableJoystick();
bool isJoystickEnabled() { return( mJoystickEnabled ); }
bool activateJoystick();
void deactivateJoystick();
bool isJoystickActive() { return( mJoystickActive ); }
const char* getJoystickAxesString( U32 deviceID );
private:
typedef SimGroup Parent;
bool mKeyboardEnabled;
bool mMouseEnabled;
bool mJoystickEnabled;
bool mKeyboardActive;
bool mMouseActive;
bool mJoystickActive;
bool mActive;
// Device state variables
S32 mModifierKeys;
bool mKeyboardState[256];
bool mMouseButtonState[3];
// last mousex and y are maintained when window is unlocked
S32 mLastMouseX;
S32 mLastMouseY;
void initJoystick();
void resetKeyboardState();
void resetMouseState();
void resetInputState();
void lockInput();
void unlockInput();
void mouseButtonEvent(const SDL_Event& event);
void mouseMotionEvent(const SDL_Event& event);
void keyEvent(const SDL_Event& event);
bool processKeyEvent(InputEvent &event);
};
#endif // _H_X86UNIXINPUTMANAGER_

View file

@ -0,0 +1,107 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "console/console.h"
#include "math/mMath.h"
extern void mInstallLibrary_C();
extern void mInstallLibrary_ASM();
extern void mInstall_AMD_Math();
//--------------------------------------
static void cMathInit(SimObject*, S32 argc, const char** argv)
{
U32 properties = CPU_PROP_C; // C entensions are always used
if (argc == 1)
{
Math::init(0);
return;
}
for (argc--, argv++; argc; argc--, argv++)
{
if (dStricmp(*argv, "DETECT") == 0) {
Math::init(0);
return;
}
if (dStricmp(*argv, "C") == 0) {
properties |= CPU_PROP_C;
continue;
}
if (dStricmp(*argv, "FPU") == 0) {
properties |= CPU_PROP_FPU;
continue;
}
if (dStricmp(*argv, "MMX") == 0) {
properties |= CPU_PROP_MMX;
continue;
}
if (dStricmp(*argv, "3DNOW") == 0) {
properties |= CPU_PROP_3DNOW;
continue;
}
if (dStricmp(*argv, "SSE") == 0) {
properties |= CPU_PROP_SSE;
continue;
}
Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", *argv);
}
Math::init(properties);
}
//------------------------------------------------------------------------------
void Math::init(U32 properties)
{
Con::addCommand( "MathInit", cMathInit, "MathInit(detect|C|FPU|MMX|3DNOW|SSE|...)", 1, 10);
if (!properties)
// detect what's available
properties = Platform::SystemInfo.processor.properties;
else
// Make sure we're not asking for anything that's not supported
properties &= Platform::SystemInfo.processor.properties;
Con::printf("Math Init:");
Con::printf(" Installing Standard C extensions");
mInstallLibrary_C();
// Con::printf(" Installing Assembly extensions");
// mInstallLibrary_ASM();
if (properties & CPU_PROP_FPU)
{
Con::printf(" Installing FPU extensions");
}
if (properties & CPU_PROP_MMX)
{
Con::printf(" Installing MMX extensions");
if (properties & CPU_PROP_3DNOW)
{
Con::printf(" Installing 3DNow extensions");
// mInstall_AMD_Math();
}
}
#if !defined(__MWERKS__) || (__MWERKS__ >= 0x2400)
if (properties & CPU_PROP_SSE)
{
Con::printf(" Installing SSE extensions");
// mInstall_Library_SSE();
}
#endif //mwerks>2.4
Con::printf(" ");
}

View file

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "math/mMath.h"
static S32 m_mulDivS32_ASM(S32 a, S32 b, S32 c)
{ // a * b / c
S32 r;
__asm__ __volatile__(
"imul %2\n"
"idiv %3\n"
: "=a" (r) : "a" (a) , "b" (b) , "c" (c)
);
return r;
}
static U32 m_mulDivU32_ASM(S32 a, S32 b, U32 c)
{ // a * b / c
S32 r;
__asm__ __volatile__(
"mov $0, %%edx\n"
"mul %2\n"
"div %3\n"
: "=a" (r) : "a" (a) , "b" (b) , "c" (c)
);
return r;
}
//------------------------------------------------------------------------------
void mInstallLibrary_ASM()
{
m_mulDivS32 = m_mulDivS32_ASM;
m_mulDivU32 = m_mulDivU32_ASM;
}

View file

@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include <stdlib.h>
void* dMemcpy(void *dst, const void *src, unsigned size)
{
return memcpy(dst,src,size);
}
//--------------------------------------
void* dMemmove(void *dst, const void *src, unsigned size)
{
return memmove(dst,src,size);
}
//--------------------------------------
void* dMemset(void *dst, S32 c, unsigned size)
{
return memset(dst,c,size);
}
//--------------------------------------
S32 dMemcmp(const void *ptr1, const void *ptr2, unsigned len)
{
return memcmp(ptr1, ptr2, len);
}
#ifdef new
#undef new
#endif
//--------------------------------------
void* FN_CDECL operator new(dsize_t, void* ptr)
{
return (ptr);
}
void* dRealMalloc(dsize_t s)
{
return malloc(s);
}
void dRealFree(void* p)
{
free(p);
}

View file

@ -0,0 +1,341 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
// TODO
//#include "platformX86UNIX/platformX86UNIX.h"
#include "platformX86UNIX/x86UNIXMessageBox.h"
#include <X11/Xatom.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Intrinsic.h>
#include <X11/IntrinsicP.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Dialog.h>
#define MaxWinWidth 800
#define MaxWinHeight 600
//------------------------------------------------------------------------------
// XMessageBoxButton
//------------------------------------------------------------------------------
XMessageBoxButton::XMessageBoxButton()
{
dStrcpy(mLabel, "");
mClickVal = -1;
mMB = NULL;
}
//------------------------------------------------------------------------------
XMessageBoxButton::XMessageBoxButton(
const char* label, int clickVal, XMessageBox* mb)
{
dStrncpy(mLabel, label, LabelSize);
mClickVal = clickVal;
mMB = mb;
}
//------------------------------------------------------------------------------
void XMessageBoxButton::dialogCallback(Widget w,
XtPointer client_data,
XtPointer call_data)
{
XMessageBoxButton* button =
reinterpret_cast<XMessageBoxButton*>(client_data);
if (button != NULL)
button->clicked();
XtAppSetExitFlag(XtWidgetToApplicationContext(w));
}
//------------------------------------------------------------------------------
void XMessageBoxButton::clicked()
{
if (mMB)
mMB->setClickedButton(this);
}
//------------------------------------------------------------------------------
// XMessageBox
//------------------------------------------------------------------------------
XMessageBox::XMessageBox()
{
mWindowTitle = "";
mMessage = "";
mWrappedMessage = NULL;
mWrappedMessageSize = 0;
mDisplay = NULL;
mFS = NULL;
mClickedButton = NULL;
}
//------------------------------------------------------------------------------
XMessageBox::~XMessageBox()
{
clearWrappedMessage();
}
//------------------------------------------------------------------------------
int XMessageBox::alertOK(const char *windowTitle, const char *message)
{
mWindowTitle = windowTitle;
mMessage = message;
mButtons.clear();
mButtons.push_back(XMessageBoxButton("OK", OK, this));
int val = show();
if (val == -1)
return OK;
return val;
}
//------------------------------------------------------------------------------
int XMessageBox::alertOKCancel(const char *windowTitle, const char *message)
{
mWindowTitle = windowTitle;
mMessage = message;
mButtons.clear();
mButtons.push_back(XMessageBoxButton("OK", OK, this));
mButtons.push_back(XMessageBoxButton("Cancel", Cancel, this));
int val = show();
if (val == -1)
return Cancel;
return val;
}
//------------------------------------------------------------------------------
int XMessageBox::alertRetryCancel(const char *windowTitle, const char *message)
{
mWindowTitle = windowTitle;
mMessage = message;
mButtons.clear();
mButtons.push_back(XMessageBoxButton("Retry", Retry, this));
mButtons.push_back(XMessageBoxButton("Cancel", Cancel, this));
int val = show();
if (val == -1)
return Cancel;
return val;
}
//------------------------------------------------------------------------------
template <class Type>
static inline Type min(Type v1, Type v2)
{
if (v1 > v2)
return v2;
else
return v1;
}
//------------------------------------------------------------------------------
void XMessageBox::clearWrappedMessage()
{
if (mWrappedMessage != NULL)
{
delete [] mWrappedMessage;
mWrappedMessageSize = 0;
}
}
//------------------------------------------------------------------------------
void XMessageBox::splitMessage()
{
clearWrappedMessage();
if (mMessage == NULL || dStrlen(mMessage)==0)
return;
int numChars = dStrlen(mMessage);
mWrappedMessageSize = (numChars * 2) + 1;
mWrappedMessage = new char[mWrappedMessageSize];
dMemset(mWrappedMessage, 0, mWrappedMessageSize);
int fontDirection, fontAscent, fontDescent;
XCharStruct strInfo;
char *curChar = const_cast<char*>(mMessage);
char *endChar;
char *curWrapped = mWrappedMessage;
int curWidth = 0;
while ( // while pointers are in range...
(curChar - mMessage) < numChars &&
(curWrapped - mWrappedMessage) < mWrappedMessageSize)
{
// look for next space in remaining string
endChar = index(curChar, ' ');
if (endChar == NULL)
endChar = index(curChar, '\0');
if (endChar != NULL)
// increment one char past the space to include it
endChar++;
else
// otherwise, set the endchar to one char ahead
endChar = curChar + 1;
// compute length of substr
int len = endChar - curChar;
XTextExtents(mFS, curChar, len,
&fontDirection, &fontAscent, &fontDescent,
&strInfo);
// if its too big, insert a newline and reset curWidth
if ((curWidth + strInfo.width) > MaxWinWidth)
{
*curWrapped = '\n';
curWrapped++;
curWidth = 0;
}
// copy the current string into curWrapped if we have enough room
int bytesRemaining =
mWrappedMessageSize - (curWrapped - mWrappedMessage);
if (bytesRemaining >= len)
dStrncpy(curWrapped, curChar, len);
curWrapped += len;
curWidth += strInfo.width;
curChar = endChar;
}
// shouldn't be necessary due to the dMemset, but just in case
mWrappedMessage[mWrappedMessageSize-1] = '\0';
}
//------------------------------------------------------------------------------
int XMessageBox::show()
{
Widget toplevel;
int argc = 3;
// this is a hack to specify a target font
char *argv[] = { const_cast<char*>(mWindowTitle),
"-fn", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*" };
// init the top level widget
XtAppContext appContext;
toplevel = XtOpenApplication(&appContext, "", NULL, 0, &argc, argv, NULL,
applicationShellWidgetClass, NULL, 0);
//this is supposed to initialize the toolkit from a pre existing display,
//but I couldn't get it to work.
// XtToolkitInitialize();
// XtAppContext xtAppContext = XtCreateApplicationContext();
// XtAppSetFallbackResources(xtAppContext, fallback) ;
// XtDisplayInitialize(xtAppContext, mDisplay, "", "", NULL, 0,
// &argc, argv);
// // toplevel = XtAppCreateShell("Torque Alert", "", applicationShellWidgetClass,
// // mDisplay, NULL, 0);
// toplevel = XtVaAppCreateShell("", "",
// applicationShellWidgetClass, mDisplay, 0) ;
// set the display member
mDisplay = XtDisplay(toplevel);
// don't map it when managed
XtVaSetValues(toplevel,
XtNmappedWhenManaged, False,
0);
// read the font resource to see what font we got
struct _appRes
{
XFontStruct* font;
} appRes;
XtResource resources[] = {
{
"font", "Font",
XtRFontStruct,
sizeof(XFontStruct*),
XtOffsetOf( struct _appRes, font ),
XtRImmediate, NULL
},
};
XtVaGetApplicationResources( toplevel, (XtPointer)&appRes,
resources, XtNumber(resources), 0 );
mFS = appRes.font;
// set the maximum window dimensions
mScreenWidth = DisplayWidth(mDisplay, DefaultScreen(mDisplay));
mScreenHeight = DisplayHeight(mDisplay, DefaultScreen(mDisplay));
mMaxWindowWidth = min(mScreenWidth, MaxWinWidth);
mMaxWindowHeight = min(mScreenHeight, MaxWinHeight);
// split the message into a vector of lines
splitMessage();
// create the dialog
Widget dialog = XtVaCreateManagedWidget("ok_dialog", dialogWidgetClass,
toplevel, XtNlabel,
mWrappedMessageSize != 0 ? mWrappedMessage : "",
0);
Vector<XMessageBoxButton>::iterator iter;
for (iter = mButtons.begin(); iter != mButtons.end(); ++iter)
{
XawDialogAddButton(dialog, iter->getLabel(),
iter->dialogCallback, iter);
}
XtRealizeWidget(toplevel);
// XChangeProperty(mDisplay, XtWindow(toplevel),
// XInternAtom(mDisplay, "WM_TRANSIENT_FOR", False),
// XA_ATOM, 32, PropModeAppend,
// NULL, 0);
// set the x, y position to center of display
Position x, y;
Dimension width, height;
XtVaGetValues(toplevel, XtNx, &x, XtNy, &y,
XtNwidth, &width, XtNheight, &height, 0);
x = (mScreenWidth - width) / 2;
y = (mScreenHeight - height) / 2;
XtVaSetValues(toplevel, XtNx, x, XtNy, y, 0);
// initialize wm_protocols, so that we can respond to window destroyed
// message
Atom wm_delete_window =
XInternAtom(mDisplay, "WM_DELETE_WINDOW", False);
Atom wm_protocols =
XInternAtom(mDisplay, "WM_PROTOCOLS", False);
XSetWMProtocols (mDisplay, XtWindow(toplevel),
&wm_delete_window, 1);
XSetWindowAttributes xattr;
xattr.override_redirect = True;
// XChangeWindowAttributes(mDisplay, XtWindow(toplevel),
// CWOverrideRedirect, &xattr);
// show the widget
XtMapWidget(toplevel);
XRaiseWindow(mDisplay, XtWindow(toplevel));
// do event loop
XEvent event;
while (!XtAppGetExitFlag(appContext))
{
XtAppNextEvent(appContext, &event);
if (event.type == ClientMessage &&
event.xclient.message_type == wm_protocols &&
event.xclient.data.l[0] == static_cast<long>(wm_delete_window))
XtAppSetExitFlag(appContext);
XtDispatchEvent(&event);
}
XtUnrealizeWidget(toplevel);
XtDestroyWidget(dialog);
XtDestroyWidget(toplevel);
XtDestroyApplicationContext(appContext);
// return the clicked val if we have one
if (mClickedButton != NULL)
return mClickedButton->getClickVal();
else
return -1;
}

View file

@ -0,0 +1,78 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIXMESSAGEBOX_H_
#define _X86UNIXMESSAGEBOX_H_
#include "core/tVector.h"
#include <X11/Intrinsic.h>
class XMessageBox;
//------------------------------------------------------------------------------
class XMessageBoxButton
{
public:
XMessageBoxButton();
XMessageBoxButton(const char* label, int clickVal, XMessageBox* mb);
const char *getLabel() { return static_cast<const char*>(mLabel); }
int getClickVal() { return mClickVal; }
void clicked();
static void dialogCallback(Widget w,
XtPointer client_data,
XtPointer call_data);
private:
static const int LabelSize = 100;
char mLabel[LabelSize];
int mClickVal;
XMessageBox *mMB;
};
//------------------------------------------------------------------------------
class XMessageBox
{
public:
static const int OK = 4;
static const int Cancel = 5;
static const int Retry = 6;
XMessageBox();
~XMessageBox();
int alertOK(const char *windowTitle, const char *message);
int alertOKCancel(const char *windowTitle, const char *message);
int alertRetryCancel(const char *windowTitle, const char *message);
static void onWMProtocols();
void setClickedButton(XMessageBoxButton* clickedButton)
{
mClickedButton = clickedButton;
}
private:
int show();
void splitMessage();
void clearWrappedMessage();
XMessageBoxButton* mClickedButton;
const char* mMessage;
const char* mWindowTitle;
char* mWrappedMessage;
int mWrappedMessageSize;
Vector<XMessageBoxButton> mButtons;
Display* mDisplay;
XFontStruct* mFS;
int mScreenWidth, mScreenHeight, mMaxWindowWidth, mMaxWindowHeight;
};
#endif // #define _X86UNIXMESSAGEBOX_H_

View file

@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformMutex.h"
#include <pthread.h>
void * Mutex::createMutex()
{
pthread_mutex_t *mutex;
mutex = (pthread_mutex_t *) dRealMalloc(sizeof(pthread_mutex_t));
pthread_mutex_init(mutex, NULL);
return((void*)mutex);
}
void Mutex::destroyMutex(void * mutex)
{
AssertFatal(mutex, "Mutex::destroyMutex: invalid mutex");
pthread_mutex_destroy((pthread_mutex_t *)mutex);
delete mutex;
}
void Mutex::lockMutex(void * mutex)
{
AssertFatal(mutex, "Mutex::lockMutex: invalid mutex");
pthread_mutex_lock((pthread_mutex_t *)mutex);
}
void Mutex::unlockMutex(void * mutex)
{
AssertFatal(mutex, "Mutex::unlockMutex: invalid mutex");
pthread_mutex_unlock((pthread_mutex_t *)mutex);
}

View file

@ -0,0 +1,26 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIXMUTEX_H_
#define _X86UNIXMUTEX_H_
// A process-shared mutex class, used by Platform::excludeOtherInstances()
class ProcessMutex
{
public:
ProcessMutex();
~ProcessMutex();
bool acquire(const char *mutexName);
void release();
private:
int mFD;
static const int LockFileNameSize=256;
char mLockFileName[LockFileNameSize];
};
#endif

View file

@ -0,0 +1,782 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platform.h"
#include "platform/event.h"
//#include <winsock.h>
//#include <wsipx.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
/* for PROTO_IPX */
#include <net/if_ppp.h>
#include <netipx/ipx.h>
#include <stdlib.h>
#include "console/console.h"
#include "platform/gameInterface.h"
#include "core/fileStream.h"
struct NameLookup
{
struct hostent *hostEnt;
int socket;
U16 port;
NameLookup *nextLookup;
};
static NameLookup *lookupList = NULL;
// process receives data and posts it to the game.
static Net::Error getLastError();
static S32 defaultPort = 28000;
static S32 netPort = 0;
static int ipxSocket = NULL;
static int udpSocket = NULL;
enum {
MaxConnections = 1024,
};
/*
HWND winsockWindow = NULL;
static LRESULT PASCAL WinsockProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
U32 error;
U32 bufLen;
U32 event;
SOCKET socket;
Net::Error err;
S32 bytesRead;
static ConnectedNotifyEvent notifyEvent;
static ConnectedReceiveEvent receiveEvent;
static ConnectedAcceptEvent acceptEvent;
switch(message)
{
case WM_USER:
error = WSAGETSELECTERROR(lParam);
event = WSAGETSELECTEVENT(lParam);
socket = wParam;
switch(event)
{
case FD_READ:
err = Net::recv(socket, receiveEvent.data, MaxPacketDataSize, &bytesRead);
if(err == Net::NoError && bytesRead != 0)
{
receiveEvent.tag = socket;
receiveEvent.size = ConnectedReceiveEventHeaderSize + bytesRead;
Game->postEvent(receiveEvent);
}
break;
case FD_CONNECT:
notifyEvent.tag = socket;
if(error)
notifyEvent.state = ConnectedNotifyEvent::ConnectFailed;
else
notifyEvent.state = ConnectedNotifyEvent::Connected;
Game->postEvent(notifyEvent);
break;
case FD_CLOSE:
// see first if there is anything to read:
for(;;)
{
err = Net::recv(socket, receiveEvent.data, MaxPacketDataSize, &bytesRead);
if(err != Net::NoError || bytesRead == 0)
break;
receiveEvent.tag = socket;
receiveEvent.size = ConnectedReceiveEventHeaderSize + bytesRead;
Game->postEvent(receiveEvent);
}
notifyEvent.tag = socket;
notifyEvent.state = ConnectedNotifyEvent::Disconnected;
Game->postEvent(notifyEvent);
break;
case FD_ACCEPT:
acceptEvent.portTag = socket;
acceptEvent.connectionTag = Net::accept(socket, &acceptEvent.address);
if(acceptEvent.connectionTag != InvalidSocket)
{
Net::setBlocking(acceptEvent.connectionTag, false);
WSAAsyncSelect(acceptEvent.connectionTag, winsockWindow, WM_USER, FD_READ | FD_CONNECT | FD_CLOSE);
Game->postEvent(acceptEvent);
}
break;
}
break;
case WM_USER + 1:
error = WSAGETASYNCERROR(lParam);
bufLen = WSAGETASYNCBUFLEN(lParam);
HANDLE handle;
handle = HANDLE(wParam);
NameLookup **walk;
for(walk = &lookupList; *walk; walk = &((*walk)->nextLookup))
{
if((*walk)->lookupHandle == handle)
{
NameLookup *temp = *walk;
struct hostent *hp = (struct hostent *) temp->hostEntStruct;
SOCKADDR_IN ipAddr;
memcpy(&ipAddr.sin_addr.s_addr, hp->h_addr, sizeof(IN_ADDR));
ipAddr.sin_port = temp->port;
ipAddr.sin_family = AF_INET;
notifyEvent.tag = temp->socket;
bool wserr = ::connect(temp->socket, (PSOCKADDR) &ipAddr, sizeof(ipAddr)); // always errors out
if(wserr && WSAGetLastError() != WSAEWOULDBLOCK)
{
notifyEvent.state = ConnectedNotifyEvent::DNSFailed;
::closesocket(temp->socket);
}
else
{
WSAAsyncSelect(temp->socket, winsockWindow, WM_USER, FD_READ | FD_CONNECT | FD_CLOSE);
notifyEvent.state = ConnectedNotifyEvent::DNSResolved;
}
Game->postEvent(notifyEvent);
*walk = temp->nextLookup;
delete temp;
break;
}
}
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
*/
bool Net::init()
{
/* nothing to do */
}
void Net::shutdown()
{
while (lookupList)
{
NameLookup *temp = lookupList;
lookupList = temp->nextLookup;
delete temp;
}
closePort();
}
static void netToIPSocketAddress(const NetAddress *address, struct sockaddr_in *sockAddr)
{
dMemset(sockAddr, 0, sizeof(struct sockaddr_in));
sockAddr->sin_family = AF_INET;
sockAddr->sin_port = htons(address->port);
char tAddr[20];
sprintf(tAddr, "%d.%d.%d.%d\n", address->netNum[0], address->netNum[1], address->netNum[2], address->netNum[3]);
//fprintf(stdout,"netToIPSocketAddress(): %s\n",tAddr);fflush(NULL);
sockAddr->sin_addr.s_addr = inet_addr(tAddr);
// sockAddr->sin_addr.s_addr = address->netNum[0]; // hopefully this will work.
}
static void IPSocketToNetAddress(const struct sockaddr_in *sockAddr, NetAddress *address)
{
address->type = NetAddress::IPAddress;
address->port = htons(sockAddr->sin_port);
char *tAddr;
tAddr = inet_ntoa(sockAddr->sin_addr);
//fprintf(stdout,"IPSocketToNetAddress(): %s\n",tAddr);fflush(NULL);
U8 nets[4];
nets[0] = atoi(strtok(tAddr, "."));
nets[1] = atoi(strtok(NULL, "."));
nets[2] = atoi(strtok(NULL, "."));
nets[3] = atoi(strtok(NULL, "."));
//fprintf(stdout,"0 = %d, 1 = %d, 2 = %d, 3 = %d\n", nets[0], nets[1], nets[2], nets[3]);
address->netNum[0] = nets[0];
address->netNum[1] = nets[1];
address->netNum[2] = nets[2];
address->netNum[3] = nets[3];
}
static void netToIPXSocketAddress(const NetAddress *address, sockaddr_ipx *sockAddr)
{
dMemset(sockAddr, 0, sizeof(sockaddr_ipx));
sockAddr->sipx_family = AF_INET;
sockAddr->sipx_port = htons(address->port);
sockAddr->sipx_network = address->netNum[0];
sockAddr->sipx_node[0] = address->nodeNum[0];
sockAddr->sipx_node[1] = address->nodeNum[1];
sockAddr->sipx_node[2] = address->nodeNum[2];
sockAddr->sipx_node[3] = address->nodeNum[3];
sockAddr->sipx_node[4] = address->nodeNum[4];
sockAddr->sipx_node[5] = address->nodeNum[5];
}
static void IPXSocketToNetAddress(const sockaddr_ipx *sockAddr, NetAddress *address)
{
address->type = NetAddress::IPXAddress;
address->port = htons(sockAddr->sipx_port);
address->netNum[0] = sockAddr->sipx_network;
address->nodeNum[0] = sockAddr->sipx_node[0];
address->nodeNum[1] = sockAddr->sipx_node[1];
address->nodeNum[2] = sockAddr->sipx_node[2];
address->nodeNum[3] = sockAddr->sipx_node[3];
address->nodeNum[4] = sockAddr->sipx_node[4];
address->nodeNum[5] = sockAddr->sipx_node[5];
}
NetSocket Net::openListenPort(U16 port)
{
if(Game->isJournalReading())
{
U32 ret;
Game->journalRead(&ret);
return NetSocket(ret);
}
NetSocket sock = openSocket();
fd_set sockFDSet;
FD_ZERO(&sockFDSet);
FD_SET(sock, &sockFDSet);
bind(sock, port);
listen(sock, 4);
setBlocking(sock, false);
if (select(sock, &sockFDSet, &sockFDSet, &sockFDSet, NULL) == -1)
Con::printf("Error: error in select()\n");
if (Game->isJournalWriting())
Game->journalWrite(U32(sock));
return sock;
}
NetSocket Net::openConnectTo(const char *addressString)
{
if(!dStrnicmp(addressString, "ipx:", 4))
return InvalidSocket;
if(!dStrnicmp(addressString, "ip:", 3))
addressString += 3; // eat off the ip:
char remoteAddr[256];
dStrcpy(remoteAddr, addressString);
char *portString = dStrchr(remoteAddr, ':');
U16 port;
if(portString)
{
*portString++ = 0;
port = htons(dAtoi(portString));
}
else
port = htons(defaultPort);
if(!dStricmp(remoteAddr, "broadcast"))
return InvalidSocket;
if(Game->isJournalReading())
{
U32 ret;
Game->journalRead(&ret);
return NetSocket(ret);
}
NetSocket sock = openSocket();
setBlocking(sock, false);
sockaddr_in ipAddr;
ipAddr.sin_addr.s_addr = inet_addr(remoteAddr);
if(ipAddr.sin_addr.s_addr != INADDR_NONE)
{
ipAddr.sin_port = port;
ipAddr.sin_family = AF_INET;
if(::connect(sock, (struct sockaddr *)&ipAddr, sizeof(ipAddr)) == -1)
{
Con::printf("Couldn't connect()");
::close(sock);
sock = InvalidSocket;
}
if(sock != InvalidSocket) {
fd_set sockFDSet;
FD_ZERO(&sockFDSet);
FD_SET(sock, &sockFDSet);
select(sock, &sockFDSet, &sockFDSet, &sockFDSet, NULL);
}
}
else
{
NameLookup *lookup = new NameLookup;
lookup->socket = sock;
lookup->port = port;
lookup->hostEnt = gethostbyname(remoteAddr);
if(lookup->hostEnt == NULL)
{
delete lookup;
::close(sock);
sock = InvalidSocket;
}
else
{
lookup->nextLookup = lookupList;
lookupList = lookup;
}
}
if(Game->isJournalWriting())
Game->journalWrite(U32(sock));
return sock;
}
void Net::closeConnectTo(NetSocket sock)
{
if(Game->isJournalReading())
return;
for(NameLookup **walk = &lookupList; *walk; walk = &((*walk)->nextLookup) )
{
NameLookup *lookup = *walk;
if(lookup->socket == sock)
{
close(lookup->socket);
*walk = lookup->nextLookup;
delete lookup;
return;
}
}
close(sock);
}
Net::Error Net::sendtoSocket(NetSocket socket, const U8 *buffer, int bufferSize)
{
if(Game->isJournalReading())
{
U32 e;
Game->journalRead(&e);
return (Net::Error) e;
}
Net::Error e = send(socket, buffer, bufferSize);
if(Game->isJournalWriting())
Game->journalWrite(U32(e));
return e;
}
bool Net::openPort(S32 port)
{
if(udpSocket != InvalidSocket)
close(udpSocket);
if(ipxSocket != InvalidSocket)
close(ipxSocket);
udpSocket = socket(AF_INET, SOCK_DGRAM, 0);
ipxSocket = socket(AF_IPX, SOCK_DGRAM, 0);
if(udpSocket != InvalidSocket)
{
Net::Error error;
error = bind(udpSocket, port);
if(error == NoError)
error = setBufferSize(udpSocket, 32768);
if(error == NoError)
error = setBroadcast(udpSocket, true);
if(error == NoError)
error = setBlocking(udpSocket, false);
if(error == NoError)
Con::printf("UDP initialized on port %d", port);
else
{
close(udpSocket);
udpSocket = InvalidSocket;
Con::printf("Unable to initialize UDP - error %d", error);
}
}
if(ipxSocket != InvalidSocket)
{
Net::Error error = NoError;
sockaddr_ipx ipxAddress;
memset((char *)&ipxAddress, 0, sizeof(ipxAddress));
ipxAddress.sipx_family = AF_IPX;
ipxAddress.sipx_port = htons(port);
S32 err = ::bind(ipxSocket, (struct sockaddr *)&ipxAddress, sizeof(ipxAddress));
if(err)
error = getLastError();
if(error == NoError)
error = setBufferSize(ipxSocket, 32768);
if(error == NoError)
error = setBroadcast(ipxSocket, true);
if(error == NoError)
error = setBlocking(ipxSocket, false);
if(error == NoError)
Con::printf("IPX initialized on port %d", port);
else
{
close(ipxSocket);
ipxSocket = InvalidSocket;
Con::printf("Unable to initialize IPX - error %d", error);
}
}
netPort = port;
return ipxSocket != InvalidSocket || udpSocket != InvalidSocket;
}
void Net::closePort()
{
if(ipxSocket != InvalidSocket)
close(ipxSocket);
if(udpSocket != InvalidSocket)
close(udpSocket);
}
Net::Error Net::sendto(const NetAddress *address, const U8 *buffer, S32 bufferSize)
{
if(Game->isJournalReading())
return NoError;
if(address->type == NetAddress::IPXAddress)
{
sockaddr_ipx ipxAddr;
netToIPXSocketAddress(address, &ipxAddr);
if(::sendto(ipxSocket, (const char*)buffer, bufferSize, 0,
(sockaddr *) &ipxAddr, sizeof(sockaddr_ipx)) == -1)
return getLastError();
else
return NoError;
}
else
{
sockaddr_in ipAddr;
netToIPSocketAddress(address, &ipAddr);
if(::sendto(udpSocket, (const char*)buffer, bufferSize, 0,
(sockaddr *) &ipAddr, sizeof(sockaddr_in)) == -1)
return getLastError();
else
return NoError;
}
}
void Net::process()
{
sockaddr sa;
PacketReceiveEvent receiveEvent;
for(;;)
{
S32 addrLen = sizeof(sa);
S32 bytesRead = -1;
if(udpSocket != InvalidSocket)
bytesRead = recvfrom(udpSocket, (char *) receiveEvent.data, MaxPacketDataSize, 0, &sa, &addrLen);
if(bytesRead == -1 && ipxSocket != InvalidSocket)
{
addrLen = sizeof(sa);
bytesRead = recvfrom(ipxSocket, (char *) receiveEvent.data, MaxPacketDataSize, 0, &sa, &addrLen);
}
if(bytesRead == -1)
break;
if(sa.sa_family == AF_INET)
IPSocketToNetAddress((sockaddr_in *) &sa, &receiveEvent.sourceAddress);
else if(sa.sa_family == AF_IPX)
IPXSocketToNetAddress((sockaddr_ipx *) &sa, &receiveEvent.sourceAddress);
else
continue;
NetAddress &na = receiveEvent.sourceAddress;
if(na.type == NetAddress::IPAddress &&
na.netNum[0] == 127 &&
na.netNum[1] == 0 &&
na.netNum[2] == 0 &&
na.netNum[3] == 1 &&
na.port == netPort)
continue;
if(bytesRead <= 0)
continue;
receiveEvent.size = PacketReceiveEventHeaderSize + bytesRead;
Game->postEvent(receiveEvent);
}
}
NetSocket Net::openSocket()
{
int retSocket;
retSocket = socket(AF_INET, SOCK_STREAM, 0);
if(retSocket == InvalidSocket)
return InvalidSocket;
else
return retSocket;
}
Net::Error Net::closeSocket(NetSocket socket)
{
if(socket != InvalidSocket)
{
if(!close(socket))
return NoError;
else
return getLastError();
}
else
return NotASocket;
}
Net::Error Net::connect(NetSocket socket, const NetAddress *address)
{
if(address->type != NetAddress::IPAddress)
return WrongProtocolType;
sockaddr_in socketAddress;
netToIPSocketAddress(address, &socketAddress);
if(!::connect(socket, (sockaddr *) &socketAddress, sizeof(socketAddress)))
return NoError;
return getLastError();
}
Net::Error Net::listen(NetSocket socket, S32 backlog)
{
if(!::listen(socket, backlog))
return NoError;
return getLastError();
}
NetSocket Net::accept(NetSocket acceptSocket, NetAddress *remoteAddress)
{
sockaddr_in socketAddress;
S32 addrLen = sizeof(socketAddress);
int retVal = ::accept(acceptSocket, (sockaddr *) &socketAddress, &addrLen);
if(retVal != InvalidSocket)
{
IPSocketToNetAddress(&socketAddress, remoteAddress);
return retVal;
}
return InvalidSocket;
}
Net::Error Net::bind(NetSocket socket, U16 port)
{
S32 error;
sockaddr_in socketAddress;
dMemset((char *)&socketAddress, 0, sizeof(socketAddress));
socketAddress.sin_family = AF_INET;
// It's entirely possible that there are two NIC cards.
// We let the user specify which one the server runs on.
// thanks to [TPG]P1aGu3 for the name
const char* serverIP = Con::getVariable( "Host::BindAddress" );
// serverIP is guaranteed to be non-0.
AssertFatal( serverIP, "serverIP is NULL!" );
if( serverIP[0] != '\0' ) {
// we're not empty
socketAddress.sin_addr.s_addr = inet_addr( serverIP );
if( socketAddress.sin_addr.s_addr != INADDR_NONE ) {
Con::printf( "Binding server port to %s", serverIP );
} else {
Con::warnf( ConsoleLogEntry::General,
"inet_addr() failed for %s while binding!",
serverIP );
socketAddress.sin_addr.s_addr = INADDR_ANY;
}
} else {
Con::printf( "Binding server port to default IP" );
socketAddress.sin_addr.s_addr = INADDR_ANY;
}
socketAddress.sin_port = htons(port);
error = ::bind(socket, (sockaddr *) &socketAddress, sizeof(socketAddress));
if(!error)
return NoError;
return getLastError();
}
Net::Error Net::setBufferSize(NetSocket socket, S32 bufferSize)
{
S32 error;
error = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char *) &bufferSize, sizeof(bufferSize));
if(!error)
error = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, (char *) &bufferSize, sizeof(bufferSize));
if(!error)
return NoError;
return getLastError();
}
Net::Error Net::setBroadcast(NetSocket socket, bool broadcast)
{
S32 bc = broadcast;
S32 error = setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (char*)&bc, sizeof(bc));
if(!error)
return NoError;
return getLastError();
}
Net::Error Net::setBlocking(NetSocket socket, bool blockingIO)
{
int notblock = !blockingIO;
S32 error = ioctl(socket, FIONBIO, &notblock);
if(!error)
return NoError;
return getLastError();
}
Net::Error Net::send(NetSocket socket, const U8 *buffer, S32 bufferSize)
{
S32 error = ::send(socket, (const char*)buffer, bufferSize, 0);
if(!error)
return NoError;
return getLastError();
}
Net::Error Net::recv(NetSocket socket, U8 *buffer, S32 bufferSize, S32 *bytesRead)
{
*bytesRead = ::recv(socket, (char*)buffer, bufferSize, 0);
if(*bytesRead == -1)
return getLastError();
return NoError;
}
bool Net::compareAddresses(const NetAddress *a1, const NetAddress *a2)
{
if((a1->type != a2->type) ||
(*((U32 *)a1->netNum) != *((U32 *)a2->netNum)) ||
(a1->port != a2->port))
return false;
if(a1->type == NetAddress::IPAddress)
return true;
for(S32 i = 0; i < 6; i++)
if(a1->nodeNum[i] != a2->nodeNum[i])
return false;
return true;
}
bool Net::stringToAddress(const char *addressString, NetAddress *address)
{
if(dStrnicmp(addressString, "ipx:", 4))
{
// assume IP if it doesn't have ipx: at the front.
if(!dStrnicmp(addressString, "ip:", 3))
addressString += 3; // eat off the ip:
sockaddr_in ipAddr;
char remoteAddr[256];
if(strlen(addressString) > 255)
return false;
dStrcpy(remoteAddr, addressString);
char *portString = dStrchr(remoteAddr, ':');
if(portString)
*portString++ = 0;
struct hostent *hp;
if(!dStricmp(remoteAddr, "broadcast"))
ipAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
else
{
ipAddr.sin_addr.s_addr = inet_addr(remoteAddr);
if(ipAddr.sin_addr.s_addr == INADDR_NONE)
{
if((hp = gethostbyname(remoteAddr)) == NULL)
return false;
else
memcpy(&ipAddr.sin_addr.s_addr, hp->h_addr, sizeof(in_addr));
}
}
if(portString)
ipAddr.sin_port = htons(dAtoi(portString));
else
ipAddr.sin_port = htons(defaultPort);
ipAddr.sin_family = AF_INET;
IPSocketToNetAddress(&ipAddr, address);
return true;
}
else
{
S32 i;
S32 port;
address->type = NetAddress::IPXAddress;
for(i = 0; i < 6; i++)
address->nodeNum[i] = 0xFF;
// it's an IPX string
addressString += 4;
if(!dStricmp(addressString, "broadcast"))
{
address->port = defaultPort;
return true;
}
else if(sscanf(addressString, "broadcast:%d", &port) == 1)
{
address->port = port;
return true;
}
else
{
S32 nodeNum[6];
S32 netNum[4];
S32 count = dSscanf(addressString, "%2x%2x%2x%2x:%2x%2x%2x%2x%2x%2x:%d",
&netNum[0], &netNum[1], &netNum[2], &netNum[3],
&nodeNum[0], &nodeNum[1], &nodeNum[2], &nodeNum[3], &nodeNum[4], &nodeNum[5],
&port);
if(count == 10)
{
port = defaultPort;
count++;
}
if(count != 11)
return false;
for(i = 0; i < 6; i++)
address->nodeNum[i] = nodeNum[i];
for(i = 0; i < 4; i++)
address->netNum[i] = netNum[i];
address->port = port;
return true;
}
}
}
void Net::addressToString(const NetAddress *address, char addressString[256])
{
if(address->type == NetAddress::IPAddress)
{
sockaddr_in ipAddr;
netToIPSocketAddress(address, &ipAddr);
if(ipAddr.sin_addr.s_addr == htonl(INADDR_BROADCAST))
dSprintf(addressString, 256, "IP:Broadcast:%d", ntohs(ipAddr.sin_port));
else
dSprintf(addressString, 256, "IP:%s:%d", inet_ntoa(ipAddr.sin_addr),
ntohs(ipAddr.sin_port));
// dSprintf(addressString, 256, "IP:%d:%d", ipAddr.sin_addr.s_addr,
// ntohs(ipAddr.sin_port));
}
else
{
dSprintf(addressString, 256, "IPX:%.2X%.2X%.2X%.2X:%.2X%.2X%.2X%.2X%.2X%.2X:%d",
address->netNum[0], address->netNum[1], address->netNum[2], address->netNum[3],
address->nodeNum[0], address->nodeNum[1], address->nodeNum[2], address->nodeNum[3], address->nodeNum[4], address->nodeNum[5],
address->port);
}
}
Net::Error getLastError()
{
return Net::UnknownError;
}

View file

@ -0,0 +1,613 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
//#include "console/ast.h"
#include "console/console.h"
//#include "console/consoleInternal.h"
//#include "core/fileStream.h"
//#include "math/mPoint.h"
#include "platformX86UNIX/platformGL.h"
#include "platform/event.h"
#include "platform/gameInterface.h"
#include "platformX86UNIX/x86UNIXOGLVideo.h"
#include "platform/platformAudio.h"
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
/* our windowing/gl vars */
GLXContext ctx;
Display *display;
int screen_num;
Window win;
Screen *screen_ptr;
//------------------------------------------------------------------------------
bool OpenGLDevice::smCanSwitchBitDepth = true;
//------------------------------------------------------------------------------
OpenGLDevice::OpenGLDevice()
{
initDevice();
}
//------------------------------------------------------------------------------
void OpenGLDevice::initDevice()
{
// Set the device name:
mDeviceName = "OpenGL";
// Set some initial conditions:
mResolutionList.clear();
Resolution newRes( 640, 480, 32 );
mResolutionList.push_back( newRes );
return;
/*
// Enumerate all available resolutions:
DEVMODE devMode;
U32 modeNum = 0;
U32 stillGoing = true;
while ( stillGoing )
{
dMemset( &devMode, 0, sizeof( devMode ) );
devMode.dmSize = sizeof( devMode );
stillGoing = EnumDisplaySettings( NULL, modeNum++, &devMode );
if ( devMode.dmPelsWidth >= 640 && devMode.dmPelsHeight >= 480
&& ( devMode.dmBitsPerPel == 16 || devMode.dmBitsPerPel == 32 ) &&
( smCanSwitchBitDepth || devMode.dmBitsPerPel == winState.desktopBitsPixel ) )
{
// Only add this resolution if it is not already in the list:
bool alreadyInList = false;
for ( U32 i = 0; i < mResolutionList.size(); i++ )
{
if ( devMode.dmPelsWidth == mResolutionList[i].w
&& devMode.dmPelsHeight == mResolutionList[i].h
&& devMode.dmBitsPerPel == mResolutionList[i].bpp )
{
alreadyInList = true;
break;
}
}
if ( !alreadyInList )
{
Resolution newRes( devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel );
mResolutionList.push_back( newRes );
}
}
}
*/
}
//------------------------------------------------------------------------------
bool OpenGLDevice::activate( U32 width, U32 height, U32 bpp, bool fullScreen )
{
Con::printf( "Activating the OpenGL display device..." );
bool needResurrect = false;
// If the rendering context exists, delete it:
if ( ctx )
{
Con::printf( "Killing the texture manager..." );
Game->textureKill();
needResurrect = true;
Con::printf( "Making the rendering context not current..." );
if ( !glXMakeCurrent(display, None, NULL) )
{
AssertFatal( false, "OpenGLDevice::activate\nglXMakeCurrent(display, None, NULL) failed!" );
return false;
}
Con::printf( "Deleting the rendering context ..." );
glXDestroyContext(display, ctx);
ctx = NULL;
}
// GLX attributes
static int attr[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None };
// create a GLX instance
Con::printf(" Creating a new rendering context..." );
XVisualInfo *vi = glXChooseVisual(display, screen_num, attr);
ctx = glXCreateContext(display, vi, 0, GL_TRUE);
// attach the GLX context to the window
glXMakeCurrent(display, win, ctx);
// Output some driver info to the console:
const char* vendorString = (const char*) glGetString( GL_VENDOR );
const char* rendererString = (const char*) glGetString( GL_RENDERER );
const char* versionString = (const char*) glGetString( GL_VERSION );
Con::printf( "OpenGL driver information:" );
if ( vendorString )
Con::printf( " Vendor: %s", vendorString );
if ( rendererString )
Con::printf( " Renderer: %s", rendererString );
if ( versionString )
Con::printf( " Version: %s", versionString );
if ( needResurrect )
{
// Reload the textures:
Con::printf( "Resurrecting the texture manager..." );
Game->textureResurrect();
}
QGL_EXT_Init();
return true;
}
//------------------------------------------------------------------------------
void OpenGLDevice::shutdown()
{
Con::printf( "Shutting down the OpenGL display device..." );
if ( ctx )
{
Con::printf( "Making the GL rendering context not current..." );
if ( !glXMakeCurrent(display, None, NULL) )
{
AssertFatal( false, "OpenGLDevice::activate\nglXMakeCurrent(display, None, NULL) failed!" );
return;
}
Con::printf( "Deleting the rendering context ..." );
glXDestroyContext(display, ctx);
ctx = NULL;
}
// if ( smIsFullScreen )
// {
// Con::printf( "Restoring the desktop display settings (%dx%dx%d)...", winState.desktopWidth, winState.desktopHeight, winState.desktopBitsPixel );
// ChangeDisplaySettings( NULL, 0 );
// }
}
//------------------------------------------------------------------------------
// This is the real workhorse function of the DisplayDevice...
//
bool OpenGLDevice::setScreenMode( U32 width, U32 height, U32 bpp, bool fullScreen, bool forceIt, bool repaint )
{
#if 0
HWND curtain = NULL;
char errorMessage[256];
Resolution newRes( width, height, bpp );
bool newFullScreen = fullScreen;
bool safeModeOn = Con::getBoolVariable( "$pref::Video::safeModeOn" );
if ( !newFullScreen && mFullScreenOnly )
{
Con::warnf( ConsoleLogEntry::General, "OpenGLDevice::setScreenMode - device or desktop color depth does not allow windowed mode!" );
newFullScreen = true;
}
if ( !newFullScreen && ( newRes.w >= winState.desktopWidth || newRes.h >= winState.desktopHeight ) )
{
Con::warnf( ConsoleLogEntry::General, "OpenGLDevice::setScreenMode -- can't switch to resolution larger than desktop in windowed mode!" );
// Find the largest standard resolution that will fit on the desktop:
U32 resIndex;
for ( resIndex = mResolutionList.size() - 1; resIndex > 0; resIndex-- )
{
if ( mResolutionList[resIndex].w < winState.desktopWidth
&& mResolutionList[resIndex].h < winState.desktopHeight )
break;
}
newRes = mResolutionList[resIndex];
}
if ( newRes.w < 640 || newRes.h < 480 )
{
Con::warnf( ConsoleLogEntry::General, "OpenGLDevice::setScreenMode -- can't go smaller than 640x480!" );
return false;
}
if ( newFullScreen )
{
if (newRes.bpp != 16 && mFullScreenOnly)
newRes.bpp = 16;
// Match the new resolution to one in the list:
U32 resIndex = 0;
U32 bestScore = 0, thisScore = 0;
for ( int i = 0; i < mResolutionList.size(); i++ )
{
if ( newRes == mResolutionList[i] )
{
resIndex = i;
break;
}
else
{
thisScore = abs( S32( newRes.w ) - S32( mResolutionList[i].w ) )
+ abs( S32( newRes.h ) - S32( mResolutionList[i].h ) )
+ ( newRes.bpp == mResolutionList[i].bpp ? 0 : 1 );
if ( !bestScore || ( thisScore < bestScore ) )
{
bestScore = thisScore;
resIndex = i;
}
}
}
newRes = mResolutionList[resIndex];
}
else
{
// Basically ignore the bit depth parameter:
newRes.bpp = winState.desktopBitsPixel;
}
// Return if already at this resolution:
if ( !forceIt && newRes == smCurrentRes && newFullScreen == smIsFullScreen )
return true;
Con::printf( "Setting screen mode to %dx%dx%d (%s)...", newRes.w, newRes.h, newRes.bpp, ( newFullScreen ? "fs" : "w" ) );
bool needResurrect = false;
if ( ( newRes.bpp != smCurrentRes.bpp ) || ( safeModeOn && ( ( smIsFullScreen != newFullScreen ) || newFullScreen ) ) )
{
// Delete the rendering context:
if ( winState.hGLRC )
{
if (!Video::smNeedResurrect)
{
Con::printf( "Killing the texture manager..." );
Game->textureKill();
needResurrect = true;
}
Con::printf( "Making the rendering context not current..." );
if ( !qwglMakeCurrent( NULL, NULL ) )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nqwglMakeCurrent( NULL, NULL ) failed!" );
return false;
}
Con::printf( "Deleting the rendering context..." );
if ( Con::getBoolVariable("$pref::Video::deleteContext",true) &&
!qwglDeleteContext( winState.hGLRC ) )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nqwglDeleteContext failed!" );
return false;
}
winState.hGLRC = NULL;
}
// Release the device context:
if ( winState.appDC )
{
Con::printf( "Releasing the device context..." );
ReleaseDC( winState.appWindow, winState.appDC );
winState.appDC = NULL;
}
// Destroy the window:
if ( winState.appWindow )
{
Con::printf( "Destroying the window..." );
DestroyWindow( winState.appWindow );
winState.appWindow = NULL;
}
}
else if ( smIsFullScreen != newFullScreen )
{
// Change the window style:
Con::printf( "Changing the window style..." );
S32 windowStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
if ( newFullScreen )
windowStyle |= ( WS_POPUP | WS_MAXIMIZE );
else
windowStyle |= ( WS_OVERLAPPED | WS_CAPTION );
if ( !SetWindowLong( winState.appWindow, GWL_STYLE, windowStyle ) )
Con::errorf( "SetWindowLong failed to change the window style!" );
}
U32 test;
if ( newFullScreen )
{
// Change the display settings:
DEVMODE devMode;
dMemset( &devMode, 0, sizeof( devMode ) );
devMode.dmSize = sizeof( devMode );
devMode.dmPelsWidth = newRes.w;
devMode.dmPelsHeight = newRes.h;
devMode.dmBitsPerPel = newRes.bpp;
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
Con::printf( "Changing the display settings to %dx%dx%d...", newRes.w, newRes.h, newRes.bpp );
curtain = CreateCurtain( newRes.w, newRes.h );
test = ChangeDisplaySettings( &devMode, CDS_FULLSCREEN );
if ( test != DISP_CHANGE_SUCCESSFUL )
{
smIsFullScreen = false;
Con::setBoolVariable( "$pref::Video::fullScreen", false );
ChangeDisplaySettings( NULL, 0 );
Con::errorf( ConsoleLogEntry::General, "OpenGLDevice::setScreenMode - ChangeDisplaySettings failed." );
switch( test )
{
case DISP_CHANGE_RESTART:
Platform::AlertOK( "Display Change Failed", "You must restart your machine to get the specified mode." );
break;
case DISP_CHANGE_BADMODE:
Platform::AlertOK( "Display Change Failed", "The specified mode is not supported by this device." );
break;
default:
Platform::AlertOK( "Display Change Failed", "Hardware failed to switch to the specified mode." );
break;
};
DestroyWindow( curtain );
return false;
}
else
smIsFullScreen = true;
}
else if ( smIsFullScreen )
{
Con::printf( "Changing to the desktop display settings (%dx%dx%d)...", winState.desktopWidth, winState.desktopHeight, winState.desktopBitsPixel );
ChangeDisplaySettings( NULL, 0 );
smIsFullScreen = false;
}
Con::setBoolVariable( "$pref::Video::fullScreen", smIsFullScreen );
bool newWindow = false;
if ( !winState.appWindow )
{
Con::printf( "Creating a new %swindow...", ( fullScreen ? "full-screen " : "" ) );
winState.appWindow = CreateOpenGLWindow( newRes.w, newRes.h, newFullScreen );
if ( !winState.appWindow )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nFailed to create a new window!" );
return false;
}
newWindow = true;
}
// Move the window:
if ( !newFullScreen )
{
// Adjust the window rect to compensate for the window style:
RECT windowRect;
windowRect.left = windowRect.top = 0;
windowRect.right = newRes.w;
windowRect.bottom = newRes.h;
AdjustWindowRect( &windowRect, GetWindowLong( winState.appWindow, GWL_STYLE ), false );
U32 adjWidth = windowRect.right - windowRect.left;
U32 adjHeight = windowRect.bottom - windowRect.top;
// Center the window on the desktop:
U32 xPos = ( winState.desktopWidth - adjWidth ) / 2;
U32 yPos = ( winState.desktopHeight - adjHeight ) / 2;
test = SetWindowPos( winState.appWindow, 0, xPos, yPos, adjWidth, adjHeight, SWP_NOZORDER );
if ( !test )
{
dSprintf( errorMessage, 255, "OpenGLDevice::setScreenMode\nSetWindowPos failed trying to move the window to (%d,%d) and size it to %dx%d.", xPos, yPos, newRes.w, newRes.h );
AssertFatal( false, errorMessage );
return false;
}
}
else if ( !newWindow )
{
// Move and size the window to take up the whole screen:
if ( !SetWindowPos( winState.appWindow, 0, 0, 0, newRes.w, newRes.h, SWP_NOZORDER ) )
{
dSprintf( errorMessage, 255, "OpenGLDevice::setScreenMode\nSetWindowPos failed to move the window to (0,0) and size it to %dx%d.", newRes.w, newRes.h );
AssertFatal( false, errorMessage );
return false;
}
}
bool newDeviceContext = false;
if ( !winState.appDC )
{
// Get a new device context:
Con::printf( "Acquiring a new device context..." );
winState.appDC = GetDC( winState.appWindow );
if ( !winState.appDC )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nGetDC failed to get a valid device context!" );
return false;
}
newDeviceContext = true;
}
if ( newWindow )
{
// Set the pixel format of the new window:
PIXELFORMATDESCRIPTOR pfd;
CreatePixelFormat( &pfd, newRes.bpp, 24, 8, false );
S32 chosenFormat = ChooseBestPixelFormat( winState.appDC, &pfd );
if ( !chosenFormat )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nNo valid pixel formats found!" );
return false;
}
qwglDescribePixelFormat( winState.appDC, chosenFormat, sizeof( pfd ), &pfd );
if ( !SetPixelFormat( winState.appDC, chosenFormat, &pfd ) )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nFailed to set the pixel format!" );
return false;
}
Con::printf( "Pixel format set:" );
Con::printf( " %d color bits, %d depth bits, %d stencil bits", pfd.cColorBits, pfd.cDepthBits, pfd.cStencilBits );
}
if ( !winState.hGLRC )
{
// Create a new rendering context:
Con::printf( "Creating a new rendering context..." );
winState.hGLRC = qwglCreateContext( winState.appDC );
if ( !winState.hGLRC )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nqwglCreateContext failed to create an OpenGL rendering context!" );
return false;
}
// Make the new rendering context current:
Con::printf( "Making the new rendering context current..." );
if ( !qwglMakeCurrent( winState.appDC, winState.hGLRC ) )
{
AssertFatal( false, "OpenGLDevice::setScreenMode\nqwglMakeCurrent failed to make the rendering context current!" );
return false;
}
// Just for kicks. Seems a relatively central place to put this...
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ( needResurrect )
{
// Reload the textures:
Con::printf( "Resurrecting the texture manager..." );
Game->textureResurrect();
}
}
// Just for kicks. Seems a relatively central place to put this...
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ( newDeviceContext && gGLState.suppSwapInterval )
setVerticalSync( !Con::getBoolVariable( "$pref::Video::disableVerticalSync" ) );
smCurrentRes = newRes;
Platform::setWindowSize( newRes.w, newRes.h );
char tempBuf[15];
dSprintf( tempBuf, sizeof( tempBuf ), "%d %d %d", smCurrentRes.w, smCurrentRes.h, smCurrentRes.bpp );
Con::setVariable( "$pref::Video::resolution", tempBuf );
if ( curtain )
DestroyWindow( curtain );
// Doesn't hurt to do this even it isn't necessary:
ShowWindow( winState.appWindow, SW_SHOW );
SetForegroundWindow( winState.appWindow );
SetFocus( winState.appWindow );
if ( repaint )
Con::evaluate( "resetCanvas();" );
return true;
#endif
}
//------------------------------------------------------------------------------
void OpenGLDevice::swapBuffers()
{
glXSwapBuffers(display, win);
}
//------------------------------------------------------------------------------
const char* OpenGLDevice::getDriverInfo()
{
#if 0
// Output some driver info to the console:
const char* vendorString = (const char*) glGetString( GL_VENDOR );
const char* rendererString = (const char*) glGetString( GL_RENDERER );
const char* versionString = (const char*) glGetString( GL_VERSION );
const char* extensionsString = (const char*) glGetString( GL_EXTENSIONS );
U32 bufferLen = ( vendorString ? dStrlen( vendorString ) : 0 )
+ ( rendererString ? dStrlen( rendererString ) : 0 )
+ ( versionString ? dStrlen( versionString ) : 0 )
+ ( extensionsString ? dStrlen( extensionsString ) : 0 )
+ 4;
char* returnString = Con::getReturnBuffer( bufferLen );
dSprintf( returnString, bufferLen, "%s\t%s\t%s\t%s",
( vendorString ? vendorString : "" ),
( rendererString ? rendererString : "" ),
( versionString ? versionString : "" ),
( extensionsString ? extensionsString : "" ) );
return( returnString );
#endif
}
//------------------------------------------------------------------------------
bool OpenGLDevice::getGammaCorrection(F32 &g)
{
#if 0
U16 ramp[256*3];
if (!GetDeviceGammaRamp(winState.appDC, ramp))
return false;
F32 csum = 0.0;
U32 ccount = 0;
for (U16 i = 0; i < 256; ++i)
{
if (i != 0 && ramp[i] != 0 && ramp[i] != 65535)
{
F64 b = (F64) i/256.0;
F64 a = (F64) ramp[i]/65535.0;
F32 c = (F32) (mLog(a)/mLog(b));
csum += c;
++ccount;
}
}
g = csum/ccount;
return true;
#endif
}
//------------------------------------------------------------------------------
bool OpenGLDevice::setGammaCorrection(F32 g)
{
#if 0
U16 ramp[256*3];
for (U16 i = 0; i < 256; ++i)
ramp[i] = mPow((F32) i/256.0f, g) * 65535.0f;
dMemcpy(&ramp[256],ramp,256*sizeof(U16));
dMemcpy(&ramp[512],ramp,256*sizeof(U16));
return SetDeviceGammaRamp(winState.appDC, ramp);
#endif
}
//------------------------------------------------------------------------------
bool OpenGLDevice::setVerticalSync( bool on )
{
#if 0
if ( !gGLState.suppSwapInterval )
return( false );
return( qwglSwapIntervalEXT( on ? 1 : 0 ) );
#endif
}
//------------------------------------------------------------------------------
DisplayDevice* OpenGLDevice::create()
{
return new OpenGLDevice();
}

View file

@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _LINUXOGLVIDEO_H_
#define _LINUXOGLVIDEO_H_
#ifndef _PLATFORMVIDEO_H_
#include "platform/platformVideo.h"
#endif
class OpenGLDevice : public DisplayDevice
{
static bool smCanSwitchBitDepth;
bool mRestoreGamma;
U16 mOriginalRamp[256*3];
public:
OpenGLDevice();
void initDevice();
bool activate( U32 width, U32 height, U32 bpp, bool fullScreen );
void shutdown();
void destroy();
bool setScreenMode( U32 width, U32 height, U32 bpp, bool fullScreen, bool forceIt = false, bool repaint = true );
void swapBuffers();
const char* getDriverInfo();
bool getGammaCorrection(F32 &g);
bool setGammaCorrection(F32 g);
bool setVerticalSync( bool on );
static DisplayDevice* create();
};
#endif // _H_LINUXOGLVIDEO

View file

@ -0,0 +1,175 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "console/console.h"
#define AL_NO_PROTOTYPES
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>
// Stub functions: ---------------------------------------------------------
// AL:
ALvoid stub_alEnable( ALenum ) {}
ALvoid stub_alDisable( ALenum ) {}
ALboolean stub_alIsEnabled( ALenum ) {return(AL_FALSE);}
ALvoid stub_alHint( ALenum , ALenum ) {}
ALboolean stub_alGetBoolean( ALenum ) {return(AL_FALSE);}
ALint stub_alGetInteger( ALenum ) {return(0);}
ALfloat stub_alGetFloat( ALenum ) {return(0.f);}
ALdouble stub_alGetDouble( ALenum ) {return(0.f);}
ALvoid stub_alGetBooleanv( ALenum, ALboolean* ) {}
ALvoid stub_alGetIntegerv( ALenum, ALint* ) {}
ALvoid stub_alGetFloatv( ALenum, ALfloat* ) {}
ALvoid stub_alGetDoublev( ALenum, ALdouble* ) {}
const ALubyte* stub_alGetString( ALenum pname )
{
switch(pname)
{
case AL_VENDOR: return (ALubyte*)"None";
case AL_VERSION: return (ALubyte*)"OpenAL 0.1";
case AL_RENDERER: return (ALubyte*)"None";
case AL_EXTENSIONS: return (ALubyte*)"";
}
return(0);
}
ALenum stub_alGetError( ALvoid ) {return(0);}
ALboolean stub_alIsExtensionPresent( const ALubyte* ) {return(AL_FALSE);}
ALvoid* stub_alGetProcAddress( const ALubyte* ) {return(0);}
ALenum stub_alGetEnumValue( const ALubyte* ) {return(0);}
ALvoid stub_alListenerf( ALenum, ALfloat ) {}
ALvoid stub_alListener3f( ALenum, ALfloat, ALfloat, ALfloat ) {}
ALvoid stub_alListenerfv( ALenum, ALfloat* ) {}
ALvoid stub_alGetListeneri( ALenum, ALint* ) {}
ALvoid stub_alGetListenerf( ALenum, ALfloat* ) {}
ALvoid stub_alGetListenerfv( ALenum, ALfloat* ) {}
ALvoid stub_alGenSources( ALsizei, ALuint* ) {}
ALvoid stub_alDeleteSources( ALsizei, ALuint* ) {}
ALboolean stub_alIsSource( ALuint ) {return(AL_FALSE);}
ALvoid stub_alSourcei( ALuint, ALenum, ALint ) {}
ALvoid stub_alSourcef( ALuint, ALenum, ALfloat ) {}
ALvoid stub_alSource3f( ALuint, ALenum, ALfloat, ALfloat, ALfloat ) {}
ALvoid stub_alSourcefv( ALuint, ALenum, ALfloat* ) {}
ALvoid stub_alGetSourcei( ALuint, ALenum, ALint* ) {}
ALvoid stub_alGetSourcef( ALuint, ALenum, ALfloat* ) {}
ALvoid stub_alGetSourcefv( ALuint, ALenum, ALfloat* ) {}
ALvoid stub_alSourcePlayv( ALuint, ALuint* ) {}
ALvoid stub_alSourceStopv( ALuint, ALuint* ) {}
ALvoid stub_alSourcePlay( ALuint ) {}
ALvoid stub_alSourcePause( ALuint ) {}
ALvoid stub_alSourceStop( ALuint ) {}
ALvoid stub_alGenBuffers( ALsizei, ALuint* ) {}
ALvoid stub_alDeleteBuffers( ALsizei, ALuint* ) {}
ALboolean stub_alIsBuffer( ALuint ) {return(AL_FALSE);}
ALvoid stub_alBufferData( ALuint, ALenum, ALvoid*, ALsizei, ALsizei ) {}
ALsizei stub_alBufferAppendData( ALuint, ALenum, ALvoid*, ALsizei, ALsizei ) {return(0);}
ALvoid stub_alGetBufferi( ALuint, ALenum, ALint* ) {}
ALvoid stub_alGetBufferf( ALuint, ALenum, ALfloat* ) {}
// ALC:
ALvoid* stub_alcCreateContext( ALint *) {return(0);}
ALCenum stub_alcMakeContextCurrent( ALvoid *) {return(ALC_INVALID);}
ALvoid* stub_alcUpdateContext( ALvoid * ) {return(0);}
ALCenum stub_alcDestroyContext( ALvoid * ) {return(ALC_INVALID);}
ALCenum stub_alcGetError( ALvoid ) {return(ALC_INVALID);}
const ALubyte* stub_alcGetErrorString( ALvoid ) {return(0);}
ALvoid* stub_alcGetCurrentContext( ALvoid ) {return(0);}
// ALUT:
void stub_alutInit( int *, char ** ) {}
void stub_alutExit( ALvoid ) {}
ALboolean stub_alutLoadWAV( const char *, ALvoid **, ALsizei *, ALsizei *, ALsizei *, ALsizei *) {return(AL_FALSE);}
// Extension: IASIG
ALvoid stub_alGenEnvironmentIASIG( ALsizei, ALuint* ) {}
ALvoid stub_alDeleteEnvironmentIASIG( ALsizei, ALuint*) {}
ALboolean stub_alIsEnvironmentIASIG( ALuint ) {return(AL_FALSE);}
ALvoid stub_alEnvironmentiIASIG( ALuint, ALenum, ALint ) {}
ALvoid stub_alEnvironmentfIASIG( ALuint, ALenum, ALfloat ) {}
ALvoid stub_alGetEnvironmentiIASIG_EXT( ALuint, ALenum, ALint * ) {}
ALvoid stub_alGetEnvironmentfIASIG_EXT( ALuint, ALenum, ALfloat * ) {}
// Extension: Dynamix
ALboolean stub_alBufferi_EXT( ALuint, ALenum, ALint ) { return(AL_FALSE); }
ALboolean stub_alBufferSyncData_EXT( ALuint, ALenum, ALvoid *, ALsizei, ALsizei ) {return(AL_FALSE); }
ALboolean stub_alBufferStreamFile_EXT( ALuint, const ALubyte * ) { return(AL_FALSE); }
ALboolean stub_alSourceCallback_EXT( ALuint, ALvoid * ) { return(AL_FALSE); }
ALvoid stub_alSourceResetEnvironment_EXT( ALuint ) {}
ALboolean stub_alContexti_EXT( ALenum, ALint) { return(AL_FALSE); }
ALboolean stub_alGetContexti_EXT( ALenum, ALint * ) { return(AL_FALSE); }
ALboolean stub_alGetContextstr_EXT( ALenum, ALuint, ALubyte ** ) { return(AL_FALSE); }
ALboolean stub_alCaptureInit_EXT( ALenum, ALuint, ALsizei ) { return(AL_FALSE); }
ALboolean stub_alCaptureDestroy_EXT( ALvoid ) { return(AL_FALSE); }
ALboolean stub_alCaptureStart_EXT( ALvoid ) { return(AL_FALSE); }
ALboolean stub_alCaptureStop_EXT( ALvoid ) { return(AL_FALSE); }
ALsizei stub_alCaptureGetData_EXT( ALvoid *, ALsizei, ALenum, ALuint ) { return(AL_FALSE); }
// declare OpenAL functions
#define AL_EXTENSION(ext_name) bool gDoesSupport_##ext_name = false;
#define AL_FUNCTION(fn_return,fn_name,fn_args) fn_return (*fn_name)fn_args = stub_##fn_name;
#define AL_EXT_FUNCTION(ext_name,fn_return,fn_name,fn_args) fn_return (*fn_name)fn_args = stub_##fn_name;
#include <openALFn.h>
// DLL's: ------------------------------------------------------------------
static bool findExtension( const char* name )
{
bool result = false;
if (alGetString != NULL)
{
result = dStrstr( (const char*)alGetString(AL_EXTENSIONS), name) != NULL;
}
return result;
}
// Stub: -------------------------------------------------------------------
static void bindStubFunctions()
{
#define AL_EXTENSION(ext_name) gDoesSupport_##ext_name = false;
#define AL_FUNCTION(fn_return,fn_name,fn_parms) fn_name = stub_##fn_name;
#define AL_EXT_FUNCTION(ext_name,fn_return,fn_name,fn_args) fn_name = stub_##fn_name;
#include <openALFn.h>
}
namespace Audio
{
static bool sStaticLibrary;
void libraryShutdown()
{
bindStubFunctions();
sStaticLibrary = true;
}
bool libraryInit(const char *library)
{
libraryShutdown();
if(!library || !library[0])
return(false);
libraryShutdown();
return(false);
}
void libraryInitExtensions()
{
// static library extensions are bound on libraryInit (need to be defined anyways...)
if(sStaticLibrary)
{
#define AL_EXTENSION(ext_name) gDoesSupport_##ext_name = findExtension( #ext_name );
#include <openALFn.h>
}
else
{
#define AL_EXTENSION(ext_name) gDoesSupport_##ext_name = findExtension( #ext_name );
// #define AL_EXT_FUNCTION(ext_name,fn_return,fn_name,fn_args) bindExtension(*(void**)&fn_name, #fn_name, gDoesSupport_##ext_name );
#include <openALFn.h>
}
}
} // end namespace Audio

View file

@ -0,0 +1,23 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
void Platform::postQuitMessage(const U32 in_quitVal)
{
// PostQuitMessage(in_quitVal);
}
void Platform::debugBreak()
{
// DebugBreak();
}
void Platform::forceShutdown(S32 returnValue)
{
// ExitProcess(returnValue);
}

View file

@ -0,0 +1,407 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "console/console.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformRedBook.h"
#if defined(__linux__)
#include <linux/cdrom.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>
#endif
#include <SDL/SDL.h>
class UnixRedBookDevice : public RedBookDevice
{
private:
S32 mDeviceId;
SDL_CD *mCD;
cdrom_volctrl mOriginalVolume;
bool mVolumeInitialized;
bool mPlaying;
void openVolume();
void closeVolume();
void setLastError(const char *);
public:
UnixRedBookDevice();
~UnixRedBookDevice();
bool open();
bool close();
bool play(U32);
bool stop();
bool getTrackCount(U32 *);
bool getVolume(F32 *);
bool setVolume(F32);
bool isPlaying() { return mPlaying; }
bool updateStatus();
void setDeviceInfo(S32 deviceId, const char *deviceName);
};
//-------------------------------------------------------------------------------
// Class: UnixRedBookDevice
//-------------------------------------------------------------------------------
UnixRedBookDevice::UnixRedBookDevice()
{
mVolumeInitialized = false;
mDeviceId = -1;
mDeviceName = NULL;
mCD = NULL;
mPlaying = false;
}
//------------------------------------------------------------------------------
UnixRedBookDevice::~UnixRedBookDevice()
{
close();
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::updateStatus()
{
AssertFatal(mCD, "mCD is NULL");
CDstatus status = SDL_CDStatus(mCD);
if (status == CD_ERROR)
{
setLastError("Error accessing device");
return(false);
}
else if (status == CD_TRAYEMPTY)
{
setLastError("CD tray empty");
return false;
}
mPlaying = (status == CD_PLAYING);
return true;
}
//------------------------------------------------------------------------------
void UnixRedBookDevice::setDeviceInfo(S32 deviceId, const char *deviceName)
{
mDeviceId = deviceId;
mDeviceName = new char[dStrlen(deviceName) + 1];
dStrcpy(mDeviceName, deviceName);
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::open()
{
if(mAcquired)
{
setLastError("Device is already open.");
return(false);
}
// open the device
mCD = SDL_CDOpen(mDeviceId);
if (mCD == NULL)
{
setLastError(SDL_GetError());
return false;
}
mAcquired = true;
openVolume();
setLastError("");
return(true);
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::close()
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
stop();
closeVolume();
if (mCD != NULL)
{
SDL_CDClose(mCD);
mCD = NULL;
}
mAcquired = false;
setLastError("");
return(true);
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::play(U32 track)
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
U32 numTracks;
if(!getTrackCount(&numTracks))
return(false);
if(track >= numTracks)
{
setLastError("Track index is out of range");
return(false);
}
if (!updateStatus())
return false;
AssertFatal(mCD, "mCD is NULL");
if (SDL_CDPlayTracks(mCD, track, 0, 1, 0) == -1)
{
setLastError(SDL_GetError());
return false;
}
mPlaying = true;
setLastError("");
return(true);
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::stop()
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
AssertFatal(mCD, "mCD is NULL");
if (SDL_CDStop(mCD) == -1)
{
setLastError(SDL_GetError());
return(false);
}
mPlaying = false;
setLastError("");
return(true);
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::getTrackCount(U32 * numTracks)
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
if (!updateStatus())
return false;
AssertFatal(mCD, "mCD is NULL");
*numTracks = mCD->numtracks;
return(true);
}
template <class Type>
static inline Type max(Type v1, Type v2)
{
if (v1 <= v2)
return v2;
else
return v1;
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::getVolume(F32 * volume)
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
if(!mVolumeInitialized)
{
setLastError("Volume failed to initialize");
return(false);
}
#if defined(__linux__)
AssertFatal(mCD, "mCD is NULL");
setLastError("");
cdrom_volctrl sysvol;
if (ioctl(mCD->id, CDROMVOLREAD, &sysvol) == -1)
{
setLastError(strerror(errno));
return(false);
}
U8 maxVol = max(sysvol.channel0, sysvol.channel1);
// JMQTODO: support different left/right channel volumes?
*volume = static_cast<F32>(maxVol) / 255.f;
return true;
#else
return(false);
#endif
}
//------------------------------------------------------------------------------
bool UnixRedBookDevice::setVolume(F32 volume)
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
if(!mVolumeInitialized)
{
setLastError("Volume failed to initialize");
return(false);
}
#if defined(__linux__)
AssertFatal(mCD, "mCD is NULL");
setLastError("");
cdrom_volctrl sysvol;
volume = volume * 255.f;
if (volume > 255)
volume = 255;
if (volume < 0)
volume = 0;
sysvol.channel0 = sysvol.channel1 = static_cast<__u8>(volume);
if (ioctl(mCD->id, CDROMVOLCTRL, &sysvol) == -1)
{
setLastError(strerror(errno));
return(false);
}
return true;
#else
return(false);
#endif
}
//------------------------------------------------------------------------------
void UnixRedBookDevice::openVolume()
{
// Its unforunate that we have to do it this way, but SDL does not currently
// support setting CD audio volume
#if defined(__linux__)
AssertFatal(mCD, "mCD is NULL");
setLastError("");
if (ioctl(mCD->id, CDROMVOLREAD, &mOriginalVolume) == -1)
{
setLastError(strerror(errno));
return;
}
mVolumeInitialized = true;
#else
setLastError("Volume failed to initialize");
#endif
}
void UnixRedBookDevice::closeVolume()
{
if(!mVolumeInitialized)
return;
#if defined(__linux__)
AssertFatal(mCD, "mCD is NULL");
setLastError("");
if (ioctl(mCD->id, CDROMVOLCTRL, &mOriginalVolume) == -1)
{
setLastError(strerror(errno));
return;
}
#endif
mVolumeInitialized = false;
}
//------------------------------------------------------------------------------
void UnixRedBookDevice::setLastError(const char * error)
{
RedBook::setLastError(error);
}
//------------------------------------------------------------------------------
void InstallRedBookDevices()
{
Con::printf("CD Audio Init:");
if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1)
{
Con::printf(" Unable to initialize CD Audio: %s", SDL_GetError());
return;
}
S32 numDrives = SDL_CDNumDrives();
if (numDrives == 0)
{
Con::printf(" No drives found.");
return;
}
for (int i = 0; i < numDrives; ++i)
{
const char * deviceName = SDL_CDName(i);
Con::printf(" Installing CD Audio device: %s", deviceName);
UnixRedBookDevice * device = new UnixRedBookDevice;
device->setDeviceInfo(i, deviceName);
RedBook::installDevice(device);
}
Con::printf(" ");
}
//------------------------------------------------------------------------------
void PollRedbookDevices()
{
// JMQTODO: poll at longer intervals if this function is expensive
static const U32 PollDelay = 1000;
static U32 lastPollTime = 0;
U32 curTime = Platform::getVirtualMilliseconds();
if (lastPollTime != 0 &&
(curTime - lastPollTime) < PollDelay)
return;
lastPollTime = curTime;
RedBookDevice *rbDevice = RedBook::getCurrentDevice();
if (rbDevice == NULL)
return;
UnixRedBookDevice *device = dynamic_cast<UnixRedBookDevice*>(rbDevice);
if (device == NULL)
return;
if (device->isPlaying())
{
device->updateStatus();
if (!device->isPlaying())
RedBook::handleCallback(RedBook::PlayFinished);
}
}

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformSemaphore.h"
#include <fcntl.h>
#include <semaphore.h>
void * Semaphore::createSemaphore(U32 initialCount)
{
sem_t *semaphore;
/* hell, I want an elite semaphore, OK?! - rjp */
semaphore = sem_open("/tmp/eliteQueue.31337", O_CREAT, 0664, initialCount);
return(semaphore);
}
void Semaphore::destroySemaphore(void * semaphore)
{
AssertFatal(semaphore, "Semaphore::destroySemaphore: invalid semaphore");
sem_close((sem_t *)semaphore);
delete semaphore;
}
bool Semaphore::acquireSemaphore(void * semaphore, bool block)
{
AssertFatal(semaphore, "Semaphore::acquireSemaphore: invalid semaphore");
if(block)
{
sem_wait((sem_t *)semaphore);
return(true);
}
else
{
U32 result = sem_trywait((sem_t *)semaphore);
return(result == 0);
}
}
void Semaphore::releaseSemaphore(void * semaphore)
{
AssertFatal(semaphore, "Semaphore::releaseSemaphore: invalid semaphore");
sem_unlink("/tmp/eliteQueue.31337");
}

View file

@ -0,0 +1,377 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//
// Initial revision: 12/13/01 Paul G. Allen, Random Logic Consulting
//-----------------------------------------------------------------------------
#include "math/mPoint.h"
#include "platformX86UNIX/platformGL.h"
#include "platformX86UNIX/x86UNIXGLX.h"
/******************************************************************************
*
* Class: x86UNIXPlatformState
* Description: Class used to store the state of things for X Windows based
* implementations.
*
* Data Objects:
* Point2I DesktopSize hor. and vert. X desktop resolution
* Point2I WindowSize hor. and vert. X window resolution
* GLXContext OpenGLContext Current GLX context
* S32 Desktop_bpp X desktop color depth
* Display *display Pointer to current X display
* Window CurrentWindow Current X window for game
* Screen *ScreenPointer Pointer to current screen on display
* int ScreenNumber Current X screen number
* Colormap CurrentColormap Current X color map
* XVisualInfo *VisualInfo Visual information stuct for GLX
* XSetWindowAttributes WindowAttributes
* Attributes for CurrentWindow
* XSizeHints SizeHints Size hints for CurrentWindow
* bool KeepAspect true = keep aspect ratio of window
* bool OverrideSettings true = disable "Graphics" dialog
* char WindowName[40] CurrentWindow name (for title bar)
*
* bool videoInitted Video is initialized
* U32 currentTime Current game time
* char *DisplayHint Display hints for display
*
* Changelog:
* PGA 12/18/01: Initial revision
******************************************************************************/
class x86UNIXPlatformState
{
private:
Point2I DesktopSize;
Point2I WindowSize;
GLXContext OpenGLContext;
S32 Desktop_bpp;
Display *display;
Window CurrentWindow;
Screen *ScreenPointer;
int ScreenNumber;
Colormap CurrentColormap;
XVisualInfo *VisualInfo;
XSetWindowAttributes WindowAttributes;
XSizeHints SizeHints;
bool KeepAspect,
OverrideSettings;
char WindowName[40];
public:
bool videoInitted;
U32 currentTime;
char *DisplayHint;
/******************************************************************************
*
* Member routines: Get and set XSetWindowAttributes private data member.
*
******************************************************************************/
void SetWindowAttributes( XSetWindowAttributes NewAttributes )
{
WindowAttributes = NewAttributes;
}
XSetWindowAttributes * GetWindowAttributes()
{
return &WindowAttributes;
}
/******************************************************************************
*
* Member routines: Get and set Colormap private data member.
*
******************************************************************************/
void SetColormap( Colormap NewColormap )
{
CurrentColormap = NewColormap;
}
Colormap GetColormap()
{
return CurrentColormap;
}
/******************************************************************************
*
* Member routines: Get and set XVisualInfo private data member.
*
******************************************************************************/
void SetVisualInfo( XVisualInfo *NewInfo )
{
VisualInfo = NewInfo;
}
XVisualInfo * GetVisualInfo()
{
return VisualInfo;
}
/******************************************************************************
*
* Member routines: Get and set X display Screen number private data member.
*
******************************************************************************/
void SetScreenNumber( int NewNumber )
{
ScreenNumber = NewNumber;
}
int GetScreenNumber()
{
return ScreenNumber;
}
/******************************************************************************
*
* Member routines: Get and set Screen pointer private data member.
*
******************************************************************************/
void SetScreenPointer( Screen *NewScreenPointer )
{
ScreenPointer = NewScreenPointer;
}
Screen * GetScreenPointer()
{
return ScreenPointer;
}
/******************************************************************************
*
* Member routines: Get and set Window private data member.
*
******************************************************************************/
void SetWindow( Window NewWindow )
{
CurrentWindow = NewWindow;
}
Window GetWindow()
{
return CurrentWindow;
}
/******************************************************************************
*
* Member routines: Get and set desktop color depth private data member.
*
******************************************************************************/
void SetDesktop_bpp( S32 bpp )
{
Desktop_bpp = bpp;
}
S32 GetDesktop_bpp()
{
return Desktop_bpp;
}
/******************************************************************************
*
* Member routines: Get and set GLXContext private data member.
*
******************************************************************************/
void SetGLContextPointer( GLXContext GLContext )
{
OpenGLContext = GLContext;
}
GLXContext GetGLContextPointer()
{
return OpenGLContext;
}
/******************************************************************************
*
* Member routines: Get and set Display private data member.
*
******************************************************************************/
void SetDisplayPointer( Display *DisplayPointer )
{
display = DisplayPointer;
}
Display * GetDisplayPointer()
{
return display;
}
/******************************************************************************
*
* Member routines: Set Point2I window size private data members given two
* seperate values, one for each WindowSize data mamber.
*
******************************************************************************/
void SetWindowSize (S32 horizontal, S32 vertical )
{
WindowSize.set ( horizontal, vertical );
}
/******************************************************************************
*
* Member routines: Set Point2I window size private data class given a Point2I
* data object.
*
******************************************************************************/
void SetWindowSize( Point2I Size )
{
WindowSize = Size;
}
/******************************************************************************
*
* Member routines: Return both x and y data members of the WindowSize private
* data class.
*
******************************************************************************/
Point2I& GetWindowSize()
{
return ( WindowSize );
}
/******************************************************************************
*
* Member routines: Get and set the window name private data member.
*
******************************************************************************/
void SetName (const char * Name)
{
strcpy( WindowName, "\0" );
strncpy( WindowName, Name, sizeof( WindowName ) );
}
const char * GetWindowName()
{
return WindowName;
}
/******************************************************************************
*
* Member routines: Get a pointer to XSizeHints private data member.
*
******************************************************************************/
XSizeHints * GetSizeHints()
{
return ( &SizeHints );
}
/******************************************************************************
*
* Member routines: Get and set the command line override private data member.
*
******************************************************************************/
bool GetOverrideSetting()
{
return OverrideSettings;
}
void SetOverrideSetting( bool NewOverride )
{
OverrideSettings = NewOverride;
}
/******************************************************************************
*
* Member routines: Get and set aspect ratio command line private data member.
*
******************************************************************************/
bool GetAspectSetting()
{
return KeepAspect;
}
void SetAspectSetting( bool NewAspect )
{
KeepAspect = NewAspect;
}
/******************************************************************************
*
* Member routine: Get the Point2I desktop size private class data member.
*
******************************************************************************/
Point2I GetDesktopSize()
{
return DesktopSize;
}
/******************************************************************************
*
* Member routine: Set the Point2I desktop size private class data member
* given a Point2I data object.
*
******************************************************************************/
void SetDesktopSize( S32 horizontal, S32 vertical )
{
DesktopSize.set( horizontal, vertical );
}
/******************************************************************************
*
* Member routine: Initialize the class to a known state.
*
******************************************************************************/
x86UNIXPlatformState()
{
Desktop_bpp = 16;
SizeHints.flags = None;
SizeHints.x = 0;
SizeHints.y = 0;
videoInitted = false;
currentTime = 0;
DisplayHint = NULL;
KeepAspect = true;
OverrideSettings = false;
strcpy( WindowName, "Torque" );
DesktopSize.set( 0, 0 );
WindowSize.set( 800, 600 );
CurrentColormap = 0;
VisualInfo = NULL;
}
};
extern x86UNIXPlatformState * x86UNIXState;

View file

@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIXSTDCONSOLE_H_
#define _X86UNIXSTDCONSOLE_H_
#define MAX_CMDS 10
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
class StdConsole
{
bool stdConsoleEnabled;
int stdOut;
int stdIn;
int stdErr;
ConsoleEvent postEvent;
char inbuf[512];
S32 inpos;
bool lineOutput;
char curTabComplete[512];
S32 tabCompleteStart;
char rgCmds[MAX_CMDS][512];
S32 iCmdIndex;
void printf(const char *s, ...);
public:
StdConsole();
void process();
void enable(bool);
void processConsoleLine(const char *consoleLine);
static void create();
static void destroy();
static bool isEnabled();
};
extern StdConsole *stdConsole;
#endif

View file

@ -0,0 +1,364 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include <stdarg.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef HAS_VSSCANF
# undef HAS_VSSCANF
#endif
/* this routine turns a string to all uppercase - rjp */
char *__strtoup(char *str)
{
char *newStr = str;
if (newStr == NULL)
return(NULL);
while (*newStr)
{
*newStr = toupper(*newStr);
*newStr++;
}
return(str);
}
/* this routine turns a string to all lowercase - rjp */
char *__strtolwr(char *str)
{
char *newStr = str;
if (newStr == NULL)
return(NULL);
while (*newStr)
{
*newStr = tolower(*newStr);
*newStr++;
}
return(str);
}
char *dStrdup_r(const char *src, const char *fileName, U32 lineNumber)
{
char *buffer = (char *) dMalloc_r(dStrlen(src) + 1, fileName, lineNumber);
dStrcpy(buffer, src);
return buffer;
}
char* dStrcat(char *dst, const char *src)
{
return strcat(dst,src);
}
// concatenates a list of src's onto the end of dst
// the list of src's MUST be terminated by a NULL parameter
// dStrcatl(dst, sizeof(dst), src1, src2, NULL);
char* dStrcatl(char *dst, U32 dstSize, ...)
{
const char* src;
char *p = dst;
AssertFatal(dstSize > 0, "dStrcatl: destination size is set zero");
dstSize--; // leave room for string termination
// find end of dst
while (dstSize && *p++)
dstSize--;
va_list args;
va_start(args, dstSize);
// concatenate each src to end of dst
while ( (src = va_arg(args, const char*)) != NULL )
while( dstSize && *src )
{
*p++ = *src++;
dstSize--;
}
va_end(args);
// make sure the string is terminated
*p = 0;
return dst;
}
// copy a list of src's into dst
// the list of src's MUST be terminated by a NULL parameter
// dStrccpyl(dst, sizeof(dst), src1, src2, NULL);
char* dStrcpyl(char *dst, U32 dstSize, ...)
{
const char* src;
char *p = dst;
AssertFatal(dstSize > 0, "dStrcpyl: destination size is set zero");
dstSize--; // leave room for string termination
va_list args;
va_start(args, dstSize);
// concatenate each src to end of dst
while ( (src = va_arg(args, const char*)) != NULL )
while( dstSize && *src )
{
*p++ = *src++;
dstSize--;
}
va_end(args);
// make sure the string is terminated
*p = 0;
return dst;
}
S32 dStrcmp(const char *str1, const char *str2)
{
return strcmp(str1, str2);
}
S32 dStricmp(const char *str1, const char *str2)
{
return strcasecmp(str1, str2);
}
S32 dStrncmp(const char *str1, const char *str2, U32 len)
{
return strncmp(str1, str2, len);
}
S32 dStrnicmp(const char *str1, const char *str2, U32 len)
{
return strncasecmp(str1, str2, len);
}
char* dStrcpy(char *dst, const char *src)
{
return strcpy(dst,src);
}
char* dStrncpy(char *dst, const char *src, U32 len)
{
return strncpy(dst,src,len);
}
U32 dStrlen(const char *str)
{
return strlen(str);
}
char* dStrupr(char *str)
{
#ifdef __MWERKS__ // metrowerks strupr is broken
_strupr(str);
return str;
#else
return __strtoup(str);
#endif
}
char* dStrlwr(char *str)
{
return __strtolwr(str);
}
char* dStrchr(char *str, S32 c)
{
return strchr(str,c);
}
const char* dStrchr(const char *str, S32 c)
{
return strchr(str,c);
}
const char* dStrrchr(const char *str, S32 c)
{
return strrchr(str,c);
}
char* dStrrchr(char *str, S32 c)
{
return strrchr(str,c);
}
U32 dStrspn(const char *str, const char *set)
{
return(strspn(str, set));
}
U32 dStrcspn(const char *str, const char *set)
{
return strcspn(str, set);
}
char* dStrstr(const char *str1, const char *str2)
{
return strstr(str1,str2);
}
char* dStrtok(char *str, const char *sep)
{
return strtok(str, sep);
}
S32 dAtoi(const char *str)
{
return atoi(str);
}
F32 dAtof(const char *str)
{
return atof(str);
}
bool dAtob(const char *str)
{
return !dStricmp(str, "true") || dAtof(str);
}
bool dIsalnum(const char c)
{
return isalnum(c);
}
bool dIsalpha(const char c)
{
return(isalpha(c));
}
bool dIsspace(const char c)
{
return(isspace(c));
}
bool dIsdigit(const char c)
{
return(isdigit(c));
}
void dPrintf(const char *format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args);
}
S32 dVprintf(const char *format, void *arglist)
{
S32 len = vprintf(format, (char*)arglist);
return (len);
}
S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
{
va_list args;
va_start(args, format);
#ifdef __MWERKS__
S32 len = vsnprintf(buffer, bufferSize, format, args);
#else
bufferSize;
S32 len = vsprintf(buffer, format, args);
#endif
return (len);
}
S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist)
{
#ifdef __MWERKS__
S32 len = vsnprintf(buffer, bufferSize, format, (char*)arglist);
#else
bufferSize;
S32 len = vsprintf(buffer, format, (char*)arglist);
#endif
// S32 len = vsnprintf(buffer, bufferSize, format, (char*)arglist);
return (len);
}
S32 dSscanf(const char *buffer, const char *format, ...)
{
va_list args;
#if defined(HAS_VSSCANF)
va_start(args, format);
return __vsscanf(buffer, format, args);
#else
va_start(args, format);
// Boy is this lame. We have to scan through the format string, and find out how many
// arguments there are. We'll store them off as void*, and pass them to the sscanf
// function through specialized calls. We're going to have to put a cap on the number of args that
// can be passed, 8 for the moment. Sigh.
static void* sVarArgs[20];
U32 numArgs = 0;
for (const char* search = format; *search != '\0'; search++) {
if (search[0] == '%' && search[1] != '%')
numArgs++;
}
AssertFatal(numArgs <= 20, "Error, too many arguments to lame implementation of dSscanf. Fix implmentation");
// Ok, we have the number of arguments...
for (U32 i = 0; i < numArgs; i++)
sVarArgs[i] = va_arg(args, void*);
va_end(args);
switch (numArgs) {
case 0: return 0;
case 1: return sscanf(buffer, format, sVarArgs[0]);
case 2: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1]);
case 3: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2]);
case 4: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3]);
case 5: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4]);
case 6: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5]);
case 7: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6]);
case 8: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7]);
case 9: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8]);
case 10: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9]);
case 11: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10]);
case 12: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11]);
case 13: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12]);
case 14: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13]);
case 15: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14]);
case 16: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14], sVarArgs[15]);
case 17: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14], sVarArgs[15], sVarArgs[16]);
case 18: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14], sVarArgs[15], sVarArgs[16], sVarArgs[17]);
case 19: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14], sVarArgs[15], sVarArgs[16], sVarArgs[17], sVarArgs[18]);
case 20: return sscanf(buffer, format, sVarArgs[0], sVarArgs[1], sVarArgs[2], sVarArgs[3], sVarArgs[4], sVarArgs[5], sVarArgs[6], sVarArgs[7], sVarArgs[8], sVarArgs[9], sVarArgs[10], sVarArgs[11], sVarArgs[12], sVarArgs[13], sVarArgs[14], sVarArgs[15], sVarArgs[16], sVarArgs[17], sVarArgs[18], sVarArgs[19]);
}
return 0;
#endif
}
S32 dFflushStdout()
{
return fflush(stdout);
}
S32 dFflushStderr()
{
return fflush(stderr);
}
void dQsort(void *base, U32 nelem, U32 width, S32 (QSORT_CALLBACK *fcmp)(const void *, const void *))
{
qsort(base, nelem, width, fcmp);
}

View file

@ -0,0 +1,97 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platform/platformThread.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformSemaphore.h"
#include <pthread.h>
//--------------------------------------------------------------------------
struct x86UNIXThreadData
{
ThreadRunFunction mRunFunc;
S32 mRunArg;
Thread * mThread;
void * mSemaphore;
x86UNIXThreadData()
{
mRunFunc = 0;
mRunArg = 0;
mThread = 0;
mSemaphore = 0;
};
};
//--------------------------------------------------------------------------
Thread::Thread(ThreadRunFunction func, S32 arg, bool start_thread)
{
x86UNIXThreadData * threadData = new x86UNIXThreadData();
threadData->mRunFunc = func;
threadData->mRunArg = arg;
threadData->mThread = this;
threadData->mSemaphore = Semaphore::createSemaphore();
mData = reinterpret_cast<void*>(threadData);
if (start_thread)
start();
}
Thread::~Thread()
{
join();
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(mData);
Semaphore::destroySemaphore(threadData->mSemaphore);
delete threadData;
}
static void *ThreadRunHandler(void * arg)
{
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(arg);
threadData->mThread->run(threadData->mRunArg);
Semaphore::releaseSemaphore(threadData->mSemaphore);
}
void Thread::start()
{
if(isAlive())
return;
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(mData);
Semaphore::acquireSemaphore(threadData->mSemaphore);
pthread_t threadID;
pthread_create(&threadID, NULL, ThreadRunHandler, mData);
}
bool Thread::join()
{
if(!isAlive())
return(false);
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(mData);
return(Semaphore::acquireSemaphore(threadData->mSemaphore));
}
void Thread::run(S32 arg)
{
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(mData);
if(threadData->mRunFunc)
threadData->mRunFunc(arg);
}
bool Thread::isAlive()
{
x86UNIXThreadData * threadData = reinterpret_cast<x86UNIXThreadData*>(mData);
bool signal = Semaphore::acquireSemaphore(threadData->mSemaphore, false);
if(signal)
Semaphore::releaseSemaphore(threadData->mSemaphore);
return(!signal);
}

View file

@ -0,0 +1,90 @@
//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "time.h"
#include <sys/time.h>
#include <sys/resource.h>
U32 x86UNIXGetTickCount();
//--------------------------------------
void Platform::getLocalTime(LocalTime &lt)
{
struct tm *systime;
time_t long_time;
time( &long_time ); // Get time as long integer.
systime = localtime( &long_time ); // Convert to local time.
lt.sec = systime->tm_sec;
lt.min = systime->tm_min;
lt.hour = systime->tm_hour;
lt.month = systime->tm_mon;
lt.monthday = systime->tm_mday;
lt.weekday = systime->tm_wday;
lt.year = systime->tm_year;
lt.yearday = systime->tm_yday;
lt.isdst = systime->tm_isdst;
}
U32 Platform::getTime()
{
time_t long_time;
time( &long_time );
return long_time;
}
U32 Platform::getRealMilliseconds()
{
// struct rusage usageStats;
// getrusage(RUSAGE_SELF, &usageStats);
// return usageStats.ru_utime.tv_usec;
return x86UNIXGetTickCount();
}
U32 Platform::getVirtualMilliseconds()
{
return x86UNIXState.currentTime;
}
void Platform::advanceTime(U32 delta)
{
x86UNIXState.currentTime += delta;
}
//------------------------------------------------------------------------------
//-------------------------------------- x86UNIX Implementation
//
//
static bool sg_initialized = false;
static U32 sg_secsOffset = 0;
//--------------------------------------
U32 x86UNIXGetTickCount()
{
// TODO: What happens when crossing a day boundary?
//
timeval t;
if (sg_initialized == false) {
sg_initialized = true;
gettimeofday(&t, NULL);
sg_secsOffset = t.tv_sec;
}
gettimeofday(&t, NULL);
U32 secs = t.tv_sec - sg_secsOffset;
U32 uSecs = t.tv_usec;
// Make granularity 1 ms
return (secs * 1000) + (uSecs / 1000);
}

View file

@ -0,0 +1,30 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/x86UNIXUtils.h"
#include <unistd.h>
#include <termios.h>
#include <stdio.h>
UnixUtils *UUtils = NULL;
UnixUtils utils;
UnixUtils::UnixUtils()
{
UUtils = this;
}
bool UnixUtils::inBackground()
{
int terminalGroupId = tcgetpgrp(fileno(stdin));
int myPid = getpid();
if (terminalGroupId != myPid)
return true;
else
return false;
}

View file

@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#ifndef _X86UNIXUTILS_H_
#define _X86UNIXUTILS_H_
class UnixUtils
{
public:
UnixUtils();
/**
Return true if we're running in the background, false otherwise.
There's no "standard" way to determine this in unix, but
modern job control unices should support the method described
here:
http://www.faqs.org/faqs/unix-faq/faq/part3/
(question 3.7)
*/
bool inBackground();
};
extern UnixUtils *UUtils;
#endif

File diff suppressed because it is too large Load diff