View Full Version : glLineStipple problem
12-20-2001, 04:25 AM
I am having trouble with glLineStipple. The red book section on it is very brief. When I try to stipple a line, it is not drawn at all. If it is solid then it is fine.
this is what I have...
if (m_style == STIPPLED)
can anyone point me in the right direction?
Is m_style ever equal to STIPPLED?
12-21-2001, 12:02 AM
of course!!! I should have mentioned that everything is being called as it should be, just that when m_style is set to STIPPLED, the glLineStipple() command seems to cause the line to to be drawn at all (or the resulting line is invisible)
Oh well, just a wild guess http://www.opengl.org/discussion_boards/ubb/rolleyes.gif
Joke aside, with the code you gave, that was the only "problem" I saw. If the entire code isn't too large (~200 lines or less), post it here. Otherwise, you can send it to me, and I have a look at it. You find my address in my profile. Might be a driver problem. What card do you have?
12-21-2001, 04:05 AM
the graphics adapter is a GForce 2 nVidia thingy. How important is the hardware? Are you saying that dependent on the hardware I may or may not be able to stipple lines?
In that case, I've noted that it's possible to render a line as a 1D texture. I think I'm ok with clamping the texture to a line, but how do I generate the texture of a dashed line?
I just thoguth that if you had an old/bad graphics board or something, you might have some buggy drivers that can't handle line stipple correct. I have a GF2 myself, and I can ensure you that there's nothing wrong with line stipple on that one.
To generate a 1D dashes texture, you can do something like this. It will be a "16-bit pattern".
unsigned char *tex = new unsigned char;
for(int i = 0; i < 16; ++i)
if(pixel i should be set)
tex = 0xFF;
tex = 0x00;
glTexImage1D(GL_TEXTURE_1D, 0, GL_ALPHA, 16, 0, GL_UNSIGNED BYTE, tex);
All you have to do is to decide whethe the pixel should be set or not. To get every four pixel to be set, try
if(i & (1 << 3))
That should create a 1D texture you can use for line stipple. Bind the texture and set texture coordinates for the line. Alpha test can be used to reject the "invisible" parts of the line.
[This message has been edited by Bob (edited 12-21-2001).]
12-22-2001, 11:48 PM
Wow, thanks for that. It'll have to wait until new year now when I'm back at work.
Thanks for that
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.