{"id":35,"date":"2022-07-04T11:33:21","date_gmt":"2022-07-04T11:33:21","guid":{"rendered":"https:\/\/blogs.scummvm.org\/grisenti\/?p=35"},"modified":"2022-07-04T11:33:21","modified_gmt":"2022-07-04T11:33:21","slug":"start-of-the-graphics-rework","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/grisenti\/2022\/07\/04\/start-of-the-graphics-rework\/","title":{"rendered":"Start of the graphics rework"},"content":{"rendered":"<p>This week I started working on the graphics component of the engine, which is probably going to be the biggest task of the project. There\u2019s a lot of code to look at and trying to understand what is going on has been the biggest challenge yet.<\/p>\n<p>The first thing I worked on was the <code>LowLevelGraphicsSDL<\/code> class which implements some immediate mode drawing functions (through the opengl fixed function pipeline), the creation and management of the main rendering context and the creation of textures and vertex buffers. This class is also used for retrieving opengl information like the availability of vertex buffer objects or the possibility to use shaders. The last part was a surprise since I\u2019ve always taught that the engine required shaders. Turn out thought that if these are not available, or the game\u2019s graphical quality is set to the minimum (very low), it will run without them. It\u2019s a pretty bad experience \u2013 basically a horror game without lights &#8211; but at least it\u2019s playable.<\/p>\n<p>Next, I worked on implementing the <code>SDLTexture<\/code> class which went smoothly with only a few problems that were resolved in little time, though I haven\u2019t yet had the opportunity to fully test it so more problems will probably appear in the future.<\/p>\n<p>To check for bugs in the opengl calls I\u2019ve implemented a couple of macros that call <code>glGetError<\/code> and print a message when necessary. In the meantime, someone else implemented the same thing, but with more features in <em>graphics\/opengl\/debug.h<\/em> so in the future mine will be replaced.<\/p>\n<p>The last thing I completed this week was the <code>VertexBufferVBO<\/code> class which was a similar experience to the texture class mentioned above. This class is one of two vertex buffer classes, the previous one implemented in terms of vertex buffer objects (an opengl construct, usually shortened as VBO), while the other one, VertexBufferOGL, is implemented without VBOs and can be used in opengl versions under 2.0.<\/p>\n<p>After working on the previous task, I started working on shaders. The engine used CG, a toolkit made by nvidia that has now been deprecated, for what I assume is the ability to work in opengl versions under 2.0, where opengl\u2019s shaders were not yet available. CG\u2019s shading language is similar to GLSL (and more so to HLSL, the directx equivalent), but the two are not compatible so in the future I will have to translate them. Between the two there\u2019s not much difference, except for different data types and different names for some operations. In engine code a big difference between using CG and GLSL is that CG\u2019s shaders can be bound independently. This is in contrast to opengl in which the vertex shaders and the fragment shader must be linked before they can be used.<br \/>\nThis task was the most difficult this week and made me realize that I understood far less about the graphics system than I though. Although some opengl operations are very similar to what I&#8217;m familiar with, others I haven\u2019t fully understood, which has caused me some headaches. For now, I\u2019ve given up and since they are not necessary for the game to start, I will come back to them in the future, once I\u2019m more familiar with how the engine works.<\/p>\n<p>Next week I will keep working on graphics and hopefully get some part of the game to display, although I don\u2019t yet have a clear idea of what that would require.<\/p>\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I started working on the graphics component of the engine, which is probably going to be the biggest task of the project. There\u2019s a lot of code to look at and trying to understand what is going on has been the biggest challenge yet. The first thing I worked on was the LowLevelGraphicsSDL [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/35\/revisions\/36"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}