I wanted to write about GLSL clip planes, but you will find that Prideout wrote about it and it pretty much says what it has to say. Here it is, Clip Planes: http://github.prideout.net/clip-planes/
Sometimes you’re writing code and need a quick way to enable/disable a section of code. That happens to me and most probably it happens to you too. I know of 2 ways to do this. You’ll need to change a character and compile the file, but that’s it. This does not allow you to change things in runtime, it’s all in compile time.
We can use C/C++ multiline comments /* */, to enable/disable blocks of code by changing a character. Check the following example:
/**/ glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDepthMask( GL_FALSE ); glEnable( GL_STENCIL_TEST ); /*/ glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glDepthMask( GL_TRUE ); glDisable( GL_DEPTH_TEST ); glDisable( GL_STENCIL_TEST ); /**/
To enable the second block -and disable the first- change /**/ into /*/ from the first line.
An alternative to the comment method is to use the #if #endif preprocessor directives. Using the same code example, if we wanted to enable the first block we’ll change it as follows:
#if 1 glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDepthMask( GL_FALSE ); glEnable( GL_STENCIL_TEST ); #else glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glDepthMask( GL_TRUE ); glDisable( GL_DEPTH_TEST ); glDisable( GL_STENCIL_TEST ); #endif
To switch blocks, change #if 1 to #if 0. That’s pretty much it.
The example code above is not the best example at all, but take it as just that. An example. During your code sessions you’ll find better use for this i’m sure about that. Hope it helps.
I’ve been trying to get AntTweakBar (version 116) to compile and run as my default GUI but ended up finding some obstacles that took me a couple days to find a solution. Should have been a smooth ride, but ended up in a couple of crazy days and an easy solution found just minutes ago.
Let’s begin with some information. It was pretty easy to compile following the instructions found on the website. Under Windows it took a few minutes to get it up and running, even as a Static Library. Problems began when i’ve tried to compile on OS X 10.9:
- It reports 2 errors with the declaration of glDrawElements and glShaderSource. It differs from the declaration from GL header.
Easy fix: Just copy the declaration from GL header to ATB.
- Compiling as a static library was OK. After reading it’s change log i realised they have static library support but i had taken the longest path and was trying to get it done manually, so it took me more time that i had planned.
After some time, i finally got the wanted the static library compiled and linking successfully, i got the following error:
“AntTweakBar: OpenGL Core Profile functions cannot be loaded.
ERROR(AntTweakBar) >> Cannot load OpenGL library dynamically”
Tracked that problem down to the line:
gl_dyld = dlopen("OpenGL", RTLD_LAZY );
gl_dyld was always NULL, which tells me the library wasn’t being loaded/found (really?!). The fix i found is to change the first parameter to use the full path to OpenGL as follows:
gl_dyld = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY );
It is a very simple fix and worked just fine for me, but, it took me a few days of frustration and travel. After all i was supposed to get this up and running last Thursday. It’s nearly one week later.
I was thinking about better ways to organize my work and life and how fragmented everything was. I store information & data in many different places sometimes it’s easy to lose track and speaking for myself, I don’t really feel organized and secure. Back in the days I would have a document (or multiple) with everything in it and a folder per section. This was not the best option of course, but atleast it gave me a good feeling about myself, and it worked for me. After building up my list I noticed all was in my head and I don’t really use that much software to keep track on what i do. It just feels different. Also I ended up writing down more than organization software, I wrote all of it.
This is a list of software that i use on a daily basis for both personal & professional projects (no special order)
- Visual Studio / XCode / Make / Eclipse ( code/development )
- Disk Order / Total Commander ( file management and browsing )
- KeyRemap4MacBook ( mapping keys )
- Witch ( switching between windows a la Windows OS )
- HyperDock ( aplication’s windows management )
- Dropbox ( data storage )
- Dash ( code snippets )
- Google Tasks / Reminders ( reminders and tasks )
- Notes ( notes and ideas )
- Billings ( time tracking )
- Sourcetree ( source control )
- Skype ( live chat and voice calls )
- Pocket ( read it later )
- Feedly ( RSS feeds )
- 1password ( secure information )
- Google Docs ( document sharing )
- Paint .NET ( image manipulation )
- Twitter ( news and follow ups )
Following the previous post, here is a funny trick on user input. After playing with Oculus Rift i noticed a cute trick using bits for camera control. By switching bits on/off one can update a Camera’s direction vector with a byte. This allows us to accumulate directions with one variable and some states.