GithubHelp home page GithubHelp logo

Comments (23)

yeputons avatar yeputons commented on May 8, 2024 1

Dirty hack that worked on my machine, see shaders.py:327:

-#define texture_color(index) int(texture2D(u_texture[index], uv).r * 255.0)
+#define texture_color(index) int(texture2D(u_texture[index], uv).r * 255.0 + 0.5)

My assumption is that the problem is that texture values are floats between 0.0 and 1.0, and we want to distinguish 1/255ths. Unfortunately, 1/255 cannot be represented exactly and it turns out that 1/255 * 255 (via OpenGL) is rounded down to 0 on my machine. This effect can be also noted when rendering images with blt. Say, color 1 becomes 0, 2 becomes 1, 4 becomes 3. So, instead of rounding down with int(), I now round to the approx. closest integer.

I'm not exactly sure what causes that effect or even what are exact values returned by texture2D() * 255.0 instead of 1.0. I think it should be something like 0.9999, but I haven't checked and recommend further investigation (a hotfix may be landed in the meantime).

cc @olgalupuleac

from pyxel.

kitao avatar kitao commented on May 8, 2024 1

@yeputons I imported your modification in v0.7.8. I hope it works in your environment.

from pyxel.

kev-inn avatar kev-inn commented on May 8, 2024

Just checked it on my system and it works for me, which is strange.

  • Win10
  • Python 3.6.2
  • pyxel 0.7.4

pyxel-180803-202815

Code is the same:

import pyxel

pyxel.init(160, 120)

def update():
    if pyxel.btnp(pyxel.KEY_Q):
        pyxel.quit()

def draw():
    pyxel.cls(0)
    pyxel.rect(10, 10, 20, 20, 11)
    pyxel.text(10, 10, "This is a sentence.", 11)

pyxel.run(update, draw)

from pyxel.

kitao avatar kitao commented on May 8, 2024

@mattjquinn Hi, what will happen when the example #3 (draw api sample) runs on your environment?

from pyxel.

mattjquinn avatar mattjquinn commented on May 8, 2024

Example #3 also has missing text. It also appears that clip() doesn't work either, though the screen changes colors and one of the sprites moves as expected:

2018-08-04-135618_1600x900_scrot

Example #1 is also missing the top line of text as well:

2018-08-04-135547_1600x900_scrot

from pyxel.

matju avatar matju commented on May 8, 2024

I have a similar issue - except I'm on MacOS Sierra. brew and pip3 installed everything OK.

In my case:

  • Example 1 doesn't render any text
  • Clipping doesn't work for Example 3
  • Some fragments of text are rendered for Example 3 (see screenshot)
  • Example 3's circles don't render properly

pyxel-180804-130423

from pyxel.

timbledum avatar timbledum commented on May 8, 2024

Fine on my mac at home, but getting no text displayed on my windows 10 work computer. No install issues. Tried on 3.6 and 3.7, including fresh environment.

capture

Do we have opengl version issues perhaps? I'm finding it hard to figure out what version is installed on windows though.

from pyxel.

matju avatar matju commented on May 8, 2024

In my case I'm running MacOS 10.12.6 on a MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports) with Intel Iris Graphics 550 - apparently this supports OpenGL 4.1.

brew list --versions reports python 3.7.0 and glfw 3.2.1.

pip3 list reports:

Package     Version
----------- -------
cffi        1.11.5 
glfw        1.7.0  
numpy       1.15.0 
Pillow      5.2.0  
pip         18.0   
pycparser   2.18   
PyOpenGL    3.1.0  
pyxel       0.7.6  
setuptools  40.0.0 
sounddevice 0.3.11 
wheel       0.31.1 

from pyxel.

kitao avatar kitao commented on May 8, 2024

@matju Appearently, you environment has enough specs to run Pyxel.

Now I'm wondering there is some informal OpenGL code and it causes this bug.

Could you try change line 139 of the example #3 from pyxel.blt(x, y, 0, 0, 0, 16, 16) to pyxel.blt(x, y, 4, 0, 0, 16, 16)?

By this change, Pyxel draws the system font texture with blt command.
If some characters with blue color are shown, it means the system font texture is available and the shader for text has some problem. If not, the system font texture has some problem.

from pyxel.

mattjquinn avatar mattjquinn commented on May 8, 2024

@kitao Using OpenGL 4.2, I made the change to line 139; only difference was the first cat being replaced by a black square:

2018-08-06-074258_1600x900_scrot

Output of glxinfo is

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 4.2 (Core Profile) Mesa 17.3.6
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.3.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 17.3.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

Is there any advice you can give us for debugging issues with system font resources that Pyxel expects to be present?

from pyxel.

kitao avatar kitao commented on May 8, 2024

@mattjquinn Thank you! It seems that the image bank #5 of Pyxel is not available.
Potential possibility is your environment doesn't allow to use five textures at the same time, or shader setting of Pyxel for textures is informal OpenGL code.

If possible, could you change line.40 of constants.py of Pyxel from `RENDERER_IMAGE_COUNT = 5' to 'RENDERER_IMAGE_COUNT = 2'?

If the example #3 works by this change, the cause is the number of the texture unit.

from pyxel.

mattjquinn avatar mattjquinn commented on May 8, 2024

No luck @kitao; after decreasing from 5 to 2, the only difference is that the background behind the first cat is gray:

2018-08-06-081121_1600x900_scrot

So you're saying that since this doesn't work, I should look into environment limitations on using five textures at the same time?

from pyxel.

kitao avatar kitao commented on May 8, 2024

@mattjquinn Sorry! You also need to the example #3.

Now, the System Font image number is 1, so please change the same line of the example #3 to pyxel.blt(x, y, 1, 0, 0, 16, 16).

from pyxel.

mattjquinn avatar mattjquinn commented on May 8, 2024

Still no luck: first cat is now completely blacked out:

2018-08-06-081849_1600x900_scrot

from pyxel.

matju avatar matju commented on May 8, 2024

@kitao If I change line 139 of example 3 to pyxel.blt(x, y, 4, 0, 0, 16, 16) then the first cat is replaced with some faint blue text:

pyxel-180806-073320

from pyxel.

kitao avatar kitao commented on May 8, 2024

@matju Thank you for checking. This is the image I expected. So in your case, the number of the texture or size may be the cause. (Though I don't know it can cause breaking text rendering like this.)

Could you try to just change the `RENDERER_IMAGE_COUNT' of constant.py to some number less than 5 to make sure the number of the texture cause this?

from pyxel.

kitao avatar kitao commented on May 8, 2024

Hi, @yeputons
Thank you for good information! I understood what happen in your environment.
So in your environment, all color drawn with blt and text command changes rather than text is not drawn?

from pyxel.

yeputons avatar yeputons commented on May 8, 2024

@kitao Color drawn with blt changes, yes, but text is not drawn at all: font is passed through a texture with 0/1 values, and 1 gets rounded down to 0 in texture_color, so the shader assumes that all pixels are zero and does not draw anything.

from pyxel.

timbledum avatar timbledum commented on May 8, 2024

This fixed it for me!

from pyxel.

kitao avatar kitao commented on May 8, 2024

Good!

from pyxel.

mattjquinn avatar mattjquinn commented on May 8, 2024

Yes fixed for me as well.

from pyxel.

matju avatar matju commented on May 8, 2024

Sorry to disappoint but I have the same problem in Pyxel 0.7.8...

pyxel-180808-234521

$ pip3 list
Package     Version
----------- -------
cffi        1.11.5 
glfw        1.7.0  
numpy       1.15.0 
Pillow      5.2.0  
pip         18.0   
pycparser   2.18   
PyOpenGL    3.1.0  
pyxel       0.7.8  
setuptools  40.0.0 
sounddevice 0.3.11 
wheel       0.31.1 

from pyxel.

kitao avatar kitao commented on May 8, 2024

@matju In your case, texts are drawn partially and circles are not drawn. So I split your case as #45
Let me ask more information in #45

from pyxel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.