Jump to content
  • Advertisement
Sign in to follow this  
Gice

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!