Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Not drawing anything.

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    9

    Not drawing anything.

    Hello,
    I am trying to write a very basic point drawing OpenGL program. But it is not drawing anything.
    Following is the code.

    Thanks





    #include <stdio.h>
    #include <glut.h>


    void handleResize(int w, int h){
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45,double(w)/double(h),1, 100 );
    }

    void handleKeypress(unsigned char key,int x, int y){
    switch(key){
    case 27:
    exit(0);

    }

    }
    void init(){
    glEnable(GL_DEPTH_TEST);
    }

    void drawScene(){
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glBegin(GL_POINTS);
    glVertex3f(10.0f, 20.0f, -5.1f);
    glVertex3f(50.0f, 50.0f, 5.1f);
    glEnd();

    glBegin(GL_QUADS);
    glVertex3f(10.0f, 20.0f, -5.0f);
    glVertex3f(50.0f, -50.0f, 5.1f);
    glVertex3f(-10.0f, 20.0f, -5.1f);
    glVertex3f(-50.0f, -50.0f, 5.1f);
    glEnd();

    glutSwapBuffers();



    }

    void main (int argc, char** argv){

    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEP TH);
    glutInitWindowSize(400,400);


    glutCreateWindow("Chayan Vinayak's OpenGL tutorial ");
    init();


    glutDisplayFunc(drawScene);
    glutKeyboardFunc(handleKeypress);
    glutReshapeFunc(handleResize);
    glutMainLoop();


    }

  2. #2
    Junior Member Newbie xiphos's Avatar
    Join Date
    Jun 2011
    Posts
    11

    Re: Not drawing anything.

    Points and Quad you are trying to render is not inside camera's frustum.

    put glTranslatef(0,0,-90.0f) after glLoadIdentity() in function drawScene(), you can see quad rendered.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •