# 3D Pixels won't show up

This topic is 5046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Alright so I have a totally n00b question but based on the positive response I've received so far I am going to dare to ask.. I've looked at a whole bunch of example code and I can follow it without problems. Right now I'm taking an example program and I threw in a couple of lines to add some pixels in 3D to the scene, after it renders the other objects in the scene, and before it flips the back buffer to the screen. I.e. my code looks something like this (from memory): glBegin(GL_POINTS); for (int i=0;i<5000;i++) { glColor3i(rand()%255,rand()%255,rand()%255); glVertex3i(256-rand()%512,256-rand()%512, 256-rand()%512)); } glEnd(); so i'm thinkin.. this should draw 5000 randomly colored pixels within a sphere (Ed : er.. cube, sorry) of 256 radius with origin at the origin, right? Well, my pixels don't show up in the scene. I've had it to where only pixels that lie on the zy plane show up (i.e. with z = 0) which I guess has something to do with depth testing or something.. Now I do not profess to understand the OpenGL state machine and I know it's probably something silly, but I can't figure it out. Is there a state that needs to be enabled for these pixels to show up in 3D? I'm sorry, I know it's probably a dumb question! [Edited by - Gice on December 1, 2004 10:51:52 AM]

##### Share on other sites
Actuarly it would draw 5000 randomly colored pixels with in a cube of (512,512,512).

As for the other problem, you have to increase the z-far variable to aproximatly 1000, right now it's probobly at 1.

To do that you have to find the place where you set up your projection matrix(look for this line glMatrixMode (GL_PROJECTION);).
and then modify or add one of these depending on what projection you want/have.
gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height),1.0f, 1000.0f);
or
glOrtho( 0, x , y , 0, 1, 1000 );

note: if you allready have one of these then you only have to set the last value to 1000.

##### Share on other sites
Correction to myself ; I realized it would draw in a cube not a sphere, my bad.

##### Share on other sites
thanks Overlord... I'll give that a shot..

##### Share on other sites
Hm.. as I thought, that wasn't it...

##### Share on other sites
You say you're rendering this after you render some other objects. Can you post your full rendering loop?

Enigma

##### Share on other sites
Eureka! I got it to work after I disabled depth testing and lighting. (DOH)

Thanks enigma and lc_overlord for taking time to try and help :)

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632655
• Total Posts
3007670
• ### Who's Online (See full list)

There are no registered users currently online

×