Can someone write me a simple GLUT example?
Could someone please write a simple example ware there is a green square in the middle of the screen. If you press one of the A,D,S and W keys it moves left right up or down?
I tried to write my own program but for some strange reason glutmainloop wouldn't work so I stuck it somewhare else and now the block only moves when I am moveing or resizing the window
.
Anyone?
I tried to write my own program but for some strange reason glutmainloop wouldn't work so I stuck it somewhare else and now the block only moves when I am moveing or resizing the window
.Anyone?
I can write you one in cocoa, but you are using Carbon right?
Ok I am just modifying tutorial 2 from NeHe because I don't feel like typing everything to set up GL again, I will email it to you in a sec.
I already posted one... but here goes again...
Code:
#include <stdlib.h>
#if defined(__APPLE_CC__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// your drawing code goes here
glutSwapBuffers();
}
void reshape(int width, int height)
{
glViewport(0, 0, width, height);
}
void idle(void)
{
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
(void)glutCreateWindow("GLUT Program");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return EXIT_SUCCESS;
}
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| SDL to write to a browser pane ???? | Mark Whittemore | 2 | 2,449 |
Sep 22, 2005 08:35 AM Last Post: TomorrowPlusX |
|
| PBuffer & Render to Texture (read & write) | habicht | 4 | 3,430 |
Feb 7, 2005 05:33 PM Last Post: habicht |
|
| Which dylib in OpenGL framework gets linked? (simple glut ex) | johnMG | 6 | 3,251 |
Oct 22, 2003 06:06 AM Last Post: anarchie |
|

