ands / lightmapper

A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!
1.44k stars 134 forks source link

Minor refactor and code cleanup #12

Closed aidinabedi closed 6 years ago

aidinabedi commented 6 years ago

The purpose of the PR is to improve readability and make contributions easier down the road. Changes include:

ands commented 6 years ago

Hey, thanks for contributing :) Could you explain why you moved the main loop part to a separate function? Is that necessary to get it to run on WebGL at some point?

aidinabedi commented 6 years ago

Hello @ands!

Short answer: Yes, it is necessary for WebGL-compatibility - which is exactly what I'm planning :)

Long answer: For the project to run inside a web browser - the loop-part will need to be an event callback instead of an actual loop - otherwise, it will block everything else in the browser. So to make the code support both platforms, I refactored the loop-part so it can easily be used in a normal loop (when built as standalone executable) or as a callback (when built for the browser).

ands commented 6 years ago

Alright, thanks for the explanation :)