Advertisement

drawing a grid

Started by April 04, 2002 03:33 PM
9 comments, last by Crispy 22 years, 10 months ago
which way would be the best to draw a simple wireframe/dotframe (is that the right word??) grid? by drawing polys (hopefullt not) or is there a function (glut or no glut - doesn''t matter) that would do the work for me? thanks crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Are you just looking for GL_LINES?


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Advertisement
silly me. of course. thanks siaspete. didn''t quite realise to look at glBegin() before i asked. cut myself with the Okkam''s Razor.

crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Remember to disable texturing before drawing the lines if you don''t want them textured :-)


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
if you''re trying to make a mesh or object you''ve already
created wireframe or "dotframe" or whatever you want,
check out glPolygonMode().
the default is GL_FILLED, but you can pick GL_LINES and make it
wireframe.

for example, to render just one object in wireframe you could
do somethign like this:
if(bWireframe){   glPolygonMode(GL_LINES);   DrawPlayer1();   glPolygonMode(GL_FILLED);} 

-eldee;another space monkey;[ Forced Evolution Studios ]
a question, though...

can i use GL_LINES to draw finer (thinner) lines so that they wouldn''t be so prominent when the grid is dense?

crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
In general, no. You can''t draw anything thinner than a pixel. You can however alter the alpha (using glColor4f) to fade the lines out slightly. This is a bit easier on the eye.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
the following code produces no dirrefent a result than the code without the call to glColor4d(). why is that?

glDisable(GL_TEXTURE_2D);glColor4d(0.5, 0.3, 0.7, 0.5);   glBegin(GL_LINES);  	for(int i = -30; i < 30; i++)       	{        	glVertex3d(i * RC.grid_density, 0, -15);        	glVertex3d(i * RC.grid_density, 0, 15);        }  	for(int i = -30; i < 30; i++)       	{        	glVertex3d(15, 0, i * RC.grid_density);        	glVertex3d(-15, 0, i * RC.grid_density);        }   glEnd();glEnable(GL_TEXTURE_2D);


crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
you have to use something like
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
and enable blending

There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
Also, glEnable (GL_BLEND);


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

This topic is closed to new replies.

Advertisement