Hello everyone…ok the idea is I just got this code from internet source …it draw 4 object…then user can using mouse to choose different object …so my attempt is I want to displaying 4 object all '4’once!!..so when i alter the code it seems nothing was display…so really need ur expertise help guys…here the code i’ve been using…
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
void drawSphere(void) {
glutWireSphere(3.0,20,10);
}
void drawCone(void) {
glutWireCone(5.0, 5.0, 10, 20);
}
void drawTorus(void) {
glutWireTorus(1.0, 5.0, 10, 20);
}
void drawTeapot(void) {
glutWireTeapot(5.0);
}
void display(void)
{
glClear( GL_COLOR_BUFFER_BIT );
/* set matrix mode to modelview */
glMatrixMode(GL_MODELVIEW);
/* save matrix */
glPushMatrix();
glPopMatrix();
/* swap buffers to display the frame */
glutSwapBuffers();
}
void myReshape(int w, int h)
{
/* set viewport to new width and height */
/* note that this command does not change the CTM */
glViewport(0, 0, w, h);
/*
* set viewing window using perspective projection
*/
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); /* init projection matrix */
/* perspective parameters: field of view, aspect, near clip, far clip */
gluPerspective( 60.0, (GLdouble)w/(GLdouble)h, 0.1, 40.0);
/* set matrix mode to modelview */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 50.0, /* eye at (0,0,20) */
0.0, 0.0, 0.0, /* lookat point */
0.0, 10.0, 0.0); /* up is in +ive y */
}
/*
* myKey
*
* responds to key presses from the user
*/
void myKey(unsigned char k, int x, int y)
{
switch (k) {
case 'q':
case 'Q': exit(0);
break;
default:
printf("Unknown keyboard command \'%c\'.
", k);
break;
}
}
void myMouse(int btn, int state, int x, int y)
{
if(btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) ;//g_rotInc += ROT_INC;
if(btn==GLUT_MIDDLE_BUTTON && state == GLUT_DOWN); //g_rotInc = ROT_INC;
/* if(btn==GLUT_RIGHT_BUTTON && state == GLUT_DOWN) g_rotInc -= ROT_INC;
*/
/* force redisplay */
glutPostRedisplay();
}
int main(int argc, char **argv)
{
/* glutInit MUST be called before any other GLUT/OpenGL calls */
glutInit(&argc, argv);
/* set double buffering, note no z buffering */
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(800, 600);
glutCreateWindow("Testing");
/* set callback functions */
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
glutKeyboardFunc(myKey);
glutMouseFunc(myMouse);
/* set clear colour */
glClearColor(1.0, 1.0, 1.0, 1.0);
/* set current colour to black */
glColor3f(0.5, 0.0, 5.0);
glutMainLoop();
return 0;
}
any help would be greatful…really need help…
tq