COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to scan all pixels of a line in openGL

• Email
• Follow

```I have to check all pixels of an edge of a polygon for visibility.
What is the best way to scan every pixel of this edge? In other words,
how do I know to which pixels the edge is exactly rasterized.
```
 0

See related articles to this posting

```Hello, Kurt!
You wrote  on 12 Aug 2003 00:03:43 -0700:

K> I have to check all pixels of an edge of a polygon for visibility.
K> What is the best way to scan every pixel of this edge? In other
K> words, how do I know to which pixels the edge is exactly rasterized.

fragments centers of which are inside a polygon are rasterized.

With best regards, Alex Mizrahi aka killer_storm.

```
 0

```> fragments centers of which are inside a polygon are rasterized.

Don't forget the rule which edge, left or right, is rasterized if the center
of fragment is precisely at the edge of the triangle (so we can't say that
what you say above is universal rule: it has it's exception..)

```
 0

```"Alex Mizrahi" <pmiz@etel.dn.ua> wrote in message news:<bhasta\$101451\$2@ID-177567.news.uni-berlin.de>...
> Hello, Kurt!
> You wrote  on 12 Aug 2003 00:03:43 -0700:
>
>  K> I have to check all pixels of an edge of a polygon for visibility.
>  K> What is the best way to scan every pixel of this edge? In other
>  K> words, how do I know to which pixels the edge is exactly rasterized.
>
> fragments centers of which are inside a polygon are rasterized.
>
> With best regards, Alex Mizrahi aka killer_storm.

I have to render the edges seperately from the polygons in a different
color for several reasons. So actually, I just want to know for a
given line between 2 3D points in object space to which pixels it is
rasterized in screen space.
```
 0

```dreamchaser1981@hotmail.com (Kurt) wrote in message news:<f7fbf77f.0308112303.21a56b96@posting.google.com>...
> I have to check all pixels of an edge of a polygon for visibility.
> What is the best way to scan every pixel of this edge? In other words,
> how do I know to which pixels the edge is exactly rasterized.

I'll try to make myself a little bit more clear.

In my current implementation I do it as follows. I calculate the
screen space coordinates of the vertices by using gluProject. I use
floor() to convert these double values to integers (or should i round
them differently to find the exact coordinates as ints?). Then I
scan-convert between these two coordinates by using Bresenhams
algorithm. Most of the pixels rendered by opengl and the ones
generated by Bresenham's algorithm match, but there are still a lot of
pixels where Bresenham finds pixels that are right next to the
according pixel rendered by opengl.

As an example, you can see the image on
http://lumumba.luc.ac.be/~dreamchaser/thesis/images/deer.png
green pixels indicate a match, red pixels are pixels generated by
Bresenham that don't match, and the black pixels are the pixels
rendered by opengl that are missed by Bresenham, so actually the red
pixels should have generated the coordinates of the black pixels to
match my goal.

Any solutions?

```
 0

```Hello, Kurt!
You wrote  on 12 Aug 2003 13:37:54 -0700:

K>>> I have to check all pixels of an edge of a polygon for visibility.
K>>> What is the best way to scan every pixel of this edge? In other
K>>> words, how do I know to which pixels the edge is exactly
K>>> rasterized.

>> fragments centers of which are inside a polygon are rasterized.

>> With best regards, Alex Mizrahi aka killer_storm.

K> I have to render the edges seperately from the polygons in a
K> different color for several reasons. So actually, I just want to know
K> for a given line between 2 3D points in object space to which pixels
K> it is rasterized in screen space.

you can read about that in OpenGL Specifications. as far as i remember there
can be different ways of rendering lines in different implementations.

With best regards, Alex Mizrahi aka killer_storm.

```
 0

```> floor() to convert these double values to integers (or should i round
> them differently to find the exact coordinates as ints?). Then I
> scan-convert between these two coordinates by using Bresenhams

Bzzzt. This is where it goes wrong: when you scanconvert, you must not
discard the decimals. Look up keyword: "subpixel" from google, there will be
plenty of appropriate documents popping up.

```
 0

```> I'll try to make myself a little bit more clear.
>
> In my current implementation I do it as follows. I calculate the
> screen space coordinates of the vertices by using gluProject. I use
> floor() to convert these double values to integers (or should i round
> them differently to find the exact coordinates as ints?). Then I
> scan-convert between these two coordinates by using Bresenhams
> algorithm. Most of the pixels rendered by opengl and the ones
> generated by Bresenham's algorithm match, but there are still a lot of
> pixels where Bresenham finds pixels that are right next to the
> according pixel rendered by opengl.

You should use floatin point numers in your implementation or
use integers with subpixel accuracy. I think that Bresenham
algorithm are not used in OpenGL line rendering. Line rendering
depends on hardware vendor implementation. For example, old
Voodoo chips render line as very thin triangle.

Even more, if you use antialiasing in your app, many pixels around
line center are affected.

yooyo
```
 0