OS X - Development and Darwin Discussion and questions about development for Mac OS X.

GLUT Help


Post Reply New Thread Subscribe

 
Thread Tools
Prometheus
Guest
 
Posts: n/a

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;          
}
QUOTE Thanks

Post Reply New Thread Subscribe


« best book on darwin | I'm Having Darwin Problems »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
GLUT & OpenGL problems dcholth OS X - Development and Darwin 4 05-21-2004 01:53 PM

All times are GMT -4. The time now is 11:07 PM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?