I'm back!
I started to work on moving from GLFW to SDL and to create proper system handling classes and renderer. Before it was just calling GLFW functions directly, rendering everything by going through all objects. And because I switched to purely 2D graphics, I had to order all visible objects and that's why I came up with renderer that gathers all data - code still goes through all objects in a room, but instead of drawing them immediately, it just stores, what and where should be drawn. This also means that it is now possible to gather data and process next frame, while current one is being rendered on separate thread. With 2D graphics this may sound as overkill but:
I started to work on moving from GLFW to SDL and to create proper system handling classes and renderer. Before it was just calling GLFW functions directly, rendering everything by going through all objects. And because I switched to purely 2D graphics, I had to order all visible objects and that's why I came up with renderer that gathers all data - code still goes through all objects in a room, but instead of drawing them immediately, it just stores, what and where should be drawn. This also means that it is now possible to gather data and process next frame, while current one is being rendered on separate thread. With 2D graphics this may sound as overkill but:
- I didn't do that yet. It runs on one thread.
- I want to keep all code clean and rendering functionality should be with rendering stuff.
- Switching in future to different graphics (voxels, 3D models) should be less problematic.
- It is modular.
- I had to solve issue of holes in doors. I want users to be able to create custom/new graphics and to make it easier for them. And as it is 2D graphics, I need some ordering of objects and drawing objects that are partially beyond the door.
And as for switching from GLFW to SDL. SDL provides all modules I need (although some need extra stuff to be done), it also handles any size of graphics, not only of power of 2. And finally, system classes are held in one place and if I ever feel that I should use other solution, I will just have to do it in one place.
Only thing I did since beginning of year up to last Sunday were commenting out old functionality, compiling libraries I need (sdl, sdl-image) and creating base for system classes. My mistake was to try to use sdl2 and I managed to modify sdl-image to compile with it and then prepare vapi for such sdl-image (I named it sdl2-image) and then... I realised that I really don't want to prepare vapi for sdl2. It is enough that I have to modify vapi for sdl to add functions that I find missing (SDL_SoftStretch, SDL_DisplayFormatAlpha).
Don't worry, this week I will make greater progress. I still need to think about how to represent graphics for walls/doors, well, regions in general, but that's separate issue.
No comments:
Post a Comment