Skip to content

Commit 3953702

Browse files
author
miccol
committed
fixed problem with GLUT and new versions of MACOS
1 parent 3ff114c commit 3953702

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
cmake_minimum_required(VERSION 2.8.3)
1+
cmake_minimum_required(VERSION 3.0)
22
project(BTpp)
33

44
set(CMAKE_BUILD_TYPE Release)
5-
add_definitions(-Wall -lglut -lGL -lgtest -std=c++11)
5+
add_definitions(-Wall -lglut -lGL -lgtest -std=c++11 -lX11)
66

77
# Needed for using threads
88
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
9+
10+
911
#########################################################
10-
# FIND GTest
12+
# FIND X11
1113
#########################################################
14+
find_package(X11 REQUIRED)
15+
include_directories(${X11_INCLUDE_DIR})
16+
link_directories(${X11_LIBRARIES})
17+
1218
find_package(GTest)
1319
include_directories(${GTEST_INCLUDE_DIRS})
1420
if(NOT GTEST_FOUND)
@@ -41,7 +47,14 @@ endif(NOT OPENGL_FOUND)
4147
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include/)
4248
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/gtest/include/)
4349

44-
#INCLUDE_DIRECTORIES(/usr/local/include/btpp/)
50+
if(APPLE)
51+
include_directories(AFTER "/opt/X11/include")
52+
set(CMAKE_OSX_ARCHITECTURES "x86_64")
53+
if(CMAKE_GENERATOR STREQUAL Xcode)
54+
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")
55+
endif()
56+
endif()
57+
4558

4659
file(GLOB_RECURSE BTHeadLibrary include/*.h)
4760

@@ -84,13 +97,13 @@ endif(GTEST_FOUND)
8497
# COMPILING SAMPLE EXAMPLE
8598
######################################################
8699
add_executable(btpp_example src/example.cpp ${BTSrcLibrary} ${BTHeadLibrary})
87-
target_link_libraries(btpp_example ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
100+
target_link_libraries(btpp_example ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${X11_LIBRARIES})
88101

89102
######################################################
90103
# COMPILING LIBRARY
91104
######################################################
92105
add_library(btpp SHARED ${BTSrcLibrary} ${BTHeadLibrary})
93-
target_link_libraries(btpp ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
106+
target_link_libraries(btpp ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${X11_LIBRARIES})
94107

95108
######################################################
96109
# INSTALLATION OF LIBRARY AND EXECUTABLE TO /usr/local

include/draw.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#ifndef DRAWTREE_H
22
#define DRAWTREE_H
33
#include <cstdlib>
4+
5+
#ifdef __APPLE__
6+
#include <GLUT/glut.h>
7+
#else
48
#include <GL/glut.h>
5-
#include <GL/glut.h>
9+
#endif
10+
611
#include <math.h>
712
#include<iostream>
813
#include<string>

include/exceptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace BT
1313
const char* Message;
1414
public:
1515
BehaviorTreeException(const std::string Message);
16-
const char* what();
1716
};
1817
}
1918

src/behavior_tree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void Execute(BT::ControlNode* root, int TickPeriod_milliseconds)
1919
{
2020
std::cout << "Start Drawing!" << std::endl;
2121
// Starts in another thread the drawing of the BT
22-
std::thread t(&drawTree, root);
22+
//std::thread t(&drawTree, root);
2323

2424
root->ResetColorState();
2525

src/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void drawTree(BT::ControlNode* tree_)
491491
XInitThreads();
492492
glutInit(&argc, argv);
493493
init = true;
494-
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE); // Antialiasing
494+
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE ); // Antialiasing
495495
glEnable(GL_MULTISAMPLE);
496496
}
497497
tree = tree_;

src/exceptions.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,3 @@ BT::BehaviorTreeException::BehaviorTreeException(const std::string Message)
1717
{
1818
this->Message = std::string("BehaviorTreeException: " + Message).c_str();
1919
}
20-
21-
const char* BT::BehaviorTreeException::what()
22-
{
23-
return Message;
24-
}

0 commit comments

Comments
 (0)