Preparing to Learn OpenGL (Toolchain Setup)

Published December 17, 2012
Advertisement
Hello again everyone.

I am finally after a very long time going to be diving into 3D for my next project.
In order to do this I obviously need to learn a 3D api and after much evaluation I have
decided to learn OpenGL. The main reason for this is not because of its cross platform
support but because the style of the api melds with my brain much better then the COM based
Direct3D api. This is probably due to my strong roots and love for the C language but either
way I have made my choice.

I am going to be learning the Modern OpenGL style obviously starting with OpenGL 3.3.
There really is not many books out there on modern opengl so I will resort to using the
OpenGL Superbible 5th edition to get my feet wet. Sure it uses a GLTools wrapper library
but from what I can tell is eventually they teach you the stuff under that library so I will
be using it as a stepping stone to get a understanding and then supplement it with the more
advanced arcsynthesis tutorial and maybe the OpenGL 4.0 Shader Cookbook. I am hoping this will
give me a solid foundation to build off of.

With that in mind I need to configure the OpenGL Superbible to work with my Toolchain I have set up.
The superbible assumes use of Visual Studio, XCode, or Linux Makefiles. I currently don't use any of these.
First I am not on Linux even though I have strong roots with linux (My server runs on it) and development on
Linux my current laptop uses the Nvidia Optimus technology which currently has very poor Linux support.
So instead I put together a toolchain on Windows 8 in which I am somewhat comfortable with which I may adapt
in the future.

The current toolchain consists of MinGW/MSYS, CMake, Subversion and Sublime Text 2. MinGW is a gcc compiler for windows.
CMake is a cross platform build generator and Sublime Text 2 is a Non Free cross platform text editor that integrates
with TextMate bundles and is extensible through Python. Subversion is obviously a version control system. I could use git
or Mercurial but I am still having a hard time with the concept of DVCS so this is subject to change as well.

To use the OpenGL Superbible we have a few dependencies which are needed. The first is FreeGlut and the second is the
GLTools library. I got the code for the Superbible from the googlecode svn repo so I can get the source for GLTools.
I downloaded a newer version of FreeGlut from the website 2.8 the repo came with 2.6. I needed to build these with my
compiler so that they can properly link so I threw together 2 cmake files to do this. I made 4 directories under my
Documents folder 1 for FreeGlut's source, 1 for GLTools source, and 1 out of source build directory for each library.
The CMakeLists.txt file for each library went under the source directories. Then I ran cmake to generate MSYS Makefiles.
Then ran make. The make file places the libraries under a central C:\libs folder and also moves the headers there as well.
If you are interested here is the content of the CMakeLists.txt files. I used globbing for the source files which is bad
practice but in this case it does not matter because I will not be adding any more source files to the CMake projects.

GLTools CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(GLTools)
set(SRC_DIR "src/")
set(INC_DIR "include/")
set(BUILD_DIR ${PROJECT_BINARY_DIRECTORY}/libs/GLTools/libs)
file(COPY ${INC_DIR} DESTINATION ${BUILD_DIR}/../include)
file(GLOB SRC_CPP ${SRC_DIR}*.cpp)
file(GLOB SRC_C ${SRC_DIR}*.c)
include_directories(${INC_DIR})
add_library(GLTools ${SRC_CPP} ${SRC_C})
set_target_properties(GLTools PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIR})
target_link_libraries(GLTools Winmm Gdi32 OpenGL32)


FreeGlut CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(freeglut32_static)
set(SRC_DIR "src/")
set(INC_DIR "include/")
set(BUILD_DIR ${PROJECT_BINARY_DIRECTORY}/libs/freeglut-2.8.0/libs)
set(CMAKE_C_FLAGS "-O2 -c -DFREEGLUT_STATIC")
file(COPY ${INC_DIR} DESTINATION ${BUILD_DIR}/../include)
file(GLOB SRC_C ${SRC_DIR}*.c)
include_directories(${INC_DIR})
add_library(freeglut32_static ${SRC_C})
set_target_properties(freeglut32_static PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIR})
target_link_libraries(freeglut32_static)


I don't think the FreeGlut one is optimal because of the complexity of building the library.
It has been tested and does work so it should be fine. If I encounter any issues with the way
the library is built I will make sure to post and update.
So after running make under C:\libs I have the following structure

C:\libs
GLTools
include
GL
libs
freeglut-2.8.0
include
GL
libs


This structure will allow me to easily create CMake build for all of the chapters in the book as
I complete them. I know where the libraries are so I can easily link them and bring in the headers.
Kind of hackish but being that this is not a custom project it is the easiest way to ensure I can get
build up and running quickly.
That is all for this post hopefully it was helpful cya next time.
0 likes 2 comments

Comments

polyfrag
I see your Linux skills. What do you use your server for? Is it dedicated?
December 17, 2012 04:41 PM
blewisjr
It is a local intranet server. I use it as a Intranet NFS and as a VCS Server.
December 17, 2012 06:53 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement