Results 1 to 3 of 3

Thread: Drawing with glColor3ui, Blank Screen

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    5

    Drawing with glColor3ui, Blank Screen

    Hi I'm having trouble getting pixels to draw in 2D with glColor3ui, seems to work with glColor3f though. The screen
    just comes up blank

    Init code
    Code :
    if ( (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) == -1 ) ) 
    	{
    		printf("Could not initialize SDL: %s.\n", SDL_GetError()); 
    		exit(-1);
    	}
    	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
     
    	screen.image = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL|SDL_FULLSCREEN);  	
     
    	glClearColor(0.0,0.0,0.0,0.0);
    	SDL_GL_SwapBuffers();
     
    	glViewport(0,0,640,480);
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
     
    	gluOrtho2D(0,640,480,0);
     
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glLoadIdentity();

    Drawing Code
    Code :
            colour.G=0;
     
    	for(d=0;d<200;d++)
    	{
    		colour.G++;
    		glBegin(GL_POINTS);
    		        glColor3ui(colour.R,colour.G,colour.B);
    			glVertex2i(640/2+d,480/2);
    		glEnd();
    	}

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Drawing with glColor3ui, Blank Screen

    ui means unsigned int, color ranges from 0 to 4.2 billion.
    f means float, color range is normalized from 0.0f to 1.0f.

    working with ub is often more realistic, as it matches the 16.7 million colors of typical display. Color range is 0 to 255 in this case.

  3. #3
    Senior Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: Drawing with glColor3ui, Blank Screen

    means 1.0f is converted to unsigned int 1 instead of 255 which is like the closest step to complete black (0).

Similar Threads

  1. blank screen on using drawing commands
    By Def_con_61 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-13-2014, 06:02 AM
  2. Blank Screen
    By imported_JoshKlint in forum OpenGL: Linux
    Replies: 1
    Last Post: 09-16-2013, 10:40 PM
  3. blank screen
    By thisPointer in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 03-27-2005, 04:21 PM
  4. getting blank screen
    By marysowdha in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-06-2001, 02:51 PM

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