Working Broken

Member
Posts: 102
Joined: 2005.01
Post: #1
why wont this GLUT/GL thingy work?

Code:
#include <stdlib.h>

#include <GLUT/glut.h>

void display(void)
{    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
    
    glTranslatef(-1.5f,0.0f,-6.0f);
    
    glBegin(GL_TRIANGLES);          
    
        glColor3f(0.5f , 0.5f, 0.8f);
        glVertex3f( 0.0f, 1.0f, 0.0f);
        
        glColor3f(0.5f , 0.8f, 0.5f);
        glVertex3f(-1.0f,-1.0f, 0.0f);
        
        glColor3f(0.8f , 0.5f, 0.5f);
        glVertex3f( 1.0f,-1.0f, 0.0f);                        
    glEnd();  
    
    glTranslatef(3.0f,0.0f,0.0f);    
    
    glColor3f(1.0f, 0.5f, 0.5f);
    
    glBegin(GL_QUADS);                                            
        glVertex3f(-1.0f, 1.0f, 0.0f);                          
        glVertex3f( 1.0f, 1.0f, 0.0f);                          
        glVertex3f( 1.0f,-1.0f, 0.0f);                          
        glVertex3f(-1.0f,-1.0f, 0.0f);                          
    glEnd();
    
    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);
    
    glutCreateWindow("Some Drawings n' Stuff");
    
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutIdleFunc(idle);
    
    glutMainLoop();
    return EXIT_SUCCESS;
}


it draws a blank window. i want it to draw a quad and trianlge

edit:fixed it (the problem is in the display func anyway)
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #2
we need all of the code.

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #3
fixed the code (and by that i mean the code here is the same as i have.. althought it doesnt work!)

it draws a black square
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
as discussed on IRC, you're drawing things outside of OpenGL's default coordinate system. Either change where you're drawing your objects, or change the coordinate system.
Quote this message in a reply
Vertizor
Unregistered
 
Post: #5
In your reshape() routine, you haven't set up your camera.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  VBO broken in MacOS 10.4 execomrt 3 3,099 Sep 27, 2005 05:28 AM
Last Post: TomorrowPlusX
  Vertex Shaders broken in 10.2.5? Bossa Nova 2 2,419 Apr 30, 2003 07:44 AM
Last Post: Bossa Nova
  Is GLUT broken in 10.2.4? OSXRules 1 1,953 Apr 4, 2003 01:06 PM
Last Post: blb