GLUT Help

P

Prometheus

Guest
Hi,
Just wondering if anyone could shed some light on a small problem I'm having with GLUT. I can compile programs fine, however I cannot change the window size. Is there something built into the GLUT.Framework that inits all programs with size 320x240? If there is can it be overridden?

Code:
#include <GLUT/glut.h>


void resize(int w, int h) {


	if(h == 0)
		h = 1;

	float ratio = 1.0* w / h;

	// Reset the coordinate system before modifying
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	// Set the viewport to be the entire window
    glViewport(0, 0, w, h);

	// Set the correct perspective.
	gluPerspective(45,ratio,1,1000);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(0.0,0.0,5.0, 
		      0.0,0.0,-1.0,
			  0.0f,1.0f,0.0f);


}


void
Init(void)
{
  glClearColor(0.0,0.0,0.0,0.0);
}


void
display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_TRIANGLES);
		glVertex3f(-1.5,-1.5,0.0);
		glVertex3f(1.5,-1.5,0.0);
		glVertex3f(0.0,0.0,0.0);
	glEnd();
	glFlush();

}

int
main(int argc, char **argv)
{
  
  glutInitWindowSize(640, 480);
  glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
  glutInit(&argc, argv);
  glutCreateWindow("Skeleton");
  Init();
  glutDisplayFunc(display);
  glutReshapeFunc(resize);
  glutMainLoop();
  return 0;          
}
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top