Wednesday, February 26, 2014

OpenGL Application Development in Windows 8.1 64-bit

I've been doing some OpenGL application development with Visual Studio 2012 for a week or so but I found it rather frustrating because M$ doesn't provide all headers required by C99 standards. Moreover, I have yet to configure GLSL syntax highlighting successfully in Visual Studio 2012. Well, it turned out it's much better to carryout OpenGL-related development with MinGW and using CodeBlocks as the IDE.

You can download CodeBlocks from www.codeblocks.org and use the 64-bit MinGW distribution from http://nuwen.net/mingw.html. The only missing library would be freeglut for MinGW which you can download from http://www.transmissionzero.co.uk/software/freeglut-devel/. The MinGW distribution from Stephan T. Lavavej (nuwen.net) already has GLEW in it, but it doesn't have glut or freeglut.

The way I setup my development environment as follows:
  1. Use CodeBlocks as the IDE, i.e. download and use CodeBlocks distribution that DOESN'T include MinGW because we are going to use the one from nuwen.net.
  2. Use nuwen.net MinGW as the source for base GCC, GLEW and GLM tools, libraries and includes.
  3. Use Freeglut for MinGW as the glut replacement.
Assuming you have setup all of the tools above correctly (consult their README files), it's time to create a sort of "Hello World" application in OpenGL. Head to http://en.wikibooks.org/wiki/OpenGL_Programming and try the first tutorial source code. This is how I create project in CodeBlocks for that tutorial:
  1. Create an empty project in CodeBlocks.
  2. Add all tutorial 01 source code from the basics arc (http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction) into the empty project.
  3. Fix all required settings before building the project, i.e. compiler include directory search paths and libraries search paths. The details are explained below.
The following screen captures show the settings that I changed to compile tutorial 01 successfully. The tabs, menus and entries highlighted (in red box) are those that you should change according to your MinGW installation details.





Once everything compiled and linked successfully, you can run the application. This is how the application should look like.


Well done. Now, you can proceed developing all other OpenGL application in Windows without thinking about C99 and GLSL syntax highlighting matters :-).

Anyway, you could actually setup the compiler and linker setting in per-project basis in CodeBlocks via the Project|Build Option menu. Clicking this menu will open a similar dialog box as shown in the screenshot above. However, it will only apply to currently active project.

UPDATE:
-----------
- The CodeBlocks steps I mentioned above are rather brute force approach. I'll update it with a better solution in the future.

Tuesday, February 18, 2014

Up-to-Date OpenGL Tutorial for Beginner

I found the Swiftless series article on OpenGL at: OpenGL 2 Tutorials and OpenGL 4 Tutorials
to be very compelling for newbie on the subject. They are particularly easy to follow for complete newbie.
One thing that sets them apart from other articles on the subject is they cover recent implementation of OpenGL. Therefore, it's easier to follow on present day OpenGL library available on recent systems and also features supported by present day GPUs.

Nice stuff Swiftless. Kudos to your work :-)

If you want a quite lengthy but deep introduction, head to Learning Modern 3D Graphics Programming. This is the most complete tutorial I found on the Net so far. Well, it's very well structured for my taste. I think, it's even better than http://en.wikibooks.org/wiki/OpenGL_Programming.