libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
404 stars 37 forks source link

Since version 1.16.0 context.present with integer_scaling = True is ignored #106

Closed Darky-Lucera closed 3 years ago

Darky-Lucera commented 3 years ago

Hello,

I have just noticed that when I change to fullscreen the graphics have stopped being pixel perfect (when I was working with 1.19.3 version), so I went back until 1.15.3 where it worked again.

It seems that previously renderer 3 (SDL2) was used but from version 1.16.0 renderer 4 (OPENGL2) is used. Almost in my Windows machine.

HexDecimal commented 3 years ago

Do you mean that it isn't using the 'nearest' filter with the OpenGL2 renderer?

HexDecimal commented 3 years ago

If it's just the filter then you should be able to affect it with an SDL hint:

import tcod
tcod.lib.SDL_SetHint(b"SDL_RENDER_SCALE_QUALITY", b"0")

Calling this before creating the context will enforce the nearest filter no matter which renderer you use.

Darky-Lucera commented 3 years ago

Yes

On Fri, Jan 15, 2021, 8:54 PM Kyle Benesch notifications@github.com wrote:

Do you mean that it isn't using the 'nearest' filter with the OpenGL2 renderer?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/libtcod/python-tcod/issues/106#issuecomment-761165848, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHHEHL6PJFQTERS32WD5VLS2CMQRANCNFSM4WEOSNSA .

Darky-Lucera commented 3 years ago

Thanks for the trick. I will do.

But don't you think the behavior of integer scale should be the same in all renderers?

On Fri, Jan 15, 2021, 9:14 PM Kyle Benesch notifications@github.com wrote:

If it's just the filter then you should be able to affect it with an SDL hint:

import tcodtcod.lib.SDL_SetHint(b"SDL_RENDER_SCALE_QUALITY", b"0")

Calling this before creating the context will enforce the nearest filter no matter which renderer you use.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/libtcod/python-tcod/issues/106#issuecomment-761174415, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHHEHOGAVO3BC2YYIYGQWLS2COZBANCNFSM4WEOSNSA .

HexDecimal commented 3 years ago

Integer scale only refers to the output resolution, not the upscale filter that's used. Being able to change the filter of the OpenGL 2 renderer is a recent feature. The OpenGL 1 renderer is limited to using the nearest filter only. I'm not sure if the nearest filter is the default for SDL2 in all cases.

The preferred filter depends on the tileset and the desired aesthetic. The SDL hint is something I could document better.

Darky-Lucera commented 3 years ago

I remember that image scale solved the blurry graphics, so I supposed that it sets the upscale filter.

I guess I was wrong

On Sat, Jan 16, 2021, 2:24 AM Kyle Benesch notifications@github.com wrote:

Integer scale only refers to the output resolution, not the upscale filter that's used. Being able to change the filter of the OpenGL 2 renderer is a recent feature. The OpenGL 1 renderer is limited to using the nearest filter only. I'm not sure if the nearest filter is the default for SDL2 in all cases.

The preferred filter depends on the tileset and the desired aesthetic. The SDL hint is something I could document better.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/libtcod/python-tcod/issues/106#issuecomment-761284514, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHHEHJBTLNQ7FFMTI3QT7LS2DTGRANCNFSM4WEOSNSA .

HexDecimal commented 3 years ago

I remember that image scale solved the blurry graphics

Integer scaling, not image scaling. It prevents sub-pixel distortion, which could appear as a blurry smear with a linear filter, or as jagged non-square-pixel artifacts with a nearest filter. Integer scaling ensures that the tileset doesn't get distorted, but doesn't determine if the tileset will be pixelated or smooth when upscaled.

Darky-Lucera commented 3 years ago

OK, thanks!

On Sat, Jan 16, 2021, 10:32 AM Kyle Benesch notifications@github.com wrote:

I remember that image scale solved the blurry graphics

Integer scaling, not image scaling. It prevents sub-pixel distortion, which could appear as a blurry smear with a linear filter, or as jagged non-square-pixel artifacts with a nearest filter. Integer scaling ensures that the tileset doesn't get distorted, but doesn't determine if the tileset will be pixelated or smooth when upscaled.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/libtcod/python-tcod/issues/106#issuecomment-761534032, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHHEHP3XAFU34UVOQTVLBDS2FMJZANCNFSM4WEOSNSA .

Darky-Lucera commented 3 years ago

It worked perfectly. Thanks!