premake4 build: allow to dynamically load X11 if X11 system headers/library is missing
premake4 build: allow to dynamically load OpenGL/GLEW/glx if system headers are missing
This commit is contained in:
@@ -182,7 +182,63 @@ void DemoApplication::toggleIdle() {
|
||||
}
|
||||
}
|
||||
|
||||
void bCreateDiagonalMatrix(GLfloat value, GLfloat result[4][4])
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
{
|
||||
if (i==j)
|
||||
{
|
||||
result[i][j] = value;
|
||||
} else
|
||||
{
|
||||
result[i][j] = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bCreateOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar, GLfloat result[4][4])
|
||||
{
|
||||
bCreateDiagonalMatrix(1.f,result);
|
||||
|
||||
result[0][0] = 2.f / (right - left);
|
||||
result[1][1] = 2.f / (top - bottom);
|
||||
result[2][2] = - 2.f / (zFar - zNear);
|
||||
result[3][0] = - (right + left) / (right - left);
|
||||
result[3][1] = - (top + bottom) / (top - bottom);
|
||||
result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
}
|
||||
|
||||
void bCreateLookAt(const btVector3& eye, const btVector3& center,const btVector3& up, GLfloat result[16])
|
||||
{
|
||||
btVector3 f = (center - eye).normalized();
|
||||
btVector3 u = up.normalized();
|
||||
btVector3 s = (f.cross(u)).normalized();
|
||||
u = s.cross(f);
|
||||
|
||||
result[0*4+0] = s.x();
|
||||
result[1*4+0] = s.y();
|
||||
result[2*4+0] = s.z();
|
||||
|
||||
result[0*4+1] = u.x();
|
||||
result[1*4+1] = u.y();
|
||||
result[2*4+1] = u.z();
|
||||
|
||||
result[0*4+2] =-f.x();
|
||||
result[1*4+2] =-f.y();
|
||||
result[2*4+2] =-f.z();
|
||||
|
||||
result[0*4+3] = 0.f;
|
||||
result[1*4+3] = 0.f;
|
||||
result[2*4+3] = 0.f;
|
||||
|
||||
result[3*4+0] = -s.dot(eye);
|
||||
result[3*4+1] = -u.dot(eye);
|
||||
result[3*4+2] = f.dot(eye);
|
||||
result[3*4+3] = 1.f;
|
||||
}
|
||||
|
||||
|
||||
void DemoApplication::updateCamera() {
|
||||
@@ -246,9 +302,9 @@ void DemoApplication::updateCamera() {
|
||||
glFrustum (-aspect * m_frustumZNear, aspect * m_frustumZNear, -m_frustumZNear, m_frustumZNear, m_frustumZNear, m_frustumZFar);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(m_cameraPosition[0], m_cameraPosition[1], m_cameraPosition[2],
|
||||
m_cameraTargetPosition[0], m_cameraTargetPosition[1], m_cameraTargetPosition[2],
|
||||
m_cameraUp.getX(),m_cameraUp.getY(),m_cameraUp.getZ());
|
||||
GLfloat resultMat[16];
|
||||
bCreateLookAt(m_cameraPosition,m_cameraTargetPosition, m_cameraUp, resultMat);
|
||||
glMultMatrixf(resultMat);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1054,7 +1110,7 @@ void DemoApplication::setOrthographicProjection()
|
||||
// reset matrix
|
||||
glLoadIdentity();
|
||||
// set a 2D orthographic projection
|
||||
gluOrtho2D(0, m_glutScreenWidth, 0, m_glutScreenHeight);
|
||||
glOrtho(0, m_glutScreenWidth, 0, m_glutScreenHeight,-1000,1000);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include "GLDebugFont.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
|
||||
|
||||
#ifdef DONT_USE_GLUT
|
||||
#else
|
||||
#ifdef _WIN32//for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@@ -44,7 +46,7 @@ subject to the following restrictions:
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h> //for memset
|
||||
|
||||
|
||||
@@ -299,51 +299,6 @@ void GL_ShapeDrawer::drawSphere(btScalar radius, int lats, int longs)
|
||||
}
|
||||
}
|
||||
|
||||
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
|
||||
{
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
switch (upAxis)
|
||||
{
|
||||
case 0:
|
||||
glRotatef(-90.0, 0.0, 1.0, 0.0);
|
||||
glTranslatef(0.0, 0.0, -halfHeight);
|
||||
break;
|
||||
case 1:
|
||||
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
||||
glTranslatef(0.0, 0.0, -halfHeight);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
glTranslatef(0.0, 0.0, -halfHeight);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GLUquadricObj *quadObj = gluNewQuadric();
|
||||
|
||||
//The gluCylinder subroutine draws a cylinder that is oriented along the z axis.
|
||||
//The base of the cylinder is placed at z = 0; the top of the cylinder is placed at z=height.
|
||||
//Like a sphere, the cylinder is subdivided around the z axis into slices and along the z axis into stacks.
|
||||
|
||||
gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
|
||||
gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
|
||||
|
||||
gluDisk(quadObj,0,radius,15, 10);
|
||||
|
||||
gluCylinder(quadObj, radius, radius, 2.f*halfHeight, 15, 10);
|
||||
glTranslatef(0.0f, 0.0f, 2.f*halfHeight);
|
||||
glRotatef(-180.0f, 0.0f, 1.0f, 0.0f);
|
||||
gluDisk(quadObj,0.f,radius,15, 10);
|
||||
|
||||
glPopMatrix();
|
||||
gluDeleteQuadric(quadObj);
|
||||
}
|
||||
|
||||
GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
|
||||
{
|
||||
@@ -498,7 +453,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
{
|
||||
if(m_textureenabled&&(!m_textureinitialized))
|
||||
{
|
||||
GLubyte* image=new GLubyte[256*256*3];
|
||||
GLubyte* image=new GLubyte[256*256*4];
|
||||
for(int y=0;y<256;++y)
|
||||
{
|
||||
const int t=y>>4;
|
||||
@@ -508,20 +463,22 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
const int s=x>>4;
|
||||
const GLubyte b=180;
|
||||
GLubyte c=b+((s+t&1)&1)*(255-b);
|
||||
pi[0]=pi[1]=pi[2]=c;pi+=3;
|
||||
pi[0]=pi[1]=pi[2]=pi[3]=c;pi+=3;
|
||||
}
|
||||
}
|
||||
|
||||
glGenTextures(1,(GLuint*)&m_texturehandle);
|
||||
glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
||||
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
|
||||
//glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
|
||||
//glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D,3,256,256,GL_RGB,GL_UNSIGNED_BYTE,image);
|
||||
delete[] image;
|
||||
|
||||
|
||||
|
||||
glGenTextures(1,(GLuint*)&m_texturehandle);
|
||||
glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256 , 256 , 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||
delete[] image;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -691,21 +648,6 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
case CYLINDER_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
|
||||
int upAxis = cylinder->getUpAxis();
|
||||
|
||||
|
||||
float radius = cylinder->getRadius();
|
||||
float halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
|
||||
|
||||
drawCylinder(radius,halfHeight,upAxis);
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
return m_textureenabled;
|
||||
}
|
||||
|
||||
static void drawCylinder(float radius,float halfHeight, int upAxis);
|
||||
void drawSphere(btScalar r, int lats, int longs);
|
||||
static void drawCoordSystem();
|
||||
|
||||
|
||||
@@ -16,20 +16,18 @@ subject to the following restrictions:
|
||||
#define GLUT_STUFF_H
|
||||
|
||||
#ifdef DONT_USE_GLUT
|
||||
#ifdef _WIN32//for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#endif //DONT_USE_GLUT
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#define BT_ACTIVE_ALT 8192
|
||||
#define BT_ACTIVE_SHIFT 8193
|
||||
#define BT_ACTIVE_CTRL 8194
|
||||
#else //DONT_USE_GLUT
|
||||
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#ifndef DONT_USE_GLUT
|
||||
#include <GLUT/glut.h>
|
||||
#endif//DONT_USE_GLUT
|
||||
|
||||
#include <GLUT/glut.h>
|
||||
#else//(__APPLE__) && !defined (VMDMESA)
|
||||
|
||||
|
||||
@@ -39,17 +37,12 @@ subject to the following restrictions:
|
||||
#include <GL/glu.h>
|
||||
#else //_WINDOWS
|
||||
|
||||
#ifdef DONT_USE_GLUT
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else//DONT_USE_GLUT
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif//_WIN32
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif//_WIN32
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#endif//DONT_USE_GLUT
|
||||
#endif//_WINDOWS
|
||||
#endif //(__APPLE__) && !defined (VMDMESA)
|
||||
|
||||
@@ -58,11 +51,6 @@ subject to the following restrictions:
|
||||
#define BT_ACTIVE_SHIFT VK_LSHIFT
|
||||
#define BT_ACTIVE_CTRL VK_LCONTROL
|
||||
#else //_WINDOWS
|
||||
#ifdef DONT_USE_GLUT
|
||||
#define BT_ACTIVE_ALT 8192
|
||||
#define BT_ACTIVE_SHIFT 8193
|
||||
#define BT_ACTIVE_CTRL 8194
|
||||
#else//DONT_USE_GLUT
|
||||
#define BT_KEY_K 'k'
|
||||
#define BT_KEY_LEFT GLUT_KEY_LEFT
|
||||
#define BT_KEY_RIGHT GLUT_KEY_RIGHT
|
||||
@@ -81,12 +69,10 @@ subject to the following restrictions:
|
||||
#define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT
|
||||
#define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BT_USE_FREEGLUT
|
||||
#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop()
|
||||
#endif
|
||||
|
||||
#endif // DONT_USE_GLUT
|
||||
|
||||
|
||||
class DemoApplication;
|
||||
|
||||
Reference in New Issue
Block a user