getting video tutorial rocks game running on ubuntu linux

My 8 year old  has been wanting me to write a computer game for here for some time.
I’m currently taking a second course in c++ and I do need the practice so what the heck.

I found this most excellent guide at: http://www.videotutorialsrock.com/opengl_tutorial/crab_pong/home.php

I thought perhaps I could hack up the code and getting it running in Ubuntu
So… I downloaded the source and created a code::blocks project and the first message error I get is this:

||=== crab_game, Debug ===|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|33|error: GL/glut.h: No such file or directory|
/home/jonas/crab_game/crab_game/gamedrawer.h|50|error: ‘GLuint’ does not name a type|
/home/jonas/crab_game/crab_game/gamedrawer.h|54|error: ‘GLuint’ does not name a type|
/home/jonas/crab_game/crab_game/gamedrawer.h|56|error: ‘GLuint’ does not name a type|
/home/jonas/crab_game/crab_game/gamedrawer.h|58|error: ‘GLuint’ does not name a type|
/home/jonas/crab_game/crab_game/md2model.h|66|error: ‘GLuint’ was not declared in this scope|
/home/jonas/crab_game/crab_game/md2model.h|66|error: template argument 1 is invalid|
/home/jonas/crab_game/crab_game/md2model.h|66|error: template argument 2 is invalid|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|78|error: ‘GLuint’ does not name a type|
/home/jonas/crab_game/crab_game/gamedrawer.cpp||In constructor ‘GameDrawer::GameDrawer()’:|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|114|error: ‘sandTextureId’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|114|error: ‘loadTexture’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|118|error: ‘waterTextureId’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp||In member function ‘void GameDrawer::setupBarriers()’:|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|160|error: ‘GLuint’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|160|error: expected ‘;’ before ‘textureId’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|163|error: expected ‘;’ before ‘barrierDisplayListId’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|164|error: ‘barrierDisplayListId’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|164|error: ‘GL_COMPILE’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|164|error: ‘glNewList’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|167|error: ‘GL_TEXTURE_2D’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|167|error: ‘glEnable’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|168|error: ‘textureId’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|168|error: ‘glBindTexture’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|169|error: ‘GL_TEXTURE_MIN_FILTER’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|169|error: ‘GL_LINEAR’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|169|error: ‘glTexParameteri’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|170|error: ‘GL_TEXTURE_MAG_FILTER’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|172|error: ‘GLfloat’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|172|error: expected ‘;’ before ‘materialColor’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|173|error: ‘GL_FRONT’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|173|error: ‘GL_AMBIENT_AND_DIFFUSE’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|173|error: ‘materialColor’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|173|error: ‘glMaterialfv’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|175|error: ‘glNormal3f’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|176|error: ‘GL_TRIANGLE_FAN’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|176|error: ‘glBegin’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|177|error: ‘glTexCoord2f’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|178|error: ‘glVertex3f’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|186|error: ‘glEnd’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|189|error: expected ‘;’ before ‘materialColor2’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|190|error: ‘materialColor2’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|192|error: ‘glDisable’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|193|error: ‘glColor3f’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|204|error: ‘GL_QUAD_STRIP’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|215|error: ‘glEndList’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|220|error: ‘barriersDisplayListId’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|220|error: ‘glGenLists’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|222|error: ‘GL_COLOR_MATERIAL’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|225|error: expected ‘;’ before ‘materialSpecular’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|226|error: ‘GL_SPECULAR’ was not declared in this scope|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|226|error: ‘materialSpecular’ was not declared in this scope|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options…|
||=== Build finished: 50 errors, 0 warnings ===|

Hm… Soo lets hack away at the errors:

I did a quick search and found this info: http://ubuntuforums.org/showthread.php?t=1108737

Ok..

I’m pretty sure I have the required libraries but I think I’ll try this

jonas@jonas5:~$ sudo apt-get install freeglut3 freeglut3-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
freeglut3 is already the newest version.
freeglut3 set to manually installed.
The following extra packages will be installed:
libice-dev libsm-dev libxext-dev libxt-dev x11proto-xext-dev
The following NEW packages will be installed:
freeglut3-dev libice-dev libsm-dev libxext-dev libxt-dev x11proto-xext-dev
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 904kB of archives.
After this operation, 3,002kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main libice-dev 2:1.0.6-1 [60.0kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/main libsm-dev 2:1.1.1-1 [26.6kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/main libxt-dev 1:1.0.7-1 [491kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/main x11proto-xext-dev 7.1.1-2 [27.2kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/main libxext-dev 2:1.1.1-2 [102kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid/main freeglut3-dev 2.6.0-0ubuntu2 [197kB]
Fetched 904kB in 8s (107kB/s)
Selecting previously deselected package libice-dev.
(Reading database … 382664 files and directories currently installed.)
Unpacking libice-dev (from …/libice-dev_2%3a1.0.6-1_i386.deb) …
Selecting previously deselected package libsm-dev.
Unpacking libsm-dev (from …/libsm-dev_2%3a1.1.1-1_i386.deb) …
Selecting previously deselected package libxt-dev.
Unpacking libxt-dev (from …/libxt-dev_1%3a1.0.7-1_i386.deb) …
Selecting previously deselected package x11proto-xext-dev.
Unpacking x11proto-xext-dev (from …/x11proto-xext-dev_7.1.1-2_all.deb) …
Selecting previously deselected package libxext-dev.
Unpacking libxext-dev (from …/libxext-dev_2%3a1.1.1-2_i386.deb) …
Selecting previously deselected package freeglut3-dev.
Unpacking freeglut3-dev (from …/freeglut3-dev_2.6.0-0ubuntu2_i386.deb) …
Processing triggers for man-db …
Setting up libice-dev (2:1.0.6-1) …
Setting up libsm-dev (2:1.1.1-1) …
Setting up libxt-dev (1:1.0.7-1) …
Setting up x11proto-xext-dev (7.1.1-2) …
Setting up libxext-dev (2:1.1.1-2) …
Setting up freeglut3-dev (2.6.0-0ubuntu2) …
jonas@jonas5:~$

Ok… So I’m missing something the dev

Soo… Now I left with these error.

/home/jonas/crab_game/crab_game/imageloader.cpp||In function ‘Image* loadBMP(const char*)’:|
/home/jonas/crab_game/crab_game/imageloader.cpp|141|warning: suggest parentheses around ‘&&’ within ‘||’|
/home/jonas/crab_game/crab_game/md2model.cpp|363|error: ‘strlen’ was not declared in this scope|
/home/jonas/crab_game/crab_game/md2model.cpp|364|error: ‘strcmp’ was not declared in this scope|
/home/jonas/crab_game/crab_game/md2model.cpp||In member function ‘void MD2Model::setAnimation(const char*)’:|
/home/jonas/crab_game/crab_game/md2model.cpp|439|error: ‘strlen’ was not declared in this scope|
/home/jonas/crab_game/crab_game/md2model.cpp|440|error: ‘strncmp’ was not declared in this scope|
||=== Build finished: 4 errors, 1 warnings ===|

Hmm.
According to http://www.cplusplus.com/reference/clibrary/cstring/strlen/

I need to #include <string.h> so I added that to the top of md2model.cpp.  (Not sure if thats the best spot but lets see what happens.)

Uggg… We’re not there yet… Now I get this.

obj/Debug/gamedrawer.o||In function (anonymous namespace)::loadTexture(Image*)':|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|80|undefined reference to
glGenTextures’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|81|undefined reference to glBindTexture'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|89|undefined reference to
glTexImage2D’|
obj/Debug/gamedrawer.o||In function GameDrawer::setupBarriers()':|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|163|undefined reference to
glGenLists’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|164|undefined reference to glNewList'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|167|undefined reference to
glEnable’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|168|undefined reference to glBindTexture'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|169|undefined reference to
glTexParameteri’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|170|undefined reference to glTexParameteri'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|173|undefined reference to
glMaterialfv’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|175|undefined reference to glNormal3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|176|undefined reference to
glBegin’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|177|undefined reference to glTexCoord2f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|178|undefined reference to
glVertex3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|181|undefined reference to glTexCoord2f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|184|undefined reference to
glVertex3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|186|undefined reference to glEnd'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|190|undefined reference to
glMaterialfv’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|192|undefined reference to glDisable'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|193|undefined reference to
glColor3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|194|undefined reference to glNormal3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|195|undefined reference to
glBegin’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|196|undefined reference to glVertex3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|199|undefined reference to
glVertex3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|201|undefined reference to glEnd'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|204|undefined reference to
glBegin’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|207|undefined reference to glNormal3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|209|undefined reference to
glVertex3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|212|undefined reference to glVertex3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|214|undefined reference to
glEnd’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|215|undefined reference to glEndList'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|220|undefined reference to
glGenLists’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|221|undefined reference to glNewList'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|222|undefined reference to
glDisable’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|226|undefined reference to glMaterialfv'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|227|undefined reference to
glMaterialf’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|231|undefined reference to glPushMatrix'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|232|undefined reference to
glTranslatef’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|233|undefined reference to glCallList'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|234|undefined reference to
glPopMatrix’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|237|undefined reference to glEnable'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|242|undefined reference to
glMaterialfv’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|243|undefined reference to glMaterialfv'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|245|undefined reference to
glEndList’|
obj/Debug/gamedrawer.o||In function GameDrawer::setupPole()':|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|249|undefined reference to
glGenLists’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|250|undefined reference to glNewList'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|251|undefined reference to
glDisable’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|252|undefined reference to glColor3f'|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|255|undefined reference to
glNormal3f’|
/home/jonas/crab_game/crab_game/gamedrawer.cpp|256|undefined reference to `glBegin’|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options…|
||=== Build finished: 50 errors, 0 warnings ===|

I got myself confused with the code:blocks linker settings and I wound up asking for directions before I figured out what was going on.
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=292961&#Post292961
and
http://ubuntuforums.org/showthread.php?t=1701528
Anyway.. the linker settings in code::blocks need to be as follows:

-lGL -lGLU -lglut

As you can see.  I got it work.

Now, I need to study how this ticks and see if I can hack it up a bit to turn it into a game for my kid…

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *