Jump to content
  • Advertisement
Sign in to follow this  
KrunalVankar

Cant creat a mountain

This topic is 2583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <GL/glut.h>



static int spin = 0;



void init(void)

{

gluOrtho2D(0,200,0,200);
}


//void mountain(void)
//{
//glutInitDisplayMode(GLUT_DOUBLE);
//glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glBegin(GL_LINES);
// glColor3f (0.7,0.4,0.1);
//
// glVertex2f(20,20);
// glVertex2f(20,80);
//
// glEnd();
// glBegin(GL_LINES);
// glVertex2f(10,50);
// glVertex2f(25,80);
// //glVertex2f(200,220);
// glVertex2f(25,80);
// glVertex2f(40,50);
//
// glVertex2f(36,58);
// glVertex2f(45,75);
//
// glVertex2f(45,75);
// glVertex2f(60,55);
//
// glVertex2f(55,62);
// glVertex2f(67,70);
//
// glVertex2f(67,70);
// glVertex2f(75,62);
//
// glEnd();
//
//glutSwapBuffers();
//
//
//
//
//
//}

void display(void)
{



glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GLfloat position[] = { 1.0, 1.0, 1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, position);


glPushMatrix ();

glTranslatef (0.0, 0.0, -5.0);



glPushMatrix ();

glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);

glLightfv (GL_LIGHT0, GL_POSITION, position);



glTranslated (0.0, 0.0, 1.5);

glDisable (GL_LIGHTING);

glColor3f (1.0, 1.0, 0.0);

glutSolidSphere (0.2,10,16);

glEnable (GL_LIGHTING);

glPopMatrix ();


glLoadIdentity();

glPopMatrix ();

glFlush();

}



void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity();

gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

}



void mouse(int button, int state, int x, int y)

{

switch (button) {

case GLUT_LEFT_BUTTON:

if (state == GLUT_DOWN) {

spin = (spin - 3) % 180;

glutPostRedisplay();

}

break;

default:

break;

}

}

int main(int argc, char** argv)




{

glutInit(&argc, argv);

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH );

glutInitWindowSize (500,500);

glutInitWindowPosition (300, 300);

glutCreateWindow (argv[0]);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glClearColor (1.0, 1.0, 1.0, 0.0);

glShadeModel (GL_SMOOTH);

glEnable(GL_LIGHTING);

glEnable(GL_LIGHT0);

glEnable(GL_DEPTH_TEST);


glutDisplayFunc(display);



glutReshapeFunc(reshape);

glutMouseFunc(mouse);

glutMainLoop();

return 0;

}

Share this post


Link to post
Share on other sites
Advertisement
You can't create a mountain... because it's commented out? Just throwing a code listing onto the forum doesn't necessarily constitute elaborating on your thread title - can you explain what you're trying to achieve and what the problem is?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!