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

SDL.zig may not interact well with heap allocated bitmaps #39

Closed
paoda opened this issue Jan 8, 2022 · 2 comments
Closed

SDL.zig may not interact well with heap allocated bitmaps #39

paoda opened this issue Jan 8, 2022 · 2 comments
Labels
wontfix This will not be worked on

Comments

@paoda
Copy link
Contributor

paoda commented Jan 8, 2022

Currently, I'm trying to create a Gameboy Advance Emulator. For graphics, I have chosen to go with SDL2 and have decided to use SDL.zig as an alternative to using direct C bindings. Thank you for your work in creating this library.

I have stumbled across some confusing behaviour and have created a rather trivial example, which I shall link here.

The program creates and renders a white texture in the BGR555 Pixel Format. If you are to run this program, you will find a variable amount of garbage data displayed on the texture like in the screenshot below:
image

If you comment out L37, L38, and L39, and replace &white_heap with &white on L49 (the SDL_UpdateTexture call) the program works as expected, producing:
image

It is my current understanding that where the bitmap was allocated should have no effect on SDL2 displaying the texture itself.

I am quite unfamiliar with SDL.zig and SDL as a whole and therefore do not really know where to get started. I understand that you prefer contributions rather than bug reports and if so, I would at the very least appreciate some assistance regarding how I should go about identifying and resolving this issue.

@ikskuh
Copy link
Owner

ikskuh commented Jan 8, 2022

&white_heap is the address of the pointer, not the content of the pointer. Just pass white_heap instead. Right now, you're luckily just indexing into white with an offset. The "garbage" you see there is actually the address of your white_heap memory 😁

@ikskuh ikskuh added the wontfix This will not be worked on label Jan 8, 2022
@ikskuh ikskuh closed this as completed Jan 8, 2022
@paoda
Copy link
Contributor Author

paoda commented Jan 9, 2022

Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants