grizzlei / nle

nice little engine - tiny 3d game engine.
https://hasankaraman.dev/north/nice-little-engine-opengl-rendererphysics-engine/
MIT License
10 stars 1 forks source link

Improved rendering settings #2

Closed TheBoneJarmer closed 1 year ago

TheBoneJarmer commented 1 year ago

Hey,

I was browsing your code and I noticed something in https://github.com/grizzlei/nle/blob/69f1a59d002de9a687e86aa777a1fd3085bec099/src/nle/Renderer3D.cpp#L103

Your method seems to lack some stuff that disable back-culling and enable transparent textures. I will share what I use so you can see for yourself:

glEnable(GL_BLEND); // Enables the blending functionality
glEnable(GL_CULL_FACE); // Disables rendering of faces not visible to the camera, increases performance
glCullFace(GL_BACK); // Decides what face to hide for the camera, only works when GL_CULL_FACE is enabled
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Dunno how this works, it just makes sure transparency in textures are done right :p

glClearColor(this->clear_color.r / 255.0, this->clear_color.g / 255.0, this->clear_color.b / 255.0, this->clear_color.a / 255.0); // My clear functions start here
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Veerrry important to allow both for texture blending

// Render 3D shit

Hope it helps!

grizzlei commented 1 year ago

Hello @TheBoneJarmer thank you for your attention.

GL_BLEND will be enabled and disabled per object, but yes, we still need it somewhere in the Render3D::render() function. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); is called inside draw callback (set in Renderer3D constructor) I added set_clear_color member function to Renderer3D, will be included in the next commit.

GL_CULL_FACE is needed indeed as you said, will be added in the next commit.

Thanks for the heads up.

TheBoneJarmer commented 1 year ago

Hey, no biggie. Glad I could help! ^_^