Results 1 to 5 of 5

Thread: Getting no output from this code, should be a square! Help please

  1. #1
    Newbie Newbie
    Join Date
    Sep 2014
    Posts
    2

    Getting no output from this code, should be a square! Help please

    Code :
     
    #include<GL\glut.h>
    #include<GL/math_3d.h>
     
    void RenderScene()
    {
    	glClearColor(1,1,1,1);
    	glClear(GL_COLOR_BUFFER_BIT);
     
     
     
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	glColor3f(0.0,0.0,1.0);
     
    	glBegin(GL_QUADS);
     
    	glVertex3f(1.0f,1.0f,0.0f);
    	glVertex3f(1.0f,3.0f,0.0f);
    	glVertex3f(3.0f,1.0f,0.0f);
    	glVertex3f(3.0f,3.0f,0.0f);
     
    	glEnd();
     
    	glutSwapBuffers();
    }
     
    int main(int argc, char *argv[])
    {
     
    	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
     
    	glutInitWindowSize(1024,768);
    	glutInitWindowPosition(0,0);
    	glutCreateWindow("Test");
     
     
     
     
    	glutDisplayFunc(RenderScene);
    	glutMainLoop();
     
     
     
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    Posts
    463
    Your quad is off the edge of the screen, try drawing closer to the origin, eg. (0,0,0) - (1,1,0) rather than (1,1,0) - (3,3,0).

  3. #3
    Newbie Newbie
    Join Date
    Sep 2014
    Posts
    2
    I have to draw multiple shapes on the screen, adjusting them between (0,0) and (1,1) is not possible, is there any way past it?

  4. #4
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    There is, you can use the modelview matrix to place objects and your camera in the scene and the projection matrix to specify how things get mapped into screen space. Take a look at the list of tutorials at wiki - the ones from the pre-OpenGL 3.0 section are the ones that deal with how these things work when using the built in matrices and glBegin()/glEnd() style drawing.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Aside from that, change the primitive type to GL_TRIANGLE_STRIP or inverse the order of first two vertices.

Similar Threads

  1. problem in show Color square in my code
    By mornwk in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-11-2014, 12:15 PM
  2. problem in show square's color in my code
    By mornwk in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-11-2014, 08:31 AM
  3. Replies: 2
    Last Post: 04-29-2014, 11:57 AM
  4. One Code - Three different output images
    By centershock in forum OpenCL
    Replies: 2
    Last Post: 11-20-2010, 07:51 AM
  5. This code rotates the square but not the texture. why?
    By tiregarfio in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-17-2006, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean