Comments (23)
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).
from pyxel.
@yeputons I imported your modification in v0.7.8. I hope it works in your environment.
from pyxel.
Just checked it on my system and it works for me, which is strange.
- Win10
- Python 3.6.2
- pyxel 0.7.4
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.
@mattjquinn Hi, what will happen when the example #3 (draw api sample) runs on your environment?
from pyxel.
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:
Example #1 is also missing the top line of text as well:
from pyxel.
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
from pyxel.
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.
Do we have opengl version issues perhaps? I'm finding it hard to figure out what version is installed on windows though.
from pyxel.
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.
@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.
@kitao Using OpenGL 4.2, I made the change to line 139; only difference was the first cat being replaced by a black square:
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.
@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.
No luck @kitao; after decreasing from 5 to 2, the only difference is that the background behind the first cat is gray:
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.
@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.
Still no luck: first cat is now completely blacked out:
from pyxel.
@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:
from pyxel.
@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.
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.
@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.
This fixed it for me!
from pyxel.
Good!
from pyxel.
Yes fixed for me as well.
from pyxel.
Sorry to disappoint but I have the same problem in Pyxel 0.7.8...
$ 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.
@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)
- Pyxel edit crashes upon cursor entering with EXC_BAD_ACCESS (SIGBUS) HOT 5
- demo of 30 Seconds Of Daylight is crashing HOT 2
- Pyxel 2.0.0 displays only black screen on Raspberry Pi HOT 12
- Confusion with `blt` function HOT 7
- Unable to import classes from different files using https://kitao.github.io/pyxel/wasm/launcher/?run= HOT 6
- palette only 0..254 (v2.0.2) HOT 2
- mouse_wheel never become 0 HOT 3
- Pyxel Editor crash when selecting Music Editor HOT 6
- Non pixel perfect pixels on the right side of the screen HOT 29
- Pyxel not running HOT 4
- Pyxel crash when starting edit or hello world example HOT 1
- Don't start when I ask for
- command for the terminal didn't work (pycharm) HOT 2
- Slide sound effect only works once HOT 4
- Unable to build a pyxel to exe application on a drive other than C:/ on Windows. HOT 1
- pyxel edit で音符マークを押したら music_editor.py の インデックスエラーで異常終了する。 HOT 1
- `pyxel.sqrt(0)` returns 1.7976931348623157e+308 HOT 4
- Id like to edit the game on web. HOT 3
- Drone yazılımı arıyorum HOT 1
- Please tell me your work with Pyxel (Part5) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyxel.