administration mode
Pssst...Ferdy is the creator of JungleDragon, an awesome wildlife community. Visit JungleDragon

 

Article: OpenGL programming in Eclipse »

FERDY CHRISTANT - APR 26, 2007 (07:29:25 PM)

 

In an earlier article, I explained how to setup portable OpenGL programming in Visual Studio on Windows. Given my recent switch to Linux, I'm moving as much as I can to my Ubuntu setup. I've bend my mind around setting this up, and wasted many hours, only to find out how simple it really is. Goal is to setup OpenGL programming in Eclipse, with C++ as the programming language. Since there is little info on how to do this online, I'll hereby explain it, for others to take and for myself to remember should I ever have to do it again. Instructions should be similar, but vary a little, for other Linux distributions and IDEs.

Setting up Eclipse for C/C++ programming

Luckily, I have previously written an article about setting up Eclipse for C/C++ programming. By simply following the instructions in the article, you should be able to install Eclipse Callisto. The article also mentions that you need to install the C++ compiler and other tooling on top of it, since that is not part of Eclipse. For Ubuntu, this is a matter of installing g++ and gdb from the package manager. After that, you should be able to compile and run the helloworld example in forementioned example.

Installing GLUT and/or SDL

Before we continue the installation, we have a choice to make. On Linux, there are two major ways to do OpenGL programming, via GLUT or via SDL. In essence, both libraries make use of OpenGL, yet the way you interact with OpenGL commands differs. GLUT seems to be the most commonly used library, yet it has its limitation in the way you can control application flow. By contrast, the SDL library is sometimes more complex, but also more powerful. Both are simply a layer between your logic and the OpenGL API that in addition allow you to do window management and hardware interactions. Think of drawing screens, capturing keyboard input, loading images and playing sounds. For the remainder of this article, I will demonstrate how to setup both libraries and let you choose.

On my Ubuntu installation, SDL was already installed. I'm not sure of that is a default or not. To check what is installed, browse to your usr/include directory and check for the SDL directory. If it does not exist, use the package manager to install it.

To install GLUT, use the package manager to install the packages freeglut3 and freeglut3-dev. The library header files will be installed in /usr/include/GL. If you've made it this far, you are ready to put your setup to the test.

A simple GLUT project

Time to have some fun. In Eclipse, create a new project: File->New->Managed Make C++ Project. Name it "opengl_glut". After creation the project, you can expand it and browse through the includes. By default, everything in /usr/include is included in your project. This is good, this means that we can access the GLUT header files without any extra steps.

Before we can start the coding, there is one more thing to do. We need to tell the linker what libraries to include in the build. To do this, right-click on your project, choose properties. Next, choose C/C++ Build, and then Libraries under the GCC C++ Linker section. In the field libraries, add the value "glut". Click OK to confirm the project settings. 

 

Finally, done with the setup. Time for some code. Create a new source file below your project and call it "main.cpp".  Paste the following code in the file:

#include <GL/glut.h>
#define window_width  640
#define window_height 480
// Main loop
void main_loop_function()
{
// Z angle
static float angle;
// Clear color (screen) 
// And depth (used internally to block obstructed objects)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Load identity matrix
glLoadIdentity();
// Multiply in translation matrix
glTranslatef(0,0, -10);
// Multiply in rotation matrix
glRotatef(angle, 0, 0, 1);
// Render colored quad
glBegin(GL_QUADS);
glColor3ub(255, 000, 000); glVertex2f(-1,  1);
glColor3ub(000, 255, 000); glVertex2f( 1,  1);
glColor3ub(000, 000, 255); glVertex2f( 1, -1);
glColor3ub(255, 255, 000); glVertex2f(-1, -1);
glEnd();
// Swap buffers (color buffers, makes previous render visible)
glutSwapBuffers();
// Increase angle to rotate
angle+=0.25;
}
// Initialze OpenGL perspective matrix
void GL_Setup(int width, int height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, (float)width/height, .1, 100 );
glMatrixMode( GL_MODELVIEW );
}
// Initialize GLUT and start main loop
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(window_width, window_height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("GLUT Example!!!");
glutIdleFunc(main_loop_function);
GL_Setup(window_width, window_height);
glutMainLoop();
}

Let's run it. Right-click on your project in the outline, and choose Run as -> Local C/C++ Application. You should now see a rotating cube:

A simple SDL project

Creating a SDL project is very similar to a GLUT project. There is one difference in the setup, instead of telling the linker to include the "glut" library, you tell it to include the "SDL", "GLU" and "GL" libraries:

The only other difference is of course in your code. Again create a "main.cpp" source file. This time, paste the following code in the file:

#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#define window_width  640
#define window_height 480
// Keydown booleans
bool key[321];
// Process pending events
bool events()
{
SDL_Event event;
if( SDL_PollEvent(&event) )
{
switch( event.type )
{
case SDL_KEYDOWN : key[ event.key.keysym.sym ]=true ;   break;
case SDL_KEYUP   : key[ event.key.keysym.sym ]=false;   break;
case SDL_QUIT    : return false; break;
}
}
return true;
}
void main_loop_function()
{
float angle;
while( events() )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0,0, -10);
glRotatef(angle, 0, 0, 1);
glBegin(GL_QUADS);
glColor3ub(255, 000, 000); glVertex2f(-1,  1);
glColor3ub(000, 255, 000); glVertex2f( 1,  1);
glColor3ub(000, 000, 255); glVertex2f( 1, -1);
glColor3ub(255, 255, 000); glVertex2f(-1, -1);
glEnd();
SDL_GL_SwapBuffers();
// Check keypresses
if( key[SDLK_RIGHT] ){ angle-=0.5; }
if( key[SDLK_LEFT ] ){ angle+=0.5; }
}
}
// Initialze OpenGL perspective matrix
void GL_Setup(int width, int height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, (float)width/height, 0.1, 100 );
glMatrixMode( GL_MODELVIEW );
}
int main()
{
// Initialize SDL with best video mode
SDL_Init(SDL_INIT_VIDEO);
const SDL_VideoInfo* info = SDL_GetVideoInfo();	
int vidFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
if (info->hw_available) {vidFlags |= SDL_HWSURFACE;}
else {vidFlags |= SDL_SWSURFACE;}
int bpp = info->vfmt->BitsPerPixel;
SDL_SetVideoMode(window_width, window_height, bpp, vidFlags);
GL_Setup(window_width, window_height);
main_loop_function();
}

Run the project. Notice that the cube does not rotate initially, but you can using the left and right arrows of your keyboard.

Closing

This article is all about getting you started in OpenGL programming on Linux using Eclipse. I'll leave it up to you to actually learn what OpenGL can do and how you can use it, but trust me: the possibilities are endless and tons of fun :)

Disclaimers: This article assumes you have properly installed drivers for your video hard and that you have hardware acceleration working. This article is based upon a very helpful Ubuntu forum post, but narrowed down to the usage of Eclipse. 

Share |

Comments: 89
Reviews: 45
Average rating: rating
Highest rating: 5
Lowest rating: 4

COMMENT: JOE rating

MAY 28, 21:55:45

comment » Exactly what I needed! Thanks! «

COMMENT: GREG emailhomepagerating

JUN 3, 10:23:23 AM

comment » Thanks for this easy to read, easy to follow tutorial!

I have really enjoyed working with Eclipse for doing Java programming. I was hoping there was a plugin that allowed me to use it's nice interface, handy automatic compiling, and especially CVS integration for OpenGL and C/C++ (I sign up for a new free 10MB CVS account at http://www.cvsdude.com for most major projects I attempt now, and it integrates easily into Eclipse).

Thanks for taking the time to put this online. It was the first Google result for "eclipse c++ opengl", and it was a perfect find.

Thanks again! «

COMMENT: LIAM homepagerating

JUN 12, 15:26:30

comment » Excellent article! Now I can cross off one more item on my list of things I could only do in Windows.

I believe that programming games is key to learning how to become a good programmer. Until now I could not transfer my OpenGL skills from Windows/Visual C++ over to Linux. I kept losing interest before I had set up the environment I needed (IDE + API + compiler).

Tutorials like this one could help thousands of skilled programmers make it past that initial barrier and start making great 3D software for Linux!

Thanks again! «

COMMENT: SATISH VELLANKI emailhomepage

JUN 27, 04:45:14 AM

comment » Hi,

Thanks for the easy example.

I have a problem executing it.

I get (only) this error message on console:

DRM_I830_CMDBUFFER: -22

I am running on Ubuntu 7 with Beryl. I disabled Beryl and it works like a charm.

How can I make it work all the time?

Thanks in advance «

COMMENT: ZACHARY MANNING email

JUL 7, 01:34:17 AM

comment » I keep getting a an error about not having a binary when I got to run locally?

Any thoughts? «

COMMENT: NATE

JUL 23, 09:17:43 PM

comment » I had the same problem as Satish with DRM_I830_CMDBUFFER: -22 on the glut tutorial, but the SDL project works great. I'm new to 3d programming so any help would be appreciated. «

COMMENT: SNORTMAN rating

AUG 12, 04:18:06 AM

comment » very useful, thank you for a straight forward tutorial «

COMMENT: NE-YAWN emailrating

AUG 23, 09:59:30 AM

comment » Thanks a LOT.It was indeed very helpful. 01 01 «

COMMENT: JEREMY

SEP 14, 08:30:36 PM

comment » Thank you so much this is exactly what I needed!!! «

COMMENT: SARANN rating

OCT 18, 20:56:48

comment » You're amazing :-D I was looking for something to guide me through this process last year and in the end just gave up. Thank you!! «

COMMENT: DENYOS rating

OCT 23, 07:30:08 PM

comment » Tnx! This was exactly what i needed to get me started! Great Job! «

COMMENT: GOE rating

OCT 27, 16:30:36

comment » Thank you very much. You are my saver. «

COMMENT: CYBRID emailrating

NOV 15, 20:03:07

comment » I found your article very useful, but I've faced a problem I'm not able to solve, If you could help me, I would be very grateful. I've setupped SDL in Eclipse 3.3 with MinGW; and that works OK, but I also want to use SDL with OpenGL, and I cannot find witch libraries I should include in the linker params.

Thanks in advance. «

COMMENT: UMAIR AHMAD KHAN

NOV 24, 05:55:56 AM

comment » i have seen few comments asking for errors while running the code. let me tell you the fix.

i tried this tutorial on suse 10.3 and eclipse 3.3.0 eu when i installed the plugin there was no managed make c++ option and i was getting same error as mentioned in this comment.

"I keep getting a an error about not having a binary when I got to run locally?"

create an empty project right click and then properties -> c/c++ build then setting and under tool setting tab you can find gcc C++ linker settings and can add library

also as there is no managed make project so you need to right click -> make target -> create write name and target for make file

right click again -> make target -> build you can see the target name you mentioned in previous step.

press build

now run it will not give any error. 02

well i am noob on linux so i most prolly over doing few steps that may not be required. but it worked so me happy 18 «

COMMENT: FELIPE

FEB 7, 2008 - 11:16:02 PM

comment » Thanks for this. I really agree with what someone said above. Little and sometimes even simple barriers like not being able to integrate an IDE with some framework, etc., is what keeps people from trying out programming in Linux. And the same goes for many other topics on Linux.... «

COMMENT: MACIEK

MAR 11, 2008 - 11:39:37 PM

comment » @UMAIR AHMAD KHAN

I had this problem with CDT 4.0.2. In 4.0.3 there is no "managed" project but the respective fields are already present. «

COMMENT: GG rating

MAR 19, 2008 - 09:35:51 AM

comment » thank you for your help. Now I am programming with OpenGl under linux.

:) «

COMMENT: --- rating

MAR 22, 2008 - 05:01:35 AM

comment » Wow, this was exactly what I needed. Setting up OpenGL development with Eclipse on Ubuntu. And it worked. Hooray! «

COMMENT: SAUS

APR 8, 2008 - 09:30:07 PM

comment » I am having a bit of a problem with using the c++ project. All the opengl references are undefined. Odd thing is that if I put them in a c project all is well. I figure that opengl was compiled with a c compiler and not able to be used in g++. How do I fix this though?

05 «

COMMENT: SAUS

APR 8, 2008 - 09:48:30 PM

comment » Ok I have been doing a bit more research and I have found that the problem is with Eclipse. For some reason Eclipse does not like something with my C++ project. I will do some more fiddling and report the fix if I can come up with it. «

COMMENT: RYAN

APR 12, 2008 - 02:48:55 AM

comment » This was super helpful, thank you. «

COMMENT: ASMUND

APR 21, 2008 - 10:31:33 AM

comment » Thankyou! Just what I needed. «

COMMENT: TANAWAT TASSANA rating

APR 23, 2008 - 04:09:43 AM

comment » Thank you for this awesome tutorial!!! 18 «

COMMENT: TIBOLOGY rating

MAY 1, 2008 - 07:45:31 PM

comment » Cool, Thanx... «

COMMENT: CHRIS

MAY 25, 2008 - 11:33:18 PM

comment » Finally! After searching all day, reading reading this article solved my problems. Thanks! «

COMMENT: CORY rating

JUN 5, 2008 - 05:12:20 AM

comment » Thanks a metric ton! I just left my cozzy windows world and I was starting to get worried :) «

COMMENT: CURRAN emailhomepagerating

JUN 5, 2008 - 17:29:49

comment » This guide was very useful, thanks a lot! For those interested - have posted an up to date version of it (including GLEW also) for the latest versions of Eclipse and Ubuntu on my blog

http://lifeofaprogrammergeek.blogspot.com/2008/06/opengl-glut-and-glew-in-eclipse.html

Thanks again! It was a huge help! «

COMMENT: THGC rating

JUL 21, 2008 - 16:03:20

comment » Great job dude, worked fine for me, thanks «

COMMENT: NICK emailhomepage

JUL 26, 2008 - 11:09:03 AM

comment » Thanks a lot. This guide really helped me to begin with eclipse and opengl. «

COMMENT: SWTSVN

SEP 3, 2008 - 08:48:36 PM

comment » hi

could u also tell us hwo to install glew in windows eclipse? «

COMMENT: RICHARD THOMPSON emailhomepage

SEP 7, 2008 - 11:32:28

comment » Awesome guide man, I've wanted to do something like this in Linux for a long time, I'm new to the eclipse IDE and I love it, everything worked fine after a couple of tweaks, again, thanks for everything! 01 «

COMMENT: RICHARD THOMPSON emailrating

SEP 7, 2008 - 11:33:22

comment » Submit as Awesome «

COMMENT: V rating

SEP 8, 2008 - 08:44:56

comment » Just great, thanks. 18 «

COMMENT: SIMON rating

SEP 12, 2008 - 02:47:33 AM

comment » awesome!!! 18 «

COMMENT: MAURO

SEP 16, 2008 - 01:14:14 PM

comment » Thanks!!!!!

I spent hours and hours trying to figure out what librarys to include. I was using GLUT and including GL instead of simply including "glut" :S «

COMMENT: VANGUARD2K rating

SEP 21, 2008 - 08:53:50 AM

comment » Thanks a lot for this nice overview.

Although i have programmed cpp several times i have never managed to set up eclipse correctly (maybe partly because of lazyness).

With this guide i had no problem to run the test programs. Nice!

Thanks for it! «

COMMENT: LEONARD

OCT 12, 2008 - 02.56.52

comment » Hi, I'm noob with Eclipse, I did all what you sad but I received a lot of error like those:

freeglut (/home/myname/workspace/firstglut/Debug/firstglut): Unable to create direct context rendering for window 'GLUT Example!!!'

This may hurt performance.

X Error of failed request: BadMatch (invalid parameter attributes)

Major opcode of failed request: 161 (GLX)

Minor opcode of failed request: 5 (X_GLXMakeCurrent)

Serial number of failed request: 37

Current serial number in output stream: 37

Locking assertion failure. Backtrace:

#0 /usr/lib/libxcb-xlib.so.0 [0xb6ce4767]

#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_lock+0x2e) [0xb6ce481e]

#2 /usr/lib/libX11.so.6 [0xb7a6e518]

#3 /usr/lib/libX11.so.6(XESetCloseDisplay+0x31) [0xb7a518d1]

#4 /usr/lib/libGL.so.1 [0xb7bee7e9]

Maybe I have to switch output from console to a graphical output?!!

Also when I right click on a c++ project and "Run as" I can't find the option C/C++ local application....I don't know why. Right now eclipse is a mystery for me...some suggestion?

Bye «

COMMENT: LEONARD

OCT 12, 2008 - 11.24.20

comment » Hi everybody, I solve my problem re-installing the latest nvidia drivers for my ubuntu, bye and thanks for this guide 01 «

COMMENT: Z rating

NOV 5, 2008 - 04:16:38 DU.

comment » Thanks a lot, now it works for me too! «

COMMENT: JEREMY email

DEC 21, 2008 - 10:23:20 AM

comment » Thanks for this tutorial. I was on my third or fourth time of trying to install all the necessary stuff for programming OpenGL in the Linux environment. After reading your tutorial, I agree with you that it is very easy. Thanks again. «

COMMENT: KP email

JAN 28, 2009 - 09:23:18 PM

comment » So impressed...thank you for taking the time...really appreciated!!! 01 «

COMMENT: MM rating

JAN 30, 2009 - 06:37:09 AM

comment » Thanks! «

COMMENT: SREEKAR emailrating

FEB 1, 2009 - 07:10:55 AM

comment » awesome man... thanks a lot for the tutorial... btw can i ask as to which book should i read for getting a idea of concepts of linking etc...

thanks «

COMMENT: MARTON BIRO rating

MAR 10, 2009 - 09:34:58 DU.

comment » Thank you, it's working!

01 «

COMMENT: BART rating

JUN 23, 2009 - 10:20:15 PM

comment » Thanks! Perfect! «

COMMENT: GURIA

JUN 28, 2009 - 15:48:55

comment » thanks it is good example «

COMMENT: JACOB rating

JUL 3, 2009 - 10:16:12 PM

comment » Sweet it worked. «

COMMENT: EDGAR

JUL 23, 2009 - 10:33:28 PM

comment » Cool!

You Rock!

Had no problem at all

Thanks! 01 «

COMMENT: LINDSAY emailhomepage

AUG 7, 2009 - 11:11:06 AM

comment » Awesome, after five years away from C++ and OpenGL I saw the trailer for Tron2 this evening and thought to hell with it, I'm getting back into graphics in C++. Following this article I was up and into it in twenty minutes. «

COMMENT: MARTIN FROM GERMANY rating

OCT 14, 2009 - 15:53:12

comment » Thank you yery much!!! «

COMMENT: BJ

NOV 15, 2009 - 02:07:46 PM

comment » Thank you very much. I used someone else's tutorial from an older version of eclipse that wasn't working and I was just about to give up on eclipse, but this saved it. And I love the example program you gave. «

COMMENT: JOHN

NOV 17, 2009 - 03:37:16 AM

comment » I got the error about not having a binary.

Solution was to click on Project up in the menu option, and then do a Build All from there.

Then go back and do a Run As «

COMMENT: DANGERLEM rating

NOV 29, 2009 - 03:32:43 PM

comment » I tried setting up in Windows and it's always a fail. This one does it. Good thing there's virtual box and karmic koala. w00t! Ubuntu 1, Windows 0. 13 «

COMMENT: DEWESH KUMAR emailhomepage

DEC 29, 2009 - 11:08:17 AM

comment » That was awesome.I was trying since 2 days.

thanks for that.

How to get glaux for linux?

Thanks in advance.......... «

COMMENT: ANDREAS rating

JAN 2, 2010 - 06:31:26 PM

comment » Just wanted to say thanks so much for the guide, it worked on Ubuntu and has lifted a BIG headache of mine. 01

1337 thumbs up! «

COMMENT: MAN emailrating

JAN 13, 2010 - 12:36:25 AM

comment » Super, just what i needed forgetting hands on with my Bachelor project;-) «

COMMENT: TASH

JAN 17, 2010 - 09:02:34 AM

comment » Awesome tutorial...

Saved me uncountable hours

Cheers 01 «

COMMENT: RUSSELL THACKSTON emailhomepagerating

JAN 27, 2010 - 03:46:03 PM

comment » Awesome tutorial. Just what I needed. Thanks! «

COMMENT: MARIJA rating

FEB 9, 2010 - 11:09:46 AM

comment » Thank youuuuuuuu!!!!!!

This is great!!!!

I love to work in eclipse and I'm new in openGL

so this is great combination!!!!

Works for me:))) 07 «

COMMENT: MERGE

FEB 12, 2010 - 23:35:26

comment » thank you very much! «

COMMENT: DUCK

FEB 19, 2010 - 16:33:12

comment » Everything is great, but there is one problem: when I'm running the project there is no frame or menu bar how to fix it ?? «

COMMENT: BLAH rating

FEB 28, 2010 - 11:02:09 AM

comment » Thank you!! Direct and to the point, it's great. I was having a hard time figuring out to work this around - you're definitely a life savior 18 «

COMMENT: DMITRIY P.

MAR 21, 2010 - 21:31:02

comment » Very nice tutorial! Simple and good understandable. That it, what I'm searching for. Thank you very much. Very helpful. 17 «

COMMENT: NOSICLIN email

MAR 23, 2010 - 12:47:20 AM

comment » thank you ,now I can use opengl in eclipse, «

COMMENT: DEEP email

APR 18, 2010 - 12:53:44 PM

comment » I followed all the steps mentioned in the tutorial. However, when i run the program, i get the following error:

X Error of failed request: BadRequest (invalid request code or no such operation)

Major opcode of failed request: 143 (GLX)

Minor opcode of failed request: 19 (X_GLXQueryServerString)

Serial number of failed request: 11

Current serial number in output stream: 11

Please help me to figure out the problem. «

COMMENT: ANONYMOUS rating

APR 25, 2010 - 03:47:17

comment » Thank you «

COMMENT: ASHOK J emailrating

MAY 22, 2010 - 04:29:31 AM

comment » hi,

Thanks a lot.

There is a small correction for the libraries needed to make the first programing running.

It was not working with just adding glut into the libraries. I had to add GL and GLU also to make it working.

Even with that error .. your work is awsome.

thanks for your effort.

regards,

ashok. «

COMMENT: ALBERT rating

MAY 29, 2010 - 12:43:11 AM

comment » *doh* 23

this entire time i was missing the 'freeglut3-dev' package. I spent days manually trying to track down missing libraries.

those were two of the most important packages (along with their dependencies). If you didn't have those two packages installed; program won't compile. «

COMMENT: VV

JUN 15, 2010 - 07:53:12 AM

comment » thank you so much, it works so well under my ubuntu «

COMMENT: CUONG homepagerating

JUN 30, 2010 - 02:21:38 AM

comment » Thank you for this tutorial, very helpful.

Howver, I've got a linker error even though I followed exactly what described in the tut:

"undefined reference to gluPerspective"

It took me a few days to find out that the solution is to add 'GLU' in the Libraries section together with 'glut' (GLU must be capital). «

COMMENT: CODER emailhomepagerating

AUG 25, 2010 - 06:54:06 PM

comment » Thanks for posting this, very helpful...and thanks for posting the source code examples as well! :-) «

COMMENT: MIKE rating

SEP 19, 2010 - 18:10:49

comment » For the example with glut now on ubuntu 10.4 you also need to link with GLU in uppercase. «

COMMENT: ED

OCT 30, 2010 - 08:56:53 AM

comment » Very Very Good! «

COMMENT: ALEX email

NOV 17, 2010 - 01:02:47 AM

comment » Just a note for anyone having compile problems (with gluperspective) you also have to add GLU to the libraries field. «

COMMENT: JAMES rating

JAN 5, 2011 - 07:06:19 AM

comment » Amazing article! This was a really helpful tutorial. «

COMMENT: HAHN emailhomepagerating

FEB 3, 2011 - 04:18:25

comment » WOW! nice article!

and thanks to Alex.. i have same problems, can't compile that source. «

COMMENT: OSCAR WILDE emailhomepage

MAR 22, 2011 - 11:29:58 PM

comment »

HAHAHAHAHAHAHAHAHAHA! I'm using HTML! Neener Neener! «

COMMENT: PAULO CHEADI HADDAD FILHO rating

APR 3, 2011 - 10:35:46 PM

comment » CUONG's comment helped me with problem as he had.

Great article! 01 «

COMMENT: BRUNO HENRY emailhomepage

APR 16, 2011 - 03:21:31

comment » Thanks a lot man!! You were awasome!! That was the help I was looking for! 18 «

COMMENT: MIGUEL ORTIZ email

JUN 22, 2011 - 05:29:17

comment » Hi.

When you add libraries in your project, you should add -lglut and -lGLU, that means add GLU in "Libraries" option when you are using eclipse «

COMMENT: MARTIN R rating

OCT 27, 2011 - 20:39:26

comment » Superb! Now I have Eclipse working with SDL, ready to try out with some OpenGL programming. Your example is nice, but it had to figure out how to install SDL on my system by myself, since it wasn't installed by default (although that wasn't too hard, because your guide explained how everything works). Cheers! «

COMMENT: LINH emailrating

DEC 7, 2011 - 09:36:28 AM

comment » Thank you very much, this article very helpful for me :) «

COMMENT: TOMIG90 email

JAN 6, 2012 - 01:58:18 DU.

comment » Hi!

I do the tutorial on ubuntu 10.04 LTS.

I've got a problem:

Every glut method is OK, but every "glu*" is undefined reference: (

Even when i have this 3 line:

#include

#include

#include

gluPerspective or gluOrtho2d still don't work for me.

( i even tried to copy the name from the header, but it's still bad:(

someone any idea?

PS: sorry for my bad english :) «

COMMENT: AUTOGLITCH

JAN 8, 2012 - 05:47:01 PM

comment » TOMIG90 - I'm compiling this on Fedora 16 with Eclipse but I ran into the exact same issue. It's not the #include line in the .cpp file that you need to change, it's the libraries properties for the project.

I've got the latest version of eclipse and here is my step-by-step:

-Open your project

-Right click on the Project Folder in the "project explorer" window

-Select "Properties"

-Go to C/C++ Build > Settings

-Under the "Tools Settings" tab scroll down and expand "GCC C++ Linker"

-Select "Libraries"

-The top box is "Libraries (-l)". you should have both "glut" and "GLU" listed. If either are not then click the add button and type them in without quotes.

Save and recompile. I hope this helps. It's been a beast trying to learn linux, C++ and OpenGL all at ones :-) «

COMMENT: DEXTER email

JAN 11, 2012 - 01:34:59 PM

comment » "" Description Resource Path Location Type

make: *** No rule to make target `sample1'. opengl_glut line 0 C/C++ Problem""

i encountered the above error while following the above mentioned steps.....

pls help.... «

COMMENT: SSY

FEB 11, 2012 - 16:55:16

comment » "Thank you for this tutorial, very helpful.

Howver, I've got a linker error even though I followed exactly what described in the tut:

"undefined reference to gluPerspective"

It took me a few days to find out that the solution is to add 'GLU' in the Libraries section together with 'glut' (GLU must be capital). "

Thanks your comment has been super useful, and thanks for this tutorial too! «

COMMENT: RAY emailrating

FEB 20, 2012 - 05:38:39 PM

comment » Thanks so much for the tutorial! Oh and please edit the post to include a mention regarding the GLU link up- that would help. Thanks again! «

COMMENT: MARCELO email

APR 18, 2012 - 23:01:46

comment » Great!

Im using Ubuntu 11.04.

The package that i use are: freeglut3-dev for glut and libsdl1.2-dev for sdl.

In the example code for glut, the words for include in library session is "glut" and "GLU". However, the error "undefined reference to `gluPerspective'" is showed.

In the example for SDL, if i include the "GL" in libraries another error is formed while build "undefined reference to `glMatrixMode'". Just remove the reference to "GL" in libraries and everything works fine.

Thnks very much. «

COMMENT: ASH

JAN 31, 2013 - 09:27:46 AM

comment » More than 5 years ... and it still helps !!

Thanks «

RATE THIS CONTENT (OPTIONAL)
Was this document useful to you?
 
rating Awesome
rating Good
rating Average
rating Poor
rating Useless
CREATE A NEW COMMENT
required field
required field HTML is not allowed. Hyperlinks will automatically be converted.