Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not pixel perfect #6

Closed
99p opened this issue Jul 30, 2018 · 14 comments
Closed

not pixel perfect #6

99p opened this issue Jul 30, 2018 · 14 comments
Labels
help wanted Extra attention is needed

Comments

@99p
Copy link

99p commented Jul 30, 2018

plz see screenshots. this rectb and circb, looks not good.
I use win10, python3.6.2, 1920x1080 display resolusion.
no change in fullscreen(alt+enter).

pyxel-180730-233528
pyxel-180730-233740

@Stenodyon
Copy link

Stenodyon commented Jul 30, 2018

I'm having the same problem.

Sample program showcasing the bug:

import pyxel

class App:
    def __init__(self):
        pyxel.init(160, 128)
        pyxel.run(self.update, self.draw)

    def update(self):
        pass

    def draw(self):
        pyxel.cls(0)
        pyxel.rectb(20, 20, 100, 100, 7)

App()

pyxel bug
Same effect with rect, blt or cls, the last pixel column is not drawn.

Linux Debian 9, python 3.5.3

@carlsmith
Copy link

carlsmith commented Jul 30, 2018

The code @Stenodyon posted is working perfectly for me.

  • pyxel 0.7.2
  • python 3.7.0
  • macOS 10.13.6

@golebiewsky
Copy link

The code posted by @Stenodyon works for me on:

  • pyxel 0.7.0
  • Python 3.7.0
  • Windows 10 (1803)

But here:

import pyxel

class App:
    def __init__(self):
        pyxel.init(160, 128)
        pyxel.run(self.update, self.draw)

    def update(self):
        pass

    def draw(self):
        pyxel.cls(0)
        pyxel.rectb(0, 127, 20, 116, 7)
        pyxel.rectb(0, 127, 20, 120, 3)

App()

It shows only first rectangle and I have no idea why, maybe it is related.
image

@ghost
Copy link

ghost commented Aug 1, 2018

Hello,

My setup is the following:

  • Pyxel 0.7.3
  • Python 3.6.6
  • Arch Linux

The examples 03_draw_api.py and 04_sound_api.py shows the same bug as @ponponboy.

04_sound_api.py segfaults right after being launched.

The two test codes by @Stenodyon and @golebiewsky show incorrect behaviour.

Since @carlsmith and @golebiewsky report no incorrect behaviour for the built-in example while using Python 3.7.0, I'll wait for Arch Linux to update Python from 3.6.6 to 3.7.0 before drawing any conclusion.

Screenshots

03_draw_api.py

03

04_sound_api.py

04

Test code from @Stenodyon

test

Test code from @golebiewsky

test2

@carlsmith
Copy link

I tried @golebiewsky's code, and it works fine for me (same specs as my last post).

@kev-inn
Copy link

kev-inn commented Aug 3, 2018

I got an pixel-error dependant on the screen size set in pyxel.init()

import pyxel

class MyGame:
    def __init__(self):
        pyxel.init(100,100)
        self.x = 0
        pyxel.run(self.update, self.draw)

    def update(self):
        self.x = (self.x + 1) % pyxel.width

    def draw(self):
        pyxel.cls(0)
        pyxel.rect(self.x,0,self.x+7,7,9)

MyGame()

this code leads to this result:
100x100

but if I change the pyxel.init() to

pyxel.init(100,101)

the result is fine:
100x101

  • Win10,
  • Python 3.6.2
  • pyxel 0.7.4

@kitao
Copy link
Owner

kitao commented Aug 3, 2018

Pyxel uses the point sprites of OpenGL to improve the rendering performance.
And rendering area for each drawn object is specified as the size of point sprites.

So I think this bug is caused by the difference of OpenGL implementation.

@kitao
Copy link
Owner

kitao commented Aug 4, 2018

I will write a bit more.

Pyxel draws each element as point sprite of OpenGL. And to improve rendering performance, rendering area of each element is specified as the size of point sprite.
For examples, if the type of an element is pix, the size will be set as 1. In the case of rect, if the size of it is 40x30, the size will be set as 40 because allowed point sprite shape in OpenGL is only square.

So regarding this bug, it seems that some environment (depends on graphics driver?) decrease the point sprite size by 1. So pix and the longer edge of rect are not drawn.

For now, I don't have smart idea to fix this. Does anyone have good idea?

@kitao kitao added the help wanted Extra attention is needed label Aug 4, 2018
@kitao
Copy link
Owner

kitao commented Aug 4, 2018

Can anyone who faces this bug try to change the shaders.py l.54 from gl_PointSize = 1.0; to gl_PointSize = 1.1; and run the example #3 (draw api sample)?

I would like to know the pix api works or not by this change.

@kitao
Copy link
Owner

kitao commented Aug 4, 2018

Maybe I fixed this bug in 0.7.6.
Can anyone try it out?

Specifically, I changed the rendering position of each element by 0.5 pixel in OpenGL shader.
As a result of it, the edge region should also be treated as pixels regardless of environment. Probably.

@Stenodyon
Copy link

0.7.6 fixed the bug for me, thanks!

@kitao
Copy link
Owner

kitao commented Aug 4, 2018

Thank you for checking it!

@kitao kitao closed this as completed Aug 4, 2018
@ghost
Copy link

ghost commented Aug 4, 2018

I confirm that, on my setup, release 0.7.6 fixed the bug.

@99p
Copy link
Author

99p commented Aug 6, 2018

looks perfect!
thanks kitao! ;D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants