medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a4d2d1fb6d6aeca33c42fde8b7d92cc730ce2deb
parent 4c98757ce2194a224149e1dcc42729a7c4ab7a51
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Aug  5 20:53:59 +0200

Get the heightmap renderer/preprocessor to work on OS X

Diffstat:
Makefile | 20+++++++++++++++++---
gl.cc | 4++++
heightmap.cc | 2+-
heightmap.h | 2+-
terrain_manager.cc | 8++++++--
5 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -all: bsp hm pp +all: hm pp BSPSRCS = bsp.cc bsp_renderer.cc gl.cc BSPOBJS := $(patsubst %.cc,%.o,$(BSPSRCS)) @@ -11,8 +11,22 @@ PPOBJS := $(patsubst %.cc,%.o,$(PPSRCS)) WARNINGS = -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-write-strings CXXFLAGS += -std=c++11 -O2 $(WARNINGS) -ggdb3 -DGL_GLEXT_PROTOTYPES -LDFLAGS += -lm -lGL -lGLEW -lglfw -LDFLAGS += -lGLU + +# OS detection +uname := $(shell uname -s) + +ifneq ($(uname),Darwin) + LDFLAGS += -lGL -lGLEW -lglfw + LDFLAGS += -lGLU +else + # 8) + CXXFLAGS += -I/usr/local/Cellar/glfw3/3.1.1/include + CXXFLAGS += -I/usr/local/Cellar/glm/0.9.6.3/include + CXXFLAGS += -I/usr/local/Cellar/glew/1.12.0/include + LDFLAGS += -lm -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo + LDFLAGS += -L/usr/local/Cellar/glfw3/3.1.1/lib -lglfw3 + LDFLAGS += -L/usr/local/Cellar/glew/1.12.0/lib -lGLEW +endif picky: WARNINGS += -Wunused-parameter -Wunused-function -Wwrite-strings picky: all diff --git a/gl.cc b/gl.cc @@ -74,6 +74,7 @@ GLFWwindow * GL::init() { glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API ); glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE ); + glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE ); glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 ); glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 2 ); @@ -91,7 +92,10 @@ GLFWwindow * GL::init() { } glEnable( GL_DEBUG_OUTPUT ); + + #ifndef __APPLE__ glDebugMessageCallback( gl_error_printer, nullptr ); + #endif warnx( "Version %s", glGetString( GL_VERSION ) ); warnx( "Vendor %s", glGetString( GL_VENDOR ) ); diff --git a/heightmap.cc b/heightmap.cc @@ -2,7 +2,7 @@ #include <string> -#include <GL/gl.h> +#include "opengl.h" #include <glm/glm.hpp> #include <glm/gtc/type_ptr.hpp> diff --git a/heightmap.h b/heightmap.h @@ -3,7 +3,7 @@ #include <string> -#include <GL/gl.h> +#include <OpenGL/gl3.h> #include <glm/glm.hpp> #include "int.h" diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -16,6 +16,10 @@ #include "heightmap.h" #include "terrain_manager.h" +int iabs( const int x ) { + return x < 0 ? -x : x; +} + TerrainManager::TerrainManager( const std::string & dir ) : dir( dir ) { FILE * dims = fopen( ( dir + "/dims.txt" ).c_str(), "r" ); fscanf( dims, "%d %d", &w, &h ); @@ -28,10 +32,10 @@ TerrainManager::TerrainManager( const std::string & dir ) : dir( dir ) { const int ry = ty - REGION_HALF; if( rx == ry || rx == -ry ) { - lods[ tx ][ ty ] = std::max( 1, std::abs( rx ) + std::abs( ry ) - 1 ); + lods[ tx ][ ty ] = std::max( 1, iabs( rx ) + iabs( ry ) - 1 ); } else { - lods[ tx ][ ty ] = std::max( std::abs( rx ), std::abs( ry ) ); + lods[ tx ][ ty ] = std::max( iabs( rx ), iabs( ry ) ); } tiles[ tx ][ ty ].init();