{"id":11,"date":"2010-05-24T18:16:11","date_gmt":"2010-05-24T18:16:11","guid":{"rendered":"https:\/\/blogs.scummvm.org\/vgvgf\/?p=11"},"modified":"2022-05-21T18:19:53","modified_gmt":"2022-05-21T18:19:53","slug":"backend-design","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/vgvgf\/2010\/05\/24\/backend-design\/","title":{"rendered":"Backend Design"},"content":{"rendered":"<h2>The idea and goal<\/h2>\n<p>My first task is refactoring the backend structure. It has to be designed in a way to improve portability and make it easier to modify.\u00a0 Also, it has to allow an easy and fast way to use different libraries in platforms. This is mainly for making the next task, implementing OpenGL, easy to port.<\/p>\n<p>OpenGL is only a specification for rendering, and does not include Audio playing, timers, devices detection, and else functions that a library like SDL does have. So, the goal is to be able to use OpenGL for rendering and SDL for the other tasks, or other libraries\/sdks if needed.<\/p>\n<p>Now, the idea is to create a backend structure based on independent subsystems. Then, we can use the audio, timer, events, and else subsystems from SDL, and use the rendering subsystem from OpenGL.<\/p>\n<h2>Planed design<\/h2>\n<p>Each backend, like for example the SDL one, will inhereit from its subsystems that already inhereit from their virtual subsystem classes. And each subsystem will inhereit from the OSystem class.<\/p>\n<p><a href=\"https:\/\/web.archive.org\/web\/20110901055226\/http:\/\/vgvgf.com.ar\/gsoc\/wp-content\/uploads\/diagram11.png\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/vgvgf\/wp-content\/uploads\/sites\/58\/2022\/05\/diagram11.png\" \/><\/a><em>Example class diagram<\/em><\/p>\n<p>In the example diagram, SubSystem_Audio, SubSystem_Timer and SubSystem_Video are the virtual structure for the SubSystem_SDL* classes. The virtual subsystems will inhereit virtualy the class OSystem, then OSystem_SDL will only include one copy of OSystem. In actual ScummVM code, OSystem_SDL overrides all OSystem functions; in the planed desing, the OSystem functions will be mostly overriden by each subsystem, and only initialization or other special codes will be included in the OSystem_SDL backend.<\/p>\n<p>An idea I have in mind is also to separate the platform specify codes in OSystem_SDL, and create for each platform a new OSystem_*Platform* class that would inhereit the subsystems it needs. Then, we will have OSystem_Win, OSystem_Unix, OSystem_Mac, and else insteand of OSystem_SDL. This will help when implementing the OpenGL subsystem, as it will only be needed to change the inhereited video subsystem in the platform, and as the SDL name in the class doesn\u2019t reflect OpenGL is being used.<\/p>\n<div id=\"highlighter_165651\" class=\"syntaxhighlighter  \">\n<div class=\"bar                                                                                  show\">\n<div class=\"toolbar\"><a class=\"item viewSource\" title=\"view source\" href=\"https:\/\/web.archive.org\/web\/20110901055226\/http:\/\/vgvgf.com.ar\/gsoc\/page\/2\/\">view source<\/a><\/p>\n<div class=\"item copyToClipboard\"><embed id=\"highlighter_165651_clipboard\" title=\"copy to clipboard\" src=\"https:\/\/web.archive.org\/web\/20110901055226\/http:\/\/vgvgf.com.ar\/gsoc\/wp-content\/plugins\/syntaxhighlighter\/syntaxhighlighter\/scripts\/clipboard.swf\" type=\"application\/x-shockwave-flash\" width=\"16\" height=\"16\" data-mce-fragment=\"1\"><\/embed><\/div>\n<p><a class=\"item printSource\" title=\"print\" href=\"https:\/\/web.archive.org\/web\/20110901055226\/http:\/\/vgvgf.com.ar\/gsoc\/page\/2\/\">print<\/a><a class=\"item about\" title=\"?\" href=\"https:\/\/web.archive.org\/web\/20110901055226\/http:\/\/vgvgf.com.ar\/gsoc\/page\/2\/\">?<\/a><\/div>\n<\/div>\n<div class=\"lines\">\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>01<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/Example code<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>02<\/code><\/td>\n<td class=\"content\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>03<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/ Virtual Subsystems<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>04<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_Timer :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"keyword bold\">virtual<\/code>\u00a0<code class=\"plain\">OSystem { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>05<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_Audio :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"keyword bold\">virtual<\/code>\u00a0<code class=\"plain\">OSystem { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>06<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_Video :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"keyword bold\">virtual<\/code>\u00a0<code class=\"plain\">OSystem { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>07<\/code><\/td>\n<td class=\"content\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>08<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/ SDL subsystems<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>09<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_SDLTimer :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_Timer { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>10<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_SDLAudio :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_Audio { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>11<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_SDLVideo :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_Video { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>12<\/code><\/td>\n<td class=\"content\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>13<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/ OpenGL subsystem<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>14<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">SubSystem_OpenGL :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_Video { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>15<\/code><\/td>\n<td class=\"content\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>16<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/ Platfrom 1 - Using SDL<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>17<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">OSystem_Platform1 :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_SDLTimer,\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_SDLAudio,\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_SDLVideo { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>18<\/code><\/td>\n<td class=\"content\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>19<\/code><\/td>\n<td class=\"content\"><code class=\"comments\">\/\/ Platform 2 - Using SDL and OpenGL<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"line alt2\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>20<\/code><\/td>\n<td class=\"content\"><code class=\"keyword bold\">class<\/code>\u00a0<code class=\"plain\">OSystem_Platform2 :\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_SDLTimer,\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0\u00a0<code class=\"plain\">SubSystem_SDLAudio,\u00a0<\/code><code class=\"keyword bold\">public<\/code>\u00a0<code class=\"plain\">SubSystem_OpenGL { ...<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The idea and goal My first task is refactoring the backend structure. It has to be designed in a way to improve portability and make it easier to modify.\u00a0 Also, it has to allow an easy and fast way to use different libraries in platforms. This is mainly for making the next task, implementing OpenGL, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":13,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/posts\/11\/revisions\/13"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/vgvgf\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}