C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 31st, 2005, 12:32 AM
Saumanahaii Saumanahaii is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 Saumanahaii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 59 sec
Reputation Power: 0
OpenGL Devc++ GLUT compilation problem

Code:
#include <gl\glut.h>
 
 void Initialize();
 void MouseHandler(int button, int state, int x, int y);
 void KeyboardHandler(unsigned char key, int x, int y);
 void MainMenuHandler(int option);
 void Animate();
 void Reshape(int width, int height);
 void Display();
 
 /**************************************************  **************************
  main()
 
  Setup GLUT and OpenGL, drop into the event loop
 **************************************************  ***************************/
 int main(int argc, char **argv)
 {
   // Setup the basic GLUT stuff
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
 
   // Create the window
   glutInitWindowSize(1024, 768);
   glutInitWindowPosition(100, 150);
   glutCreateWindow("BOGLGP Chapter 1");
 
   Initialize();
 
   // Register the event callback functions
   glutDisplayFunc(Display); 
   glutReshapeFunc(Reshape);
   glutMouseFunc(MouseHandler);
   glutKeyboardFunc(KeyboardHandler);
   glutIdleFunc(Animate);
 
   // At this point, control is relinquished to the GLUT event handler.
   // Control is returned as events occur, via the callback functions.
   glutMainLoop();   
    
   return 0;
 } // end main()
 
 
 /**************************************************  **************************
  Initialize()
 
  One time setup, including creating menus, creating a light, setting the
  shading mode and clear color, and loading textures.
 **************************************************  ***************************/
 void Initialize()
 {
   // set up the only meny
   int mainMenu;
 
   mainMenu = glutCreateMenu(MainMenuHandler);
 
   glutSetMenu(mainMenu);
   glutAddMenuEntry("Exit", 0);
   glutAttachMenu(GLUT_RIGHT_BUTTON);
 
   glEnable(GL_DEPTH_TEST);
 } // end Initialize()
 
 
 /**************************************************  **************************
  MouseHandler()
  
  Handle mouse events. For this simple demo, just exit on a left click.
 **************************************************  ***************************/
 void MouseHandler(int button, int state, int x, int y)
 {
   switch (button)
   {
   case GLUT_LEFT_BUTTON:
 	{
 	  exit(0);
 	} break;
   default:
 	break;
   }
 
   // force a screen redraw
   glutPostRedisplay();
 } // end MouseHandler()
 
 
 /**************************************************  **************************
  KeyboardHandler()
 
  Keyboard handler. Again, we'll just exit when q is pressed.
 **************************************************  ***************************/
 void KeyboardHandler(unsigned char key, int x, int y)
 {
   switch (key)
   {
   case 'q':  // exit
 	{
 	  exit(0);
 	} break;
   default:
 	{
 	} break;
   }
   glutPostRedisplay();
 } // end KeyboardHandler()
 
 
 /**************************************************  **************************
  MainMenuHandler()
 
  Main menu callback.
 **************************************************  ***************************/
 void MainMenuHandler(int option)
 {
   switch(option)
   {
   case 0:
 	{
 	  exit(0);
 	} break;
   default:
 	break;
   }
   glutPostRedisplay();
 } // end MainMenuHandler()
 
 
 /**************************************************  **************************
  Animate()
 
  Rotate the cube by 4 degrees and force a redisplay.
 **************************************************  ***************************/
 void Animate()
 {
   glutPostRedisplay();
 } // end Animate()
 
 
 /**************************************************  **************************
  Reshape()
 
  Reset the viewport for window changes
 **************************************************  ***************************/
 void Reshape(int width, int height)
 {
   if (height == 0)
 	return;
 
   glViewport(0, 0, (GLsizei) width, (GLsizei) height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(90.0, width/height, 1.0, 100.0);
 
   glMatrixMode(GL_MODELVIEW);
 } // end Reshape
 
 
 /**************************************************  **************************
  Display()
 
  Clear and redraw the scene.
 **************************************************  ***************************/
 void Display()
 {
   // set up the camera
   glLoadIdentity();
   gluLookAt(0.0, 1.0, 6.0,
 			0.0, 0.0, 0.0,
 			0.0, 1.0, 0.0);
 
   // clear the screen
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
   // draw a triangle
   glBegin(GL_TRIANGLES);
 	glColor3f(1.0, 0.0, 0.0);
 	glVertex3f(2.0, 2.5, -1.0);
 	glColor3f(0.0, 1.0, 0.0);
 	glVertex3f(-3.5, -2.5, -1.0);
 	glColor3f(0.0, 0.0, 1.0);
 	glVertex3f(2.0, -4.0, 0.0);
   glEnd();
 
   // draw a polygon
   glBegin(GL_POLYGON);
 	glColor3f(1.0, 1.0, 1.0);
 	glVertex3f(-1.0, 2.0, 0.0);
 	glColor3f(1.0, 1.0, 0.0);
 	glVertex3f(-3.0, -0.5, 0.0);
 	glColor3f(0.0, 1.0, 1.0);
 	glVertex3f(-1.5, -3.0, 0.0);
 	glColor3f(0.0, 0.0, 0.0);
 	glVertex3f(1.0, -2.0, 0.0);
 	glColor3f(1.0, 0.0, 1.0);
 	glVertex3f(1.0, 1.0, 0.0);
   glEnd();
 
   // draw everything and swap the display buffer
   glutSwapBuffers();
 } // end Display()
 
 
 








This is some tutorial code from "Beginning OpenGL Game Programming. It supposedly compiles on MSVC++, but not on Devc++. I included the GLUT and glu libraries, but whenever I compile it I get an error stating that it cannot find -lobjc, and that ID returned 1 exit status. I thought that it might be a problem with my glut library, but that wouldn't compile either, giving me the same errors. I have no clue. I learned C++ in a high school class, and they taught us very little. I decided to make a tile based game engine with a matrix storing the value of each square, with each bmp or jpg designated to a number, 1-9. I decided to use opengl, but the code won't compile, and so I have no clue! If anyone has any ideas on how to get it working, of has some idea for achieving a similar 2d effect using (preferrably) provided c++ libraries, I would be greatly apreciated.

Reply With Quote
  #2  
Old March 31st, 2005, 05:31 PM
Saumanahaii Saumanahaii is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 Saumanahaii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 59 sec
Reputation Power: 0
Thumbs down

Fine, Nobody answer me. Next time I won't add the code brackets just so someone will flame me, and in the process, possibly answer my question.

Reply With Quote
  #3  
Old April 4th, 2005, 04:32 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
well if you're that bitter, then no, nobody is going to answer you next time. perhaps no one knows the answer, or you weren't clear enough.

however, i should give you a chance. i know that in Dev-C++, you need to put headers like this: gl/glut.h

Reply With Quote
  #4  
Old April 5th, 2005, 12:28 AM
Saumanahaii Saumanahaii is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 Saumanahaii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 59 sec
Reputation Power: 0
wow, now I feel like an idiot. That worked. Sorry about being bitter, its just I watched several posts put up after mine get more than 8 answers. and over 100 views. And here mine was, with a grand total of 8 views. Hehe, plus I was having a bad day, not to make any stupid excuses.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > OpenGL Devc++ GLUT compilation problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT