aod6060 / dsge

This is a simple 2D engine for my projects.
MIT License
1 stars 0 forks source link

Render System #1

Open aod6060 opened 1 month ago

aod6060 commented 1 month ago

Basically this is the main issues I'm currently tackling. I'm right now adding an opengl wrapper or glw which is in the has a bunch of opengl functionality that is wrapped to make it more focused on the modern pipe. Internally I've decided to use OpenGL 4.x as my main render api. I might decided later on to support Direct3D 11 if I need it (aka driver issues). Here a list of stuff I need for glw

That should sum up what I need for GLW its not a big list because the game engine isn't a 3D game engine so I don't need to add in Cubemaps or RenderBuffer because I'm don't need to Depth buffer for any thing. I might add that in to allow for Z ordering down the line. Next is for the actual render interface. The goal for this render interface is to only allow for the functionality that I'll need for the engine and nothing more. For instance sprite rendering... I can use just the main program to handle most of it but the drawing routine will require me passing a custom VertexBuffer for texCoords. Another example will be for TileMaps and ObjectMaps this will require both a custom VertexBuffers for both the vertices and texCoords. The other thing about the render is that internally it will have a fixed resolution at 640x480 (4:3) or 640x360 (16:9) so the actual render be independent to the actual resolution of the window. This means I'll have to make a FrameBuffer combo and a Texture2D that can resize if the use changes the resolution in the eventual setting menu.

aod6060 commented 1 month ago

I forgot one thing... I also need to add in font render here too. I need to display text output to the player which will be useful for alot of thing such as huds, custom ui elements, messagebox, etc.

aod6060 commented 1 month ago

Ok here is a simple example of what the render can do at this time... Currently_Have

I doesn't do much just yet but its a start. I guess I could make it move :)

aod6060 commented 1 month ago

Here is the introduction video of the issue as well as a bit of progress render_introduction_and_progress

aod6060 commented 1 month ago

Got done adding UniformBlock and UniformBuffer to the render. I also added a render interal interface for stuff that the rest of the application doesn't need to access to. Alright time to add in the other stuff.

aod6060 commented 1 month ago

Alright I've added in Texture2DArrays which is cool. Here is what it actually does. Texture2DArray_Example

What does a Texture2DArray does. It load up a bunch of images from the file. Here is the code example to initialize a Texture2DArray from file. This example is from main.cpp currently.

""" render::glw::Texture2DArray::createTexture2DArrayFromFiles(&icon_array, { "data/icon/icon_32.png", "data/icon/icon_32_green.png", "data/icon/icon_32_blue.png", "data/icon/icon_32_magenta.png" }); """

What I'm upload to are these images.

icon_32.png icon_32 icon_32_green.png icon_32_green icon_32_blue.png icon_32_blue icon_32_magenta.png icon_32_magenta

In order to get the rough fx we'll have to use custom texturecoords...

""" icon_array_texCoords.init(); icon_array_texCoords.add3(0.0f, 0.0f, 0.0f); icon_array_texCoords.add3(1.0f, 0.0f, 1.0f); icon_array_texCoords.add3(0.0f, 1.0f, 2.0f); icon_array_texCoords.add3(1.0f, 1.0f, 3.0f); icon_array_texCoords.update(); """

In order to render it we'll need to use the TEXTURE2D_ARRAY shader and the rest will work the same way as the normal textures.

""" render::startShader(render::ShaderType::ST_TEXTURE2D_ARRAY);

//render::setView(glm::mat4(1.0f)); render::setModel( glm::translate(glm::mat4(1.0f), glm::vec3(this->postion, 0.0f)) * glm::scale(glm::mat4(1.0f), glm::vec3(32.0f, 32.0f, 0.0f)) );

icon_array.bind(GL_TEXTURE0); render::draw(icon_array_texCoords); icon_array.unbind(GL_TEXTURE0);

render::endShader(); """

This is complete and I can't wait to start using them for tilemapping.

aod6060 commented 1 month ago

Time for the framebuffer.

aod6060 commented 1 month ago

Alright got done with the frame buffer. Which is cool. I'm going to create a quick video to document how it works because its a little hard to describe its functionality of without showing it off.

aod6060 commented 1 month ago

Here is the video. dsge_render_progress_ubo_t2da_fbo_gh

aod6060 commented 1 month ago

Here is a video to the post processing demo to demonstrate what the current render could do. postprocessing_demo_gh

aod6060 commented 1 month ago

Alright I'm back to the main branch. The last thing I want to add into the render section of the engine is font or text rendering. I've already started using my faviorit font pack which has a bunch of nice fonts for games. They are located in bin/data/font directory. I'll be trying to load them using freetype and then rendering them using OpenGL textures.

aod6060 commented 3 weeks ago

Alright I'm back. Had to do some family stuff which made up most of my time. Went to a dinner to honor my uncle who tragically died saving his men during Vietnam war from a tragic explosion that happened on a plane they were riding on. He was a great man according to my mom.

aod6060 commented 3 weeks ago

Here is an example of freetype rendering text to a cli freetype_rendering

aod6060 commented 3 weeks ago

Alright added in font rendering :) Added_Font_Rendering

aod6060 commented 3 weeks ago

I'm going to add in a separate shader to render fonts because it should be rendered on top of the game render unless it being used with in the render. Plus I want to add in coloring.

aod6060 commented 3 weeks ago

Alright added in a font shader to render out color font :) FontShader_Added

aod6060 commented 3 weeks ago

Here is the postprocessing image... image Shown in green for demonstration purposes. image

aod6060 commented 3 weeks ago

Here is the final video for a bit. I'm going to move onto the sound issue and add in the sound api finally. dsge_render_progress_font_rendering_with_freetype_gh

aod6060 commented 4 days ago

Alright I'm going to be adding in 4 new additions to the render system.

  1. Texture2D Manager
  2. Texture2DArray Manager
  3. VertexBuffer Manager
  4. IndexBuffer Manager
  5. Reload functions for all of these system + render global as well.
aod6060 commented 4 days ago

Texture2D manager will manage the 2D textures from a centralizer location. Now not all Texture2D will require a file load because they are being use to render to texture or some other purpose.

aod6060 commented 4 days ago

Texture2DArray manager will be very similar to the Texture2D manager but will manage Texture2DArrays

aod6060 commented 4 days ago

VertexBuffer manager will be used in a similar way to the previous 2 however it doesn't need to worry about loading anything from a file.

aod6060 commented 4 days ago

IndexBuffer manager will be the same as VertexBuffer manager, however, its for IndexBuffers.

aod6060 commented 4 days ago

Reload function are functions that will be called when the game reloads. I'm still debating on how this will work because I might need two functions for this one were I'm releasing resources and another reinitializing them. I might split it up into 2 different functions

  1. reloadInit()
  2. reloadRelease()

This actually might be better.