Fix issues on Mac OS X

This commit is contained in:
Daniel Chappuis 2013-09-15 23:32:42 +02:00
parent 7ca5b88ce3
commit 76deef4358
10 changed files with 48 additions and 15 deletions

View File

@ -7,9 +7,6 @@ PROJECT(REACTPHYSICS3D)
# Where to build the library
SET(LIBRARY_OUTPUT_PATH lib/)
# Where to build the executables
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Options
OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" OFF)
OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF)

View File

@ -4,11 +4,14 @@ cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(CollisionShapes)
# Where to build the executable
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/collisionshapes/)
# Copy the shaders used for the demo into the build directory
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Copy the meshes used for the demo into the build directory
FILE(COPY "../common/meshes/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/meshes/")
FILE(COPY "../common/meshes/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/meshes/")
# Headers
INCLUDE_DIRECTORIES("../common/opengl-framework/src/" "../common/")

View File

@ -67,7 +67,11 @@ int main(int argc, char** argv) {
glutMouseFunc(mouseButton);
glutMotionFunc(mouseMotion);
glutKeyboardFunc(keyboard);
#ifdef USE_FREEGLUT
glutCloseFunc(finish);
#else
atexit(finish);
#endif
// Glut main looop
glutMainLoop();
@ -115,7 +119,10 @@ void keyboard(unsigned char key, int x, int y) {
// Escape key
case 27:
glutLeaveMainLoop();
#ifdef USE_FREEGLUT
// TODO : Check if we need to call finish() here
glutLeaveMainLoop();
#endif
break;
// Space bar

View File

@ -68,6 +68,7 @@ void Viewer::displayGUI() {
// Display the FPS
void Viewer::displayFPS() {
#ifdef USE_FREEGLUT
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, mCamera.getWidth(), mCamera.getHeight(), 0, -1, 1);
@ -80,4 +81,5 @@ void Viewer::displayFPS() {
std::stringstream ss;
ss << "FPS : " << fps;
glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)ss.str().c_str());
#endif
}

View File

@ -32,7 +32,11 @@
#include "maths/Vector2.h"
#include <string>
#include <GL/glew.h>
#include "GL/freeglut.h"
#ifdef __APPLE__
#include "GLUT/glut.h"
#else
#include "GL/freeglut.h"
#endif
namespace openglframework {

View File

@ -41,8 +41,7 @@ varying vec2 texCoords; // Texture coordinates
void main() {
// Compute the ambient term
//vec3 ambient = lightAmbientColor;
vec3 ambient = vertexColor.rgb + 0.0 * lightAmbientColor;
vec3 ambient = lightAmbientColor;
// Get the texture color
vec3 textureColor = vertexColor.rgb;
@ -59,8 +58,8 @@ void main() {
// Compute the specular term of light 0
vec3 V = normalize(-vertexPosCameraSpace);
vec3 H0 = normalize(V + L0);
float specularFactor = pow(max(dot(N, H0), 0), shininess);
if (diffuseFactor < 0) specularFactor = 0.0;
float specularFactor = pow(max(dot(N, H0), 0.0), shininess);
if (diffuseFactor < 0.0) specularFactor = 0.0;
vec3 specular = light0SpecularColor * specularFactor;
// Compute the final color

View File

@ -4,8 +4,11 @@ cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(Cubes)
# Where to build the executable
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/cubes/)
# Copy the shaders used for the demo into the build directory
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Headers
INCLUDE_DIRECTORIES("../common/opengl-framework/src/" "../common/")

View File

@ -66,7 +66,12 @@ int main(int argc, char** argv) {
glutMouseFunc(mouseButton);
glutMotionFunc(mouseMotion);
glutKeyboardFunc(keyboard);
#ifdef USE_FREEGLUT
glutCloseFunc(finish);
#else
atexit(finish);
#endif
// Glut main looop
glutMainLoop();
@ -114,7 +119,10 @@ void keyboard(unsigned char key, int x, int y) {
// Escape key
case 27:
glutLeaveMainLoop();
#ifdef USE_FREEGLUT
// TODO : Check if we need to call finish() here
glutLeaveMainLoop();
#endif
break;
// Space bar

View File

@ -4,8 +4,11 @@ cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(Joints)
# Where to build the executable
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/joints/)
# Copy the shaders used for the demo into the build directory
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Headers
INCLUDE_DIRECTORIES("../common/opengl-framework/src/" "../common/")

View File

@ -66,7 +66,11 @@ int main(int argc, char** argv) {
glutMouseFunc(mouseButton);
glutMotionFunc(mouseMotion);
glutKeyboardFunc(keyboard);
#ifdef USE_FREEGLUT
glutCloseFunc(finish);
#else
atexit(finish);
#endif
// Glut main looop
glutMainLoop();
@ -114,7 +118,10 @@ void keyboard(unsigned char key, int x, int y) {
// Escape key
case 27:
glutLeaveMainLoop();
#ifdef USE_FREEGLUT
// TODO : Check if we need to call finish() here
glutLeaveMainLoop();
#endif
break;
// Space bar