Skip navigation

Monthly Archives: December 2013

The weirdest shit. You have to ask OpenGL to normalize byte colors. So the correct call to glVertexAttribPointer would be:

glVertexAttribPointer( attribNo, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, squareColors);

I spent like 20 minutes looking for what the problem could be with my code when I tried to switch float colors to byte colors, all my colors were white. And it was just this `normalized` flag.

Advertisements

I effectively had this:

void fun( const char* msg )
{
  function = [msg](){
    // do something with msg
  }
}

Then call:

fun( string( "oh hi hello" ).c_str() ) ;

See what’s wrong? The string object whose char* ptr I passed to fun _dies_ immediately after the line executing call to fun runs. So the captured const char* ptr [msg] is invalid if function() runs at a later time (after return of call to fun())