some compile fixes in debug font rendering
This commit is contained in:
@@ -14,7 +14,33 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include "GLDebugFont.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
|
||||
#ifdef WIN32//for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include "TargetConditionals.h"
|
||||
#if defined (TARGET_OS_IPHONE) || defined (TARGET_IPHONE_SIMULATOR)
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#define glOrtho glOrthof
|
||||
#else
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h> //for memset
|
||||
|
||||
@@ -48,10 +74,13 @@ void GLDebugResetFont(int screenWidth,int screenHeight)
|
||||
|
||||
}
|
||||
|
||||
#define USE_ARRAYS 1
|
||||
|
||||
void GLDebugDrawStringInternal(int x,int y,const char* string, const btVector3& rgb)
|
||||
{
|
||||
const char* string2 = "test";
|
||||
|
||||
|
||||
const char* string2 = "test";
|
||||
if (sTexture==-1)
|
||||
{
|
||||
GLDebugResetFont(sScreenWidth,sScreenHeight);
|
||||
@@ -59,7 +88,7 @@ const char* string2 = "test";
|
||||
if (strlen(string))
|
||||
{
|
||||
|
||||
glColor3f(rgb.getX(),rgb.getY(),rgb.getZ());
|
||||
glColor4f(rgb.getX(),rgb.getY(),rgb.getZ(),1.f);
|
||||
float cx;
|
||||
float cy;
|
||||
|
||||
@@ -80,12 +109,40 @@ const char* string2 = "test";
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glOrtho(0,sScreenWidth,0,sScreenHeight,-1,1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslated(x,sScreenHeight - y,0);
|
||||
glTranslatef(x,sScreenHeight - y,0);
|
||||
|
||||
#if USE_ARRAYS
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
#endif
|
||||
|
||||
GLfloat verts[] ={
|
||||
0.0f, 1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
1.0f, -1.0f, 0.0f,
|
||||
0.f,0.f,0.f
|
||||
};
|
||||
|
||||
GLfloat uv_texcoords[] = {
|
||||
0,0,
|
||||
0,0,
|
||||
0,0,
|
||||
0,0
|
||||
};
|
||||
verts[0] = 0; verts[1] = 0; verts[2] = 0;
|
||||
verts[3] = 16-1; verts[4] = 0; verts[5] = 0;
|
||||
verts[6] = 16-1; verts[7] = 16-1; verts[8] = 0;
|
||||
verts[9] = 0; verts[10] = 16-1; verts[11] = 0;
|
||||
|
||||
for (int i=0;i<int (strlen(string));i++)
|
||||
{
|
||||
char ch = string[i]-32;
|
||||
@@ -94,17 +151,32 @@ const char* string2 = "test";
|
||||
cx=float(ch%16) * 1./16.f;
|
||||
cy=float(ch/16) * 1./16.f;
|
||||
|
||||
uv_texcoords[0] = cx; uv_texcoords[1] = 1-cy-1./16.f;
|
||||
uv_texcoords[2] = cx+1./16.f; uv_texcoords[3] = 1-cy-1./16.f;
|
||||
uv_texcoords[4] = cx+1./16.f; uv_texcoords[5] = 1-cy;
|
||||
uv_texcoords[6] = cx; uv_texcoords[7] = 1-cy;
|
||||
#if USE_ARRAYS
|
||||
glTexCoordPointer(2,GL_FLOAT,0,uv_texcoords);
|
||||
glVertexPointer(3, GL_FLOAT, 0, verts);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
#else
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(cx,1-cy-1./16.f);
|
||||
|
||||
glVertex2i(0,0);
|
||||
glTexCoord2f(cx+1./16.f,1-cy-1./16.f);
|
||||
|
||||
glVertex2i(16 - 1,0);
|
||||
glTexCoord2f(cx+1./16.f,1-cy);
|
||||
|
||||
glVertex2i(16 - 1,16 -1);
|
||||
glTexCoord2f(cx,1-cy);
|
||||
|
||||
glVertex2i(0,16 -1);
|
||||
glEnd();
|
||||
glTranslated(10,0,0);
|
||||
#endif
|
||||
|
||||
glTranslatef(10,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +184,7 @@ const char* string2 = "test";
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
#if 1
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
@@ -121,9 +194,12 @@ const char* string2 = "test";
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glScalef(0.025,0.025,0.025);
|
||||
|
||||
#endif
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
#if USE_ARRAYS
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
#endif
|
||||
//glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,94 +14,14 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include "GL_DialogWindow.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
|
||||
|
||||
#include "GLDebugFont.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
// ---------------------------------------------------------------------------
|
||||
// Extensions
|
||||
|
||||
#ifndef __APPLE__
|
||||
typedef void (APIENTRY * PFNGLBindBufferARB)(GLenum target, GLuint buffer);
|
||||
typedef void (APIENTRY * PFNGLBindProgramARB)(GLenum target, GLuint program);
|
||||
typedef GLuint (APIENTRY * PFNGLGetHandleARB)(GLenum pname);
|
||||
typedef void (APIENTRY * PFNGLUseProgramObjectARB)(GLuint programObj);
|
||||
typedef void (APIENTRY * PFNGLTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
typedef void (APIENTRY * PFNGLActiveTextureARB)(GLenum texture);
|
||||
typedef void (APIENTRY * PFNGLClientActiveTextureARB)(GLenum texture);
|
||||
typedef void (APIENTRY * PFNGLBlendEquation)(GLenum mode);
|
||||
typedef void (APIENTRY * PFNGLBlendEquationSeparate)(GLenum srcMode, GLenum dstMode);
|
||||
typedef void (APIENTRY * PFNGLBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
|
||||
PFNGLBindBufferARB glBindBufferARB = NULL;
|
||||
PFNGLBindProgramARB glBindProgramARB = NULL;
|
||||
PFNGLGetHandleARB glGetHandleARB = NULL;
|
||||
PFNGLUseProgramObjectARB glUseProgramObjectARB = NULL;
|
||||
PFNGLTexImage3D glTexImage3D = NULL;
|
||||
PFNGLActiveTextureARB glActiveTextureARB = NULL;
|
||||
PFNGLClientActiveTextureARB glClientActiveTextureARB = NULL;
|
||||
PFNGLBlendEquation glBlendEquation = NULL;
|
||||
PFNGLBlendEquationSeparate glBlendEquationSeparate = NULL;
|
||||
PFNGLBlendFuncSeparate glBlendFuncSeparate = NULL;
|
||||
#ifndef GL_ARRAY_BUFFER_ARB
|
||||
# define GL_ARRAY_BUFFER_ARB 0x8892
|
||||
#endif
|
||||
#ifndef GL_ELEMENT_ARRAY_BUFFER_ARB
|
||||
# define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
|
||||
#endif
|
||||
#ifndef GL_ARRAY_BUFFER_BINDING_ARB
|
||||
# define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
|
||||
#endif
|
||||
#ifndef GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
|
||||
# define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
|
||||
#endif
|
||||
#ifndef GL_VERTEX_PROGRAM_ARB
|
||||
# define GL_VERTEX_PROGRAM_ARB 0x8620
|
||||
#endif
|
||||
#ifndef GL_FRAGMENT_PROGRAM_ARB
|
||||
# define GL_FRAGMENT_PROGRAM_ARB 0x8804
|
||||
#endif
|
||||
#ifndef GL_PROGRAM_OBJECT_ARB
|
||||
# define GL_PROGRAM_OBJECT_ARB 0x8B40
|
||||
#endif
|
||||
#ifndef GL_TEXTURE_3D
|
||||
# define GL_TEXTURE_3D 0x806F
|
||||
#endif
|
||||
#ifndef GL_TEXTURE0_ARB
|
||||
# define GL_TEXTURE0_ARB 0x84C0
|
||||
#endif
|
||||
#ifndef GL_ACTIVE_TEXTURE_ARB
|
||||
# define GL_ACTIVE_TEXTURE_ARB 0x84E0
|
||||
#endif
|
||||
#ifndef GL_MAX_TEXTURE_UNITS_ARB
|
||||
# define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
|
||||
#endif
|
||||
#ifndef GL_TEXTURE_RECTANGLE_ARB
|
||||
# define GL_TEXTURE_RECTANGLE_ARB 0x84F5
|
||||
#endif
|
||||
#ifndef GL_FUNC_ADD
|
||||
# define GL_FUNC_ADD 0x8006
|
||||
#endif
|
||||
#ifndef GL_BLEND_EQUATION
|
||||
# define GL_BLEND_EQUATION 0x8009
|
||||
#endif
|
||||
#ifndef GL_BLEND_EQUATION_RGB
|
||||
# define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
|
||||
#endif
|
||||
#ifndef GL_BLEND_EQUATION_ALPHA
|
||||
# define GL_BLEND_EQUATION_ALPHA 0x883D
|
||||
#endif
|
||||
#ifndef GL_BLEND_SRC_RGB
|
||||
# define GL_BLEND_SRC_RGB 0x80C9
|
||||
#endif
|
||||
#ifndef GL_BLEND_DST_RGB
|
||||
# define GL_BLEND_DST_RGB 0x80C8
|
||||
#endif
|
||||
#ifndef GL_BLEND_SRC_ALPHA
|
||||
# define GL_BLEND_SRC_ALPHA 0x80CB
|
||||
#endif
|
||||
#ifndef GL_BLEND_DST_ALPHA
|
||||
# define GL_BLEND_DST_ALPHA 0x80CA
|
||||
#endif
|
||||
#endif
|
||||
#define USE_ARRAYS 1
|
||||
|
||||
|
||||
GL_DialogWindow::GL_DialogWindow(int horPos,int vertPos,int dialogWidth,int dialogHeight, btCollisionObject* collisionObject,const char* dialogTitle)
|
||||
:m_dialogHorPos(horPos),
|
||||
@@ -133,6 +53,8 @@ static void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, u
|
||||
const GLfloat dx = +0.5f;
|
||||
const GLfloat dy = -0.5f;
|
||||
|
||||
GLfloat vVertices[] = {(GLfloat)_X0+dx,(GLfloat)_Y0+dy,(GLfloat)_X1+dx,(GLfloat)_Y1+dy};
|
||||
|
||||
bool antiAliased = false;
|
||||
if( antiAliased )
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -141,12 +63,25 @@ static void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, u
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef USE_ARRAYS
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glLineWidth(2.0f);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vVertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
#else
|
||||
glLineWidth(13.0f);
|
||||
glBegin(GL_LINES);
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glVertex2f((GLfloat)_X0+dx, (GLfloat)_Y0+dy);
|
||||
glColor4ub(GLubyte(_Color1>>16), GLubyte(_Color1>>8), GLubyte(_Color1), GLubyte(_Color1>>24));
|
||||
glVertex2f((GLfloat)_X1+dx, (GLfloat)_Y1+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
@@ -157,6 +92,28 @@ static void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsig
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#ifdef USE_ARRAYS
|
||||
GLfloat verts[] ={
|
||||
0.0f, 1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
1.0f, -1.0f, 0.0f,
|
||||
0.f,0.f,0.f
|
||||
};
|
||||
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
verts[0] = (GLfloat)horStart+dx; verts[1] = (GLfloat)vertStart+dy;
|
||||
verts[2] = (GLfloat)horEnd+dx; verts[3] = (GLfloat)vertStart+dy;
|
||||
verts[4] = (GLfloat)horEnd+dx; verts[5] = (GLfloat)vertEnd+dy;
|
||||
verts[6] = (GLfloat)horStart+dx; verts[7] = (GLfloat)vertEnd+dy;
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
#else
|
||||
glBegin(GL_QUADS);
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertStart+dy);
|
||||
@@ -167,6 +124,8 @@ static void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsig
|
||||
glColor4ub(GLubyte(argbColor01>>16), GLubyte(argbColor01>>8), GLubyte(argbColor01), GLubyte(argbColor01>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertEnd+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::draw(btScalar deltaTime)
|
||||
@@ -222,7 +181,6 @@ void GL_DialogWindow::draw(btScalar deltaTime)
|
||||
int curVertPos = m_dialogVertPos;
|
||||
curVertPos += yInc;
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
GLDebugDrawString(m_dialogHorPos+m_dialogWidth/2-((strlen(m_dialogTitle)/2)*charWidth),m_dialogVertPos+yInc ,m_dialogTitle);
|
||||
curVertPos += 20;
|
||||
|
||||
@@ -238,28 +196,10 @@ void GL_DialogWindow::draw(btScalar deltaTime)
|
||||
|
||||
void GL_DialogWindow::saveOpenGLState()
|
||||
{
|
||||
|
||||
#if 0
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
|
||||
|
||||
if( glActiveTextureARB )
|
||||
{
|
||||
glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &m_PrevActiveTextureARB);
|
||||
int maxTexUnits = 1;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTexUnits);
|
||||
maxTexUnits = btMax(1, btMin(32, maxTexUnits));
|
||||
for( int i=0; i<maxTexUnits; ++i )
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB+i);
|
||||
m_PrevActiveTexture1D[i] = glIsEnabled(GL_TEXTURE_1D);
|
||||
m_PrevActiveTexture2D[i] = glIsEnabled(GL_TEXTURE_2D);
|
||||
m_PrevActiveTexture3D[i] = glIsEnabled(GL_TEXTURE_3D);
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_TEXTURE_3D);
|
||||
}
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPushMatrix();
|
||||
@@ -286,129 +226,25 @@ void GL_DialogWindow::saveOpenGLState()
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, m_ProjMatrixInit);
|
||||
|
||||
glGetFloatv(GL_LINE_WIDTH, &m_PrevLineWidth);
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
// glDisable(GL_POLYGON_STIPPLE);
|
||||
glLineWidth(1);
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
// glDisable(GL_LINE_STIPPLE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &m_PrevTexEnv);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glGetIntegerv(GL_POLYGON_MODE, m_PrevPolygonMode);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
//glEnable(GL_ALPHA_TEST);
|
||||
//glAlphaFunc(GL_GREATER, 0);
|
||||
glDisable(GL_FOG);
|
||||
glDisable(GL_LOGIC_OP);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
if( m_MaxClipPlanes<0 )
|
||||
{
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &m_MaxClipPlanes);
|
||||
if( m_MaxClipPlanes<0 || m_MaxClipPlanes>255 )
|
||||
m_MaxClipPlanes = 6;
|
||||
}
|
||||
for( int i=0; i<m_MaxClipPlanes; ++i )
|
||||
glDisable(GL_CLIP_PLANE0+i);
|
||||
m_PrevTexture = 0;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &m_PrevTexture);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
||||
|
||||
if( glBindBufferARB!=NULL )
|
||||
{
|
||||
m_PrevArrayBufferARB = m_PrevElementArrayBufferARB = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &m_PrevArrayBufferARB);
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &m_PrevElementArrayBufferARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
}
|
||||
if( glBindProgramARB!=NULL )
|
||||
{
|
||||
m_PrevVertexProgramARB = glIsEnabled(GL_VERTEX_PROGRAM_ARB);
|
||||
m_PrevFragmentProgramARB = glIsEnabled(GL_FRAGMENT_PROGRAM_ARB);
|
||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
}
|
||||
if( glGetHandleARB!=NULL && glUseProgramObjectARB!=NULL )
|
||||
{
|
||||
m_PrevProgramObjectARB = (GLuint)glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
|
||||
glUseProgramObjectARB(0);
|
||||
}
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
if( glTexImage3D!=NULL )
|
||||
{
|
||||
m_PrevTexture3D = glIsEnabled(GL_TEXTURE_3D);
|
||||
glDisable(GL_TEXTURE_3D);
|
||||
}
|
||||
|
||||
if( m_SupportTexRect )
|
||||
{
|
||||
m_PrevTexRectARB = glIsEnabled(GL_TEXTURE_RECTANGLE_ARB);
|
||||
glDisable(GL_TEXTURE_RECTANGLE_ARB);
|
||||
}
|
||||
if( glBlendEquationSeparate!=NULL )
|
||||
{
|
||||
glGetIntegerv(GL_BLEND_EQUATION_RGB, &m_PrevBlendEquationRGB);
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &m_PrevBlendEquationAlpha);
|
||||
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
}
|
||||
if( glBlendFuncSeparate!=NULL )
|
||||
{
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &m_PrevBlendSrcRGB);
|
||||
glGetIntegerv(GL_BLEND_DST_RGB, &m_PrevBlendDstRGB);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &m_PrevBlendSrcAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &m_PrevBlendDstAlpha);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
if( glBlendEquation!=NULL )
|
||||
{
|
||||
glGetIntegerv(GL_BLEND_EQUATION, &m_PrevBlendEquation);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::restoreOpenGLState()
|
||||
{
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_PrevTexture);
|
||||
if( glBindBufferARB!=NULL )
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_PrevArrayBufferARB);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_PrevElementArrayBufferARB);
|
||||
}
|
||||
if( glBindProgramARB!=NULL )
|
||||
{
|
||||
if( m_PrevVertexProgramARB )
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
if( m_PrevFragmentProgramARB )
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
}
|
||||
if( glGetHandleARB!=NULL && glUseProgramObjectARB!=NULL )
|
||||
glUseProgramObjectARB((void*)m_PrevProgramObjectARB);
|
||||
if( glTexImage3D!=NULL && m_PrevTexture3D )
|
||||
glEnable(GL_TEXTURE_3D);
|
||||
if( m_SupportTexRect && m_PrevTexRectARB )
|
||||
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||
if( glBlendEquation!=NULL )
|
||||
glBlendEquation(m_PrevBlendEquation);
|
||||
if( glBlendEquationSeparate!=NULL )
|
||||
glBlendEquationSeparate(m_PrevBlendEquationRGB, m_PrevBlendEquationAlpha);
|
||||
if( glBlendFuncSeparate!=NULL )
|
||||
glBlendFuncSeparate(m_PrevBlendSrcRGB, m_PrevBlendDstRGB, m_PrevBlendSrcAlpha, m_PrevBlendDstAlpha);
|
||||
|
||||
glPolygonMode(GL_FRONT, m_PrevPolygonMode[0]);
|
||||
glPolygonMode(GL_BACK, m_PrevPolygonMode[1]);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, m_PrevTexEnv);
|
||||
glLineWidth(m_PrevLineWidth);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
@@ -420,23 +256,6 @@ void GL_DialogWindow::restoreOpenGLState()
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();
|
||||
|
||||
if( glActiveTextureARB )
|
||||
{
|
||||
int maxTexUnits = 1;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTexUnits);
|
||||
maxTexUnits = btMax(1, btMin(32, maxTexUnits));
|
||||
for( int i=0; i<maxTexUnits; ++i )
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB+i);
|
||||
if( m_PrevActiveTexture1D[i] )
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
if( m_PrevActiveTexture2D[i] )
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if( m_PrevActiveTexture3D[i] )
|
||||
glEnable(GL_TEXTURE_3D);
|
||||
}
|
||||
glActiveTextureARB(m_PrevActiveTextureARB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -478,13 +297,8 @@ void GL_ToggleControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar delt
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, black,black,black,black);
|
||||
}
|
||||
|
||||
btVector3 rgb(1,1,0);
|
||||
btVector3 rgb(1,1,1);
|
||||
|
||||
if (!m_active)
|
||||
{
|
||||
rgb.setValue(1,1,1);
|
||||
}
|
||||
|
||||
GLDebugDrawStringInternal(parentHorPos2,parentVertPos+16,m_toggleText,rgb);
|
||||
parentVertPos2+=20;
|
||||
|
||||
|
||||
@@ -17,7 +17,32 @@ subject to the following restrictions:
|
||||
#define GL_DIALOG_WINDOW_H
|
||||
|
||||
class btCollisionObject;
|
||||
#include "GlutStuff.h"
|
||||
|
||||
|
||||
#ifdef WIN32//for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include "TargetConditionals.h"
|
||||
#if defined (TARGET_OS_IPHONE) || defined (TARGET_IPHONE_SIMULATOR)
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#define glOrtho glOrthof
|
||||
#else
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "LinearMath/btScalar.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
class btTypedConstraint;
|
||||
|
||||
@@ -37,30 +37,43 @@ renderTexture::renderTexture(int width,int height)
|
||||
|
||||
}
|
||||
|
||||
void renderTexture::grapicalPrintf(char* str, void* fontData, int startx,int starty)
|
||||
void renderTexture::grapicalPrintf(char* str, void* fontData, int rasterposx,int rasterposy)
|
||||
{
|
||||
unsigned char c;
|
||||
int rasterposx = startx;
|
||||
int rasterposy = starty;
|
||||
int x=0;
|
||||
int xx=0;
|
||||
|
||||
while ((c = (unsigned char) *str++)) {
|
||||
|
||||
x=xx;
|
||||
unsigned char* fontPtr = (unsigned char*) fontData;
|
||||
char ch = c-32;
|
||||
|
||||
int sx=ch%16;
|
||||
int sy=ch/16;
|
||||
|
||||
|
||||
unsigned char* bitmap = 0;//&fontData->bitmap_data[cd.data_offset];
|
||||
for (int y=0;y<8;y++)
|
||||
for (int i=sx*16;i<(sx*16+16);i++)
|
||||
{
|
||||
int bit = 128;
|
||||
for (int x=0;x<8;x++)
|
||||
int y=0;
|
||||
for (int j=sy*16;j<(sy*16+16);j++)
|
||||
{
|
||||
char packedColor = bitmap[y];
|
||||
float colorf = packedColor & bit ? 0.f : 1.f;
|
||||
unsigned char packedColor = (fontPtr[i*3+255*256*3-(256*j)*3]);
|
||||
//float colorf = packedColor ? 0.f : 1.f;
|
||||
float colorf = packedColor/255.;// ? 0.f : 1.f;
|
||||
btVector4 rgba(colorf,colorf,colorf,1.f);
|
||||
setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
|
||||
bit >>=1;
|
||||
//if (colorf)
|
||||
{
|
||||
//setPixel(rasterposx+x,rasterposy+y,rgba);
|
||||
addPixel(rasterposx+x,rasterposy+y,rgba);
|
||||
}
|
||||
//bit >>=1;
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
|
||||
rasterposx+= 8;
|
||||
//xx+=16;
|
||||
xx+=10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,19 @@ public:
|
||||
{
|
||||
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
|
||||
|
||||
pixel[0] = (unsigned char)(255*rgba.getX());
|
||||
pixel[1] = (unsigned char)(255*rgba.getY());
|
||||
pixel[2] = (unsigned char)(255*rgba.getZ());
|
||||
pixel[3] = (unsigned char)(255*rgba.getW());
|
||||
pixel[0] = (unsigned char)(255.*rgba.getX());
|
||||
pixel[1] = (unsigned char)(255.*rgba.getY());
|
||||
pixel[2] = (unsigned char)(255.*rgba.getZ());
|
||||
pixel[3] = (unsigned char)(255.*rgba.getW());
|
||||
}
|
||||
|
||||
inline void addPixel(int x,int y,const btVector4& rgba)
|
||||
{
|
||||
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
|
||||
pixel[0] = (unsigned char)btMin(255.f,((float)pixel[0] + 255.f*rgba.getX()));
|
||||
pixel[1] = (unsigned char)btMin(255.f,((float)pixel[1] + 255.f*rgba.getY()));
|
||||
pixel[2] = (unsigned char)btMin(255.f,((float)pixel[2] + 255.f*rgba.getZ()));
|
||||
// pixel[3] = (unsigned char)btMin(255.f,((float)pixel[3] + 255.f*rgba.getW()));
|
||||
}
|
||||
|
||||
inline btVector4 getPixel(int x,int y)
|
||||
|
||||
@@ -68,9 +68,9 @@ static btTransform transforms[maxNumObjects];
|
||||
renderTexture* raytracePicture = 0;
|
||||
|
||||
//this applies to the raytracer virtual screen/image buffer
|
||||
static int screenWidth = 100;
|
||||
static int screenWidth = 128;//256;
|
||||
//float aspectRatio = (3.f/4.f);
|
||||
static int screenHeight = 80;//screenWidth * aspectRatio;
|
||||
static int screenHeight = 64;//256;//screenWidth * aspectRatio;
|
||||
GLuint glTextureId;
|
||||
|
||||
btConeShape myCone(1,1);
|
||||
@@ -423,12 +423,12 @@ void Raytracer::displayCallback()
|
||||
{
|
||||
for (int y=0;y<screenHeight;y++)
|
||||
{
|
||||
btVector4 rgba(0.f,0.f,0.f,0.f);
|
||||
btVector4 rgba(0.2f,0.2f,0.2f,1.f);
|
||||
raytracePicture->setPixel(x,y,rgba);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
btVector3 rayTo;
|
||||
btTransform colObjWorldTransform;
|
||||
colObjWorldTransform.setIdentity();
|
||||
@@ -485,18 +485,64 @@ void Raytracer::displayCallback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
raytracePicture->grapicalPrintf("CCD RAYTRACER",&BMF_font_helv10);
|
||||
char buffer[256];
|
||||
sprintf(buffer,"%d RAYS / Frame",screenWidth*screenHeight*numObjects);
|
||||
raytracePicture->grapicalPrintf(buffer,&BMF_font_helv10,0,10);
|
||||
#endif
|
||||
|
||||
extern unsigned char sFontData[];
|
||||
if (0)
|
||||
{
|
||||
|
||||
char* text="ABC abc 123 !@#";
|
||||
int x=0;
|
||||
for (int cc = 0;cc<strlen(text);cc++)
|
||||
{
|
||||
|
||||
char testChar = text[cc];//'b';
|
||||
char ch = testChar-32;
|
||||
int startx=ch%16;
|
||||
int starty=ch/16;
|
||||
|
||||
|
||||
//for (int i=0;i<256;i++)
|
||||
for (int i=startx*16;i<(startx*16+16);i++)
|
||||
{
|
||||
int y=0;
|
||||
//for (int j=0;j<256;j++)
|
||||
//for (int j=0;j<256;j++)
|
||||
for (int j=starty*16;j<(starty*16+16);j++)
|
||||
{
|
||||
|
||||
btVector4 rgba(0,0,0,1);
|
||||
rgba[0] = (sFontData[i*3+255*256*3-(256*j)*3])/255.f;
|
||||
//rgba[0] += (sFontData[(i+1)*3+255*256*3-(256*j)*3])/255.*0.25f;
|
||||
//rgba[0] += (sFontData[(i)*3+255*256*3-(256*j+1)*3])/255.*0.25f;
|
||||
//rgba[0] += (sFontData[(i+1)*3+255*256*3-(256*j+1)*3])/255.*0.25;
|
||||
|
||||
//if (rgba[0]!=0.f)
|
||||
{
|
||||
rgba[1]=rgba[0];
|
||||
rgba[2]=rgba[0];
|
||||
rgba[3]=1.f;
|
||||
|
||||
//raytracePicture->setPixel(x,y,rgba);
|
||||
raytracePicture->addPixel(x,y,rgba);
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//raytracePicture->grapicalPrintf("CCD RAYTRACER",sFontData);
|
||||
char buffer[256];
|
||||
sprintf(buffer,"%d rays",screenWidth*screenHeight*numObjects);
|
||||
//sprintf(buffer,"Toggle",screenWidth*screenHeight*numObjects);
|
||||
//sprintf(buffer,"TEST",screenWidth*screenHeight*numObjects);
|
||||
//raytracePicture->grapicalPrintf(buffer,sFontData,0,10);//&BMF_font_helv10,0,10);
|
||||
raytracePicture->grapicalPrintf(buffer,sFontData,0,0);//&BMF_font_helv10,0,10);
|
||||
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
Reference in New Issue
Block a user