Thread: how to make opengl draw in lighter colors ?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    111

    how to make opengl draw in lighter colors ?

    Hello ,..

    I wrote a simple glut cube that can be moved and zoomed.

    for some reason when the colors of the cube (rgb) are a bit dark .
    how can i make them brighter .

    Code:
    #
    # This example code will show how to draw a cube rotate and zoom it
    # Was created by Jabka Atu and is released under GPL
    #
    
    #include <iostream>
    #include <GL/glut.h>
    
    using namespace std;
    
    typedef unsigned char uchar;
    
    static float fTranslatex = 0 ,fTranslatey = 0 ,fTranslatez = 0 ;
    static float angle = 0;
    static float fScale = 1;
    static float rotqube ;
    
    void disp();
    void idle();
    void drawexis();
    
    
    void keyb(unsigned char key, int x, int y);
    void skeyb(int key, int x, int y);
    int drawcube();
    
    int main(int argc,char **argv){
    
      glutInit(&argc,argv);
      glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
      glutCreateWindow("Cube ... ");
      glClearColor(0.0,0.0,0.0,0.0);
      glutDisplayFunc(disp);
      glutIdleFunc(idle);
      glutKeyboardFunc(keyb);
      glutSpecialFunc(skeyb);
      glutMainLoop();
     return 0;
    }
    
    
    
    void disp()
    {
     glClear(GL_COLOR_BUFFER_BIT);
     glLoadIdentity();
     
     glRotatef(angle,1.0,1.0,0.0);
     glTranslatef(fTranslatex, fTranslatey, fTranslatez); 
     glScalef(fScale, fScale, fScale);
     drawcube();
     glutSwapBuffers();
    
    }
    
    int drawcube()
    {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glRotatef(rotqube,0.0f,1.0f,0.0f);	// Rotate The cube around the Y axis
      glRotatef(rotqube,1.0f,1.0f,1.0f);
      glEnable(GL_DEPTH_TEST); // Hide the bottom lines
      glBegin(GL_QUADS);		// Draw The Cube Using quads
        glColor3f(0.0f,0.3f,0.0f);	// Color Blue
        glVertex3f( 0.3f, 0.3f,-0.3f);	// Top Right Of The Quad (Top)
        glVertex3f(-0.3f, 0.3f,-0.3f);	// Top Left Of The Quad (Top)
        glVertex3f(-0.3f, 0.3f, 0.3f);	// Bottom Left Of The Quad (Top)
        glVertex3f( 0.3f, 0.3f, 0.3f);	// Bottom Right Of The Quad (Top)
        glColor3f(0.3f,0.5f,0.0f);	// Color Orange
        glVertex3f( 0.3f,-0.3f, 0.3f);	// Top Right Of The Quad (Bottom)
        glVertex3f(-0.3f,-0.3f, 0.3f);	// Top Left Of The Quad (Bottom)
        glVertex3f(-0.3f,-0.3f,-0.3f);	// Bottom Left Of The Quad (Bottom)
        glVertex3f( 0.3f,-0.3f,-0.3f);	// Bottom Right Of The Quad (Bottom)
        glColor3f(0.3f,0.0f,0.0f);	// Color Red	
        glVertex3f( 0.3f, 0.3f, 0.3f);	// Top Right Of The Quad (Front)
        glVertex3f(-0.3f, 0.3f, 0.3f);	// Top Left Of The Quad (Front)
        glVertex3f(-0.3f,-0.3f, 0.3f);	// Bottom Left Of The Quad (Front)
        glVertex3f( 0.3f,-0.3f, 0.3f);	// Bottom Right Of The Quad (Front)
        glColor3f(0.3f,0.3f,0.0f);	// Color Yellow
        glVertex3f( 0.3f,-0.3f,-0.3f);	// Top Right Of The Quad (Back)
        glVertex3f(-0.3f,-0.3f,-0.3f);	// Top Left Of The Quad (Back)
        glVertex3f(-0.3f, 0.3f,-0.3f);	// Bottom Left Of The Quad (Back)
        glVertex3f( 0.3f, 0.3f,-0.3f);	// Bottom Right Of The Quad (Back)
        glColor3f(0.0f,0.0f,0.3f);	// Color Blue
        glVertex3f(-0.3f, 0.3f, 0.3f);	// Top Right Of The Quad (Left)
        glVertex3f(-0.3f, 0.3f,-0.3f);	// Top Left Of The Quad (Left)
        glVertex3f(-0.3f,-0.3f,-0.3f);	// Bottom Left Of The Quad (Left)
        glVertex3f(-0.3f,-0.3f, 0.3f);	// Bottom Right Of The Quad (Left)
        glColor3f(0.3f,0.0f,0.3f);	// Color Violet
        glVertex3f( 0.3f, 0.3f,-0.3f);	// Top Right Of The Quad (Right)
        glVertex3f( 0.3f, 0.3f, 0.3f);	// Top Left Of The Quad (Right)
        glVertex3f( 0.3f,-0.3f, 0.3f);	// Bottom Left Of The Quad (Right)
        glVertex3f( 0.3f,-0.3f,-0.3f);	// Bottom Right Of The Quad (Right)
      glEnd();			// End Drawing The Cube
      
    
    
    
        return 1;		
    }
    
    void idle()
    {
    }
    
    void skeyb(int key, int x, int y) {
    
    	switch (key) 
            {
    		case GLUT_KEY_LEFT :fTranslatex -= 0.1;glutPostRedisplay(); break;
    		case GLUT_KEY_RIGHT :fTranslatex += 0.1;glutPostRedisplay(); break;
    		case GLUT_KEY_UP :fTranslatey += 0.1;glutPostRedisplay(); break;
    		case GLUT_KEY_DOWN :fTranslatey -= 0.1;glutPostRedisplay(); break;
    	}
    }
    
    void keyb(unsigned char key, int x, int y)
    {
       switch (key)
      {
        case 'a':angle+=1;glutPostRedisplay();break;
        case 's':angle-=1;glutPostRedisplay();break;
        case 'd':fScale*=1.1;glutPostRedisplay();break;
        case 'f':fScale*=0.9;glutPostRedisplay();break;
      
        case 'q':exit(0);break;
      }
    }
    why Gaos didn't had a wife ?
    http://bsh83.blogspot.com

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In your calls to glColor3f();, use numbers that are higher than 0.3-0.5?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    111
    oo . (missed that).

    Sorry for the dumb question

    i changed the base size by (replace all) and forgot the color issue).
    why Gaos didn't had a wife ?
    http://bsh83.blogspot.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. first opengl game, problems.
    By n3v in forum Game Programming
    Replies: 1
    Last Post: 07-11-2006, 08:22 PM
  2. More Problems with OpenGL and the Client Area
    By Niytaan in forum Windows Programming
    Replies: 2
    Last Post: 11-06-2002, 03:24 PM
  3. Draw Shapes.
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 08-19-2002, 09:22 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM