Tuesday, May 22, 2012

Some Great Netbeans shortcuts

Just thought it was cool to see some of the shortcuts for code completion that exist in Netbeans Java.

Here is a link to the post: http://netbeans.dzone.com/top-10-interesting-netbeans-shortcuts

Oh and the shortcut for cold folding is ctrl+shift+minus = collapse, ctrl+shift+plus = expand.

Saturday, May 12, 2012

A Good Place to Start OpenGL

Many people want to learn OpenGL. Most of these people have no idea where to start. About everyone will learn OpenGL in some deprecated or round-a-bout way that discourages them from continuing their studies.

Well that's stupid and I'd like to at least point people in the right direction for getting started. This definitely isn't a tutorial, but I hope that it does serve to broaden your knowledge of available OpenGL tools, libraries and resources.

Here are the resources:

Basically you should walk through the samples provided over at g-truc to get an idea of what it means to create a current generation OpenGL project. The authors say that the code is not for beginners but they are only being modest and probably just don't intend for them to be used by beginners. I can honestly say that they are some of the best examples of OpenGL code available.

To build them on Windows for Visual Studio 2010 you need to install cmake. After that open up command line by running it as administrator. In this cmd window change to the samples folder that contains the /data, /external, /samples... the top level of the folder. Run the command [cmake -G "Visual Studio 10"]. Do not use the cmake GUI for this as it won't work. Now you should have vs2010 projects built that you can explore by opening the .sln.

What I suggest that you do is copy the projects and get accustomed to how they use OpenGL to express themselves. Their image loading tool, GLI, is for bringing in images to the program to use as textures. FreeGLUT is a "make windows and other stuff" utility that some people use. I honestly think all GLUT stuff is lame and suggest you learn to use GLFW instead. GLM is a great way to encapsulate all of your math needs for things such as vectors and matricies (which you will make heavy use of). It gives you a portable math solution that works great with OpenGL.

Wednesday, May 9, 2012

School Parallel Project: OpenGL + Havok + Intel TBB

So I recently had to create a project for my class on parallel computing. It was a semester long project (with lots of homework in between on things like OpenMP, P Threads, CUDA, MPI and OpenCL )and I just recently finished it. I turned it in yesterday but found more time to benchmark it this morning. I will post the project here soon in some way so you can see it for your self but for now here are some stats from my two machines...


  • Laptop - [AMD Phenom 2 N830 [3-Core] 2.10 GHz] [8GB Ram] [Windows 7 64bit] [ATI Mobility Radeon HD 4200]
    • Single Threaded: 10fps
    • Multi Threaded: 15fps
  • Desktop - [Intel i7 2600 [4-Core Hyperthreaded] 3.40 GHz] [16GB Ram] [Windows 7 64bit] [nVidia GeForce GTX 480]
    • Single Threaded: 19fps
    • Multi Threaded: 75fps
Holy crap does it scale well... gDebugger reports poor desktop utilization on my 5th and 7th cores but all the same it's a crazy improvement. 

I'll post more later. Go TBB and Havok!

Tuesday, May 8, 2012

Windows: Getting the Device Context without painful setup

So I use OpenGL a lot. Because of this I use GLFW a lot. GLFW is like GLUT or Free GLUT or SDL or SFML except it's not lame (not saying these kits are all lame but GLUT is lame and SDL is lame lol ). GLFW is a lot more light weight and for me easier to work with.

Using GLFW to create your window and context is painless. However there is no obvious way to get your window's context from GLFW once it's made. In my case, I needed the context for an OpenGL OpenCL interop.

To get the window handle and device context you can go right after your glfwInit() and glfwOpenWindow(...) and call...


HWND *ptr_hwnd = GetForegroundWindow();
HDC ptr_dc = GetDC( *ptr_hwnd );


And that should do it! No pain, some gain. So long window setup code hello actually doing wtf you wanted to make the window for.

Friday, May 4, 2012

Asus P8 Z68-V Pro/GEN3 Blue Screen of Death

I recently upgraded my desktop for development I'll be doing this summer. When starting up Windows 7 I got a quick BSOD followed by a restart. Forums reveal that this issue isn't uncommon but none of the solutions seemed to work for me. Combining them did though...


  • Make sure you have/get Corsair Vengeance ram. It's made for the board and even has the board's picture on the front of the product's box lol.
  • In the bios, go to the auto tuning for overclocking and switch from Auto or Manual to XMP.
  • Go to your Advanced settings and...
    • Turn off all Marvell stuff. It's crap. It won't work (didn't for me and doesn't for most it seems).
    • Switch the SATA from AHCI to IDE.
Doing that fixed everything for me. The machine then started up fine and so did Windows. Hope this helps.

Also, you may want to go into your msconfig > startup and turn off like all of the non-essential stuff. I believe I have old software setup for my old AMD processor. My new Intel isn't jiving with it. Turning those off made my system stable. You may also just want to get a new hard drive (or wipe your existing one).

GLEW VS2010 Wont Link?!?!

This is quite a painful problem that can actually be solved easily if you know what to do.

You'll want to use the static library  (glew32s.lib) and define the preprocessor directive 'GLEW_STATIC'.
You should be able to just download the Windows binaries for this but you can build it yourself also if you'd like (it's also simple to do).

With Binaries:

  • Download glew (32 and 64 as you may need to try both. 32 will probably work though).
  • Properties > Linker > Input > Additional Dependencies : Add ( glew32s.lib, glu32.lib, opengl32.lib ).
  • Properties > General > Additional Library Directories : Add ( --your path to the glew libs-- ).
  • Properties > C/C++ > Preprocessor > Preprocessor Definitions : (Add --GLEW_STATIC-- ).
  • Copy the glew32.dll into the folder with your programs executable.
Building yourself:
  • Download glew.
  • Open up the build/vc6 project.sln.
  • Change build target from Debug to Release.
  • Go to the solution explorer on the right( or left ) side of VS2010 > right click static > build.
  • Copy the newly built .lib to what ever folder you use for your project's libraries.
  • Copy the glew32.dll into the folder with your programs executable.

And that should do it.

I can't stress enough how much of a rut I was stuck in trying to get this to work. Hours down the drain. Rage and frustration at an ever-living wall of linker errors for methods I knew should be linking.

So seriously, use the static build, make your call to glewInit(), and get back to the real work of your project.

Thanks for the solution go to ( many others not included here )

gDEBugger you a good life

Debugging graphics can be a pain. It definitely takes an amount of skill and knowledge that comes to you slowly over whats perhaps a long period of practice. Seeing an ambiguous error pop up and knowing that it has something to do with a color inside of a texture on the graphics device is something that may not be obvious to some.

There exists an amazing gift from humanity to itself (specifically the amazing developers at Graphic Remedy ), and it is called gDEBugger. Simply put it is a must have tool that will change the way you develop OpenGL applications for the better, without question. It's like Pix for DirectX (but I think it may be older and thus the original).

Some of it's features include pausing/breaking execution, examining every texture/buffer active, a performance report of your number of OpenGL calls made a frame, frame rate, examining the depth buffer and adjusting the Z-Near/Far, inverting textures, a full report of every active uniform on the device, all shaders in use, which shader program is currently active (I even think you can edit them in real time for hot changes, haven't tried it though so don't quote me), and tons more things like bottleneck locating by either killing all graphics, setting the view port to a 1x1 stenciled pixel... tons of stuff. This tool is a must.

You can get it for FREE. It's free. That's insane: http://www.gremedy.com/.

So yea. Don't say I never gave you anything lol.