My Final OpenGL Project: ChessGL3d

So I had an earlier post about starting my OpenGL experience for the first time. Well here is the culmination of my experience. I created a rough OpenGL version of Chess. I will post this as soon as I get some time. In the mean while, here are some screen shots. Enjoy.

OpenGL Display Lists And Sub Windows

I recently discovered after some needless frustration, that you need to declare display lists that contain model drawing information in all windows in which you wish to draw the model. For example, if I say:

glutSetWindow(main_window);
initDisplayLists();
...
void main_display()
{
   drawDisplayList();
}

It will work just fine. But if I try to do the same in a display function of the sub window it won’t draw. You need to call whatever init() function you create your models / display lists in AFTER setting the window. For example

glutSetWindow(main_window);
// do stuff

glutSetWindow(sub_window);
initDisplayLists();
...

void sub_display()
{
    drawDisplayList();
}

Hope that helps someone out there!

WPF Context Menu Not Showing Up

So I came across a problem with WPF and context menus. Whenever I added a context menu to a right click on a window or panel it would simple not open. The only time that a context menu would appear is when I right clicked on a button or label that was a child of the panel I added it to. I searched everywhere online for a solution and couldn’t find one. Finally, I figured it out myself. For some strange reason, a context menu will not appear if you to not manually set a background color for a component or child component. So to fix the problem, simple set a background color for which components you want the top level context menu to appear.

My finest chess game yet

My best game of chess yet. I’m black.

How To: Dual Monitors in Ubuntu with Nvidia

I noticed that a lot of people are getting “cannot parse xorg.conf” message when they try to set up dual monitors with Nvidia settings manager in ubuntu. Here is the solution.

On the command line:

sudo nvidia-xconfig

You should see it tell you that it overrode your xorg.conf. If you get warnings don’t worry, it’s likely just indicating that there was a previous problem. Then on the command line again, type this:

sudo nvidia-settings

Now setup your dual monitor or triple monitor configuration as you want (with Twin View and the correct orientation). Then hit save configuration at the bottom and you should see that you get no error.

Reboot and enjoy.

Change Default Grub Settings In Ubuntu

I was surprised to see how wrong the entries on the Internet were about changing the default OS that grub boots into. Here are the correct instructions for how to do this (it has been tested on ubuntu 9.10).

sudo gedit /etc/default/grub

Then change the GRUB_DEFAULT=0 line to the number that you want to boot. i.e. if you are trying to boot into the 5 entry in the grub bootloader, put 5. You can also change the number of second grub will wait before booting using GRUB_TIMEOUT.

Then you need to update grub:

sudo update-grub

If you see something like this, congrats! You did it!

Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done

Reboot to see the changes.

New Material

Recently switched around my courses and I plan to post a game as my final project from my interactive computer graphics class. For now here is my first screenshots from my first open gl programs. Pretty straightforward stuff but I thought it’d be worth while to post for posterity.


My First OpenGL Program (assignment)


My First Original OpenGL Program (not sure what the lines are supposed to be)

Compiling OpenGL on Mac OS X or Linux

Most linux distributions make it easy to compile programs using OpenGL. Other systems, however, aren’t so easy. Here are instructions on how to get it running in both platforms.

Ubuntu / Linux

  1. Make sure you install the opengl-mesa packages for opengl development. On ubuntu you can get them all with the following invocation:
    sudo apt-get install freeglut3-dev
  2. You should include the following #includes in your code referencing opengl:
    #  include <GL/gl.h>
    #  include <GL/glu.h>
    #  include <GL/glut.h>
  3. You should also have the following gcc cmdline flags in your makefile:
    gcc -o simple simple.c -lGL -lglut -lGLU

Mac OS X (tested on Snow Leopard)

  1. For this to work you will have to install gcc and Xcode, which should install all the required opengl/glut libraries. You can get it here.
  2. Now, you’ll have to alter all the #includes in your files to conform to the proper location. Change all your opengl #includes to the following:
    #  include <OpenGL/gl.h>
    #  include <OpenGL/glu.h>
    #  include <GLUT/glut.h>
  3. Additionally your gcc command line will need to contain the following flags to link, along with any others you might have:
    gcc -o simple simple.c -framework Carbon -framework OpenGL -framework GLUT

Cross Platform Compatibility

If you want your code to run on both, you need to get the Makefile and code to load the proper libraries depending on your system.

In all your OpenGL .c files, add the following header instead of your linux/mac includes:

#ifdef __APPLE__
#  include <OpenGL/gl.h>
#  include <OpenGL/glu.h>
#  include <GLUT/glut.h>
#else
#  include <GL/gl.h>
#  include <GL/glu.h>
#  include <GL/glut.h>
#endif

Then in your makefile, add the following before your build targets:

#default cmdline flags
LDFLAGS	= -lGL -lglut -lGLU
# Mac OS alternate cmdline link options
ifeq "$(OSTYPE)" "Darwin"
	LDFLAGS	= -framework Carbon -framework OpenGL -framework GLUT
endif

Series Renamer

I have been trying to gain access to an amazing application I recently came across. It’s know as Series Renamer and is a windows app that makes renaming and organizing your TV video files amazingly easy. If you are in the process of ripping your DVD collection then this makes the hassle of renaming all of those files as simple as selecting the correct show and episode.

I have contacted the project owner about helping out. It’ll be the first public open source project I’ve ever participated in.

Series Renamer Site

First post from my iPhone

My first post from my iPhone.

Return top