Jump to content
  • Advertisement
Sign in to follow this  

OpenGL clear up a few things please

This topic is 4287 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im a very competent at programming in C and Java, now testing the waters with OpenGL but have some issues. i don't really know the entry point where i program, in that sense i mean seen some source code like below and understand it to extent but where about do i start what i really want to do, i was wanting rotate camera, look into texture mapping, user entry.. but with OpenGL seems .. weird at mo.
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void display();
void drawCube();
void setupCube();

/* Callback function that is invoked when the window's size is changed,      
   and when the system starts up */
void AdjustSize(GLsizei, GLsizei);

int main(int argc,char **argv)
   glutReshapeFunc(AdjustSize); /* tells the Open GL system what the
					  Reshape Callback function is called*/
   return 0;

void display()
   //glRectf(0.0f,0.0f,250.0f,200.0f); /* draw a rectangle */


   glVertex3f(20.0f, 100.0f, 0.0f);
   glVertex3f(150.0f, 100.0f, 0.0f);
   glVertex3f(150.0f, 20.0f, 0.0f);
   glVertex3f(20.0f, 20.0f, 0.0f);

   		//glVertex3f(-1.0f, 1.0f, 0.0f);				// Top Left
		//glVertex3f( 1.0f, 1.0f, 0.0f);				// Top Right
		//glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right
		//glVertex3f(-1.0f,-1.0f, 0.0f);

void drawCube() {

void setupCube() {


void AdjustSize(GLsizei w, GLsizei h)
   glViewport(0,0,w,h); 				/* Create a viewport to view the scene */
   glMatrixMode(GL_PROJECTION); 		/*Load the projection matrix */
   glLoadIdentity(); 					/* loads the identity matrix into the Projection Matrix*/
   glOrtho(0.0f,250.0f,0.0f,250.0f,1.0f,-1.0f); /* This sets the matrix up for orthogonal 									viewing */
   glMatrixMode(GL_MODELVIEW); 			/* Reload the modelview matrix */
   glLoadIdentity(); 					/* Load the identity matrix into the modelview matrix */

thanks for reading, just need a litte guidance and clarification and think can tackle it. ta

Share this post

Link to post
Share on other sites
Well thats glut.You pass your display function to it and then it calls your display function each frame.
So you perform your rendering camera setup in that display function.
If you use win32+opengl you need to create a window initialize it for OGL create your own game loop where you check input and render your world etc.
Which takes a bit longer.Check out NEHE

Share this post

Link to post
Share on other sites
It sounds like your question is related more to GLUT than to OpenGL in general.

GLUT is a 'utility toolkit' that manages platform-specific tasks such as window creation and event management in a portable way. It allows you get an OpenGL application up and running quickly without mucking around with a lot of platform-specific APIs.

However, GLUT is fairly limited, and if I understand correctly isn't terribly well supported these days. For more serious applications you'll probably want to look into alternatives such as SDL.

As for the 'entry point', GLUT has a very simple structure, consisting of a few callback functions and a single 'main loop' function.

The general procedure is to register callback functions for aspects of the simulation you want to have control over (e.g. rendering), and then call glutMainLoop(). Once the loop is entered, the callback functions you've registered are called periodically, and any code that you've placed in these functions will be executed. (How often the functions are called depends on the particular function in question.)

Share this post

Link to post
Share on other sites
Have you been following the NeHe tutorials? They have nearly 50 tutorials on various OpenGL rendering practices and tricks, though for stuff like "user entry" you'll have to look elsewhere.

EDIT: Beaten to it.

Share this post

Link to post
Share on other sites
thanks for all help so far.. much appreciated.

would before delve into NeHe tutorials.. would GLUT be capable of doing the following specification:

thank you

[Edited by - dcmk09 on May 4, 2007 2:03:20 PM]

Share this post

Link to post
Share on other sites
Most of the things you're asking are not GLUT related. All GLUT does is creates a Window, and lets you get some sort of keyboard/mouse/etc. input from it, as well as some basic timing functions and so on. Just about everything you said would have to be done manually (unless you use another library to, say, load 3d model files) using OpenGL and the usual C++ techniques.

jyk is right about GLUT not being well supported (the lastest update was in 2001 IIRC).

Personally, I'd highly recommend using GLFW instead, simply because it's much easier to use, more powerful, and has very good and easy to read documentation (including examples). It's a much better experience starting out with it, IMO. Good luck.

PS. If you're planning to achieve the things you've listed, I think you'll have a long way to go because they are not by any means simplistic.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!