Jump to content

  • Log In with Google      Sign In   
  • Create Account

Martins Mozeiko

Member Since 11 Sep 2005
Offline Last Active Mar 11 2016 09:28 PM

Posts I've Made

In Topic: best way to do branching logic in shaders?

22 February 2014 - 03:50 PM

Modern OpenGL implementations compile following :

if (cond) { x = A; } else { x = B; }

to something like this:

x = cond * A + (1 - cond) * B;

(actually they have much better opcodes to express this kind of code to hardware)


So I would recommend you to use actual if conditionals - GLSL compiler in some cases could optimize code much better than you manually introducing additional multiply operations.

In Topic: Alternative to SDL to use with TCC

03 January 2014 - 06:48 AM

You can always compile SDL to shared library - dll or so file. And use that instead of static lib.


As for initialization - only Android, iOS and PSP needs special code. Other platforms will work fine without SDL_main.

In Topic: Alternative to SDL to use with TCC

01 January 2014 - 12:31 PM

If you are not worried about Android/iOS/psp platforms, then you can simply define SDL_MAIN_HANDLED preprocessor symbol, and SDL won't override main.

In Topic: Performance problems at ~1,000,000 triangles. Am I doing something wrong?

01 January 2014 - 12:24 PM

First of all - get rid of glGetUniformLocation calls during drawing. Get those uniform locations after shader is linked, and store somewhere. Calling glGetSomething usually is expensive operation in OpenGL.


Also drawing only 36 vertices per draw call is very small number. You should be drawing much more to have high performance with large number of triangles. Look into Instancing.

Another thing to look into is uniform buffer object - uploading all uniforms at once could be much better that calling individual glUniformX functions per each uniform.

In Topic: std::vector<> vs cli::array<>

02 August 2013 - 11:31 PM

They are completely different beasts.

CLI array is not a "standard C++ array. They are managed arrays. It's like new [] operator in C++, but for managed heap. cli::array allocates memory in managed heap and garbage collects it to free the memory. 

std::vector allocates its memory from regular C++ heap and frees it when it goes out of scope.


^ is not for smart pointers. It is for managed pointers - they get garbage collected to free the memory.