[Dev] display.line() broken?

James Paige Bob at HamsterRepublic.com
Thu Mar 27 07:39:08 PDT 2008


On Wed, Mar 26, 2008 at 11:29:57PM -0700, Brian Fisher wrote:
> lines work fine for me, below is the code I used for map.py:
> -----------------------------
> class BaseMap(object):
> 
>   def __init__(self):
>     self.grid = vec2d(64, 64)
> 
>   def draw(self, display):
>     game = HamsterWheel.the_game
>     for i in xrange(game.screen_height / self.grid.y + 1):
>       y = i * self.grid.y
>       points = [vec2d(0, y), vec2d(game.screen_width, y)]
>       display.line(points)
>       #display.rect(points[0], points[1])
>     for i in xrange(game.screen_width / self.grid.x + 1):
>       x = i * self.grid.x
>       points = [vec2d(x, 0), vec2d(x, game.screen_height)]
>       display.line(points)
> -----------------------------
> 
> does that code not work for you?

Nope, it doesn't :(

Although if do

      points = [vec2d(0, y), vec2d(game.screen_width, y+1)]
      display.line(points)

Then it suddenly draws again (presumably because the line is just 
slightly diagonal)

> (it's possible there could be a
> driver issue - OpenGL line support is not a high priority for ATI or
> Nvidia - I think nvidia's line's can't be antialiased either. I think
> I need to change it to draw the line with a specially built texture
> instead)

How would drawing a line with a texture work?

> ... as far as the rect goes - I don't really have on opinion on what a
> zero width/height rect should be... although rects will have similar
> problems to lines in terms of not being able to be antialiased
> consistently - so they probably need some rework (probably to use a
> specially designed texture just like the line)

Here is my reasoning. A rect drawn from vec2d(0,0) to vec2d(0,0) should 
draw one pixel rather than zero pixels. Pixels are not dimentionless, so 
when you specify corner coordinates, you really want the rect to go from 
the outer corner of one corner pixel to the outer corner of the other 
corner pixel.

---
James




More information about the Dev mailing list