zaterdag 30 november 2013

SDL: unresolved external symbol _tmainCRTStartup

When compiling a C++ program with SDL, I got the error:  unresolved external symbol _tmainCRTStartup

You solve the problem using:

#include <SDL.h>
#undef main


woensdag 27 november 2013

Assimp: merge meshes into one

Assimp is a great library for loading OpenGL models. At the moment I'm using SketchUp to create some 3D models and I export them using the "OBJ" format. Assimp can load this "OBJ" format but does not join all the meshes into one.
If you are using the internet sample "Importing 3D Models with Assimp" you see that the drawing in OpenGL loops over all the meshes. Every drawcall is a roundtrip from the CPU to the GPU and back, so you want to prevent that. So you want to merge all meshes into one.

This is possible in assimp using the flag aiProcess_OptimizeGraph. Some code:
scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality | aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);