#Raycaster bugs

1 messages · Page 1 of 1 (latest)

plush hemlock
#

Hi :)
(I don't know if this is the right place to ask this)

I've been making a small raycaster with C recently. but there is a really annoying bug I'm facing.
(you can see it in the video)

I checked my DDA render() function many times but i couldn't find any bugs.

If you have enough experience in this topic, help would be really appreciated :)

Full Code: https://github.com/proh14/pdoom (sorry for the un-clean code i was frustrated so i kept everything in a single file and wrote some dirty code 😢)
Lodev article on raycasters: https://lodev.org/cgtutor/raycasting.html
(Its easy to build just get sdl3 and build it with make)

GitHub

Contribute to proh14/pdoom development by creating an account on GitHub.

lunar sundialBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

untold coral
#

Maybe change:

hit = map[mappos.x][mappos.y];

to first y then x?

#

Also implement screen clearing

#

You just leave alot of junk pixels from the frame before

#
memset(state.pixels, 0x00, WINDOW_WIDTH * WINDOW_HEIGHT * sizeof(uint32_t));
#

That should help a bit

plush hemlock
#

it gives a really simillar bug with the pixels kind of staying after each movment

#

im worried it might be the way i use sdl????

opaque socket
#

its your code not sdl

#

your rendering sequence is just wrong. the further away wall should be rendered first

#

or technically printed on the screen first.

#

or render the first wall that the ray hits. which is probably the more correct way

plush hemlock
#

can you please show me how my rendering logic is wrong so i can fix it?

lunar sundialBOT
#

@plush hemlock Has your question been resolved? If so, type !solved :)

plush hemlock
#

Never mind!

#

I fixed it

#

it was a sdl issue

#

i switched to using SDL_TEXTUREACCESS_STREAMING

#

and SDL_LockTexture and SDL_UnlockLockTexture

#

!solved