-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Unit: gg/sokolA video, sound, rendering, or fonts related issue.A video, sound, rendering, or fonts related issue.
Description
Feature Request: Texture Filtering Controls in gg Module
Problem
The gg graphics module currently doesn't expose texture filtering controls, making it difficult to achieve pixel-perfect rendering for pixel art games. When scaling images using draw_image_part(), the graphics
backend applies linear filtering by default, causing blurriness and anti-aliasing artifacts that are undesirable for pixel art.
Current Behavior
// This scales a 16x16 tile to 32x32 but results in blurry/filtered output
dst_rect := gg.Rect{x, y, 32.0, 32.0}
src_rect := gg.Rect{src_x, src_y, 16.0, 16.0}
ctx.draw_image_part(dst_rect, src_rect, &img)Even with sample_count: 1 to disable anti-aliasing, the texture filtering still causes blurriness when scaling images.
Desired Behavior
Add texture filtering options to either:
- gg.Config for global texture filtering:
gg.new_context(
sample_count: 1
texture_filter: .nearest // or .linear (default)
)- Per-image filtering when creating images:
img := ctx.create_image_with_filter(path, .nearest) or { panic(err) }- Per-draw-call filtering:
ctx.draw_image_part_filtered(dst_rect, src_rect, &img, .nearest)Workarounds Attempted
- Setting
sample_count: 1(helps with anti-aliasing but not texture filtering) - Manual pixel-by-pixel rendering (performance issues and complexity)
- Integer-only coordinates (doesn't solve the core filtering issue)
Similar APIs
- OpenGL:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) - SDL:
SDL_SetTextureScaleMode(texture, SDL_ScaleModeNearest) - Raylib:
SetTextureFilter(texture, TEXTURE_FILTER_POINT)
Would it be possible to expose the underlying graphics backend's texture filtering controls through the gg module?
Use Case
This is essential for:
- Pixel art games and applications
- Retro-style graphics that need crisp, unfiltered scaling
- Any application requiring precise pixel control
Version used
0.4.11 e3b07d9
Environment details (OS name and version, etc.)
macOS 15.5 (24F74)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Unit: gg/sokolA video, sound, rendering, or fonts related issue.A video, sound, rendering, or fonts related issue.