Skip to content

Esteban795/opengl-raycaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opengl-raycaster

A non RAM-eating raycaster made with C and OpenGL 3.0.

Warning

  • You might encounter memory leaks when the program closes. It depends, as it seems, whether you use a Nvidia graphics card with SDL2. I'm not entirely sure what is causing them behind the scenes, but I can't seem to fix it. There are zero (at least I hope) memory leaks that are caused by myself in this program. Here is a link that could explain you the situation. It sucks, but I can't really do anything about it on my own. I don't own nvidia.glibcore..

P.S : you might not see those memory leaks warnings,because I run clear right after the program ends.

What does it do ?

  • As you might have guessed it, it showcases an example of a raycaster, using a naive algorithm of raymarching, which causes some interesting problem once in a while. Definitely something to work on ! Basically, it casts rays in the direction that you're looking, and displays the result on your screen.


Requirements

  • Obviously, a C compiler. I tested the raycaster with both gcc (version 11.3) and clang, but really any decent C compiler should be ok running this.
  • Both SDL2, glew,glut, and OpenGL (I used version 3.0) are necessary to make the program work. You can install them on your own computer using the makefile by typing
make install

after you're done cloning the repo on your computer, using :

git clone https://github.com/Esteban795/opengl-raycaster.git

or whatever you want.
If for some reasons, make install doesn't work, you can install them manually using

apt install libglew-dev libsdl2-dev freeglut3-dev

How to install it on your computer ?

  • Just clone it wherever you want in your computer.
git clone https://github.com/Esteban795/opengl-raycaster.git
  • From there, you can just run
make all

It should render this :

first_example

How to use it ?

  • I'm french. So these are the standards french keyboards layouts at use. There is currently no plan to add keyboard layout detection.
Keys What they do
z go forwards
s go backwards
q go left
d go right
RIGHT_ARROW turns camera to the right
LEFT_ARROW turns camera to the left


What's left to do ?

  • Maybe add some kind of lighing ?
  • Allow users to input their own map !
  • Just found out about this tutorial with a different algorithm. I might reimplement the ray casting stuff !
  • A minimap in one of the two top corners. I need to figure out how to draw this and update our player position.

About

A raycaster made with C and OpenGL 3.0

Resources

License

Stars

Watchers

Forks