| OS X - Development and Darwin Discussion and questions about development for Mac OS X. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
|
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 |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
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