Code Monkey home page Code Monkey logo

ssloy / tinyraycaster Goto Github PK

View Code? Open in Web Editor NEW
1.9K 40.0 141.0 27.34 MB

486 lines of C++: old-school FPS in a weekend

Home Page: https://github.com/ssloy/tinyraycaster/wiki

License: Do What The F*ck You Want To Public License

CMake 31.76% C++ 63.36% C 2.36% Dockerfile 0.49% Shell 2.03%
c-plus-plus picture graphics fps rendering raycasting fun images pixels computer-graphics opengl rendering-engine engine tutorial 3d 3d-graphics cpp rasterizer learning software-rendering

tinyraycaster's Issues

Build on Windows - incorrectly saved .ppm format

Hi!
First of all thank you for great tutorials on 3D graphics.

There is an issue when building project on Windows with GCC. In initial commit in file tinyraycaster.cpp in function drop_ppm_image you have:

std::ofstream ofs(filename);
ofs << "P6\n" << w << " " << h << "\n255\n";

On Windows GCC replaces \n in output file with platform specific code 0x0D0A, what is incorrect (it should be 0x0A in the file). This result in incorrect *.ppm image representation.
This happens because of opening file in "text" mode. To fix this, file should be opened in "binary" mode, for example like this:

std::ofstream ofs;
ofs.open(filename, std::ofstream::out | std::ofstream::binary);
ofs << "P6\n" << w << " " << h << "\n255\n";

Then everything works correctly. I think this patch would not affect other platforms.

Perfomance

How much faster is the way to render without graphics libraries, and with the help of standard language functions as you have in the game? Would it be better to switch to sdl?

sizeof(map) issue

When I try to run this the assert on line 64 always fails
assert (sizeof(map) == map_w * map_h + 1); // +1 for the null terminated string
because they are different sizes. When I checked with a std::cout statement it returned that sizeof(map) was 165 while map_w * map_h + 1 was 257. Is this not an issue on other computers? I'm just curious to see if I'm the only one that ran into this issue.

I used CLion, C++ 17, mingw.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.