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);

donderdag 25 juli 2013

C++ copy-by-value problems

In C++, copy-by-value is default. If you do the following:

Node n = grid[i][j];
n.x = 100;

you have a new object called n, which is not the same object as grid[i][j].
To solve the situation, you can do:

Node& n = grid[i][j];
n.x = 100;

The &n is the same as &grid[i][j] in this case.

woensdag 26 juni 2013

Oracle: System account resetten

System account resetten op Oracle XE:
> Aanloggen op de server waar Oracle staat.
> De SQL prompt starten.
> connect
> (als username de volgende tekst) /as sysdba
> ALTER USER system ACCOUNT UNLOCK
/
> alter user system identified by NewPasswordHere
/
> exit

vrijdag 31 mei 2013

Using GLFW x64 Visual Studio 2010

Using GLFW x64 Visual Studio 2010:

First compile GLFW with Visual Studio 2010. The solution file is in the support directory. Load the .sln file. Create an x64 active solution platform. Compile with configuration manager option "Release" and your new created "x64" solution platform.
Don't forget to include "GLFW.h".

In ProjectProperties/Linker/System/Subsystem, you can set if the application is a console application or a window application.

If you get: LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
Solve this by setting LIBCMT in the ProjectProperties/Linker/Input/Ignore Specific Default Libraries.

If you get: LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
Solve this by setting the ProjectProperties/Linker/General/Enable Incremental Linking to NO.

dinsdag 21 mei 2013

QueryPerformanceCounter not reliable

If you have a threaded application running on a multicore computer QueryPerformanceCounter can (and will) return different values depending on which core the code is executing on.

http://stackoverflow.com/questions/1825720/c-high-precision-time-measurement-in-windows

I've tested timeGetTime() , but it is also not accurate.