{"id":62,"date":"2009-06-14T18:39:11","date_gmt":"2009-06-14T18:39:11","guid":{"rendered":"https:\/\/blogs.scummvm.org\/upthorn\/?p=62"},"modified":"2022-05-25T18:39:42","modified_gmt":"2022-05-25T18:39:42","slug":"how-this-is-going-to-work","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/upthorn\/2009\/06\/14\/how-this-is-going-to-work\/","title":{"rendered":"How this is going to work"},"content":{"rendered":"<div class=\"storycontent\">\n<p>After a great deal of discussion on the matter, Eugene has given me a final decision:<\/p>\n<p>The engine is going to specify a Graphics::PixelFormat to the backend.<\/p>\n<p>So here\u2019s how this is going to work:<\/p>\n<ul>\n<li>New Methods\n<ul>\n<li>Graphics::PixelFormat constructor, for convenience of engine developers (details to be determined)<\/li>\n<li>OSystem::getBestFormat(void)\n<ul>\n<li>Returns a Graphics::PixelFormat describing the highest bitdepth supported by the backend (important for YUV games which will want to output in the highest quality)<\/li>\n<\/ul>\n<\/li>\n<li>OSystem::initFormat(Graphics::PixelFormat)\n<ul>\n<li>Set up the color format of the virtual screen in the gfxtransaction, to be applied on endGfxTransaction<\/li>\n<\/ul>\n<\/li>\n<li>Graphics::PixelFormat OSystem::getScreenFormat(void)\n<ul>\n<li>Returns a pixelformat describing the current color mode<\/li>\n<\/ul>\n<\/li>\n<li>CursorManager::pushCursorFormat(Graphics::PixelFormat)\n<ul>\n<li>Pushes a new cursor pixel format onto the stack, and set it in the backend.<\/li>\n<\/ul>\n<\/li>\n<li>CursorManager::popCursorFormat(void)\n<ul>\n<li>Pop a cursor pixel format from the stack, and restore the previous one to the backend.<\/li>\n<li>If there is no previous format, the current screen format is used instead.<\/li>\n<li>Unlike CursorManager::popCursorPalette, this must be called <strong>prior<\/strong> to CursorManager::popCursor<\/li>\n<\/ul>\n<\/li>\n<li>CursorManager::replaceCursorFormat(Graphics::PixelFormat)\n<ul>\n<li>Replace the current cursor pixel format on the stack.<\/li>\n<li>If the stack is empty, the format is pushed instead.<\/li>\n<li>These methods should be called whenever the equivalent *CursorPalette methods are called, to keep cursor rendering straight across color mode changes.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Changed functions\/methods\n<ul>\n<li>initGraphics\n<ul>\n<li>Takes an optional pointer to a Graphics::PixelFormat struct<\/li>\n<li>if pointer is null or not supplied, initializes using CLUT8 (standard 8-bit that everything already uses)<\/li>\n<\/ul>\n<\/li>\n<li>OSystem::endGFXTransaction\n<ul>\n<li>Must apply the color mode setup by initFormat<\/li>\n<li>kTransactionPixelFormatNotSupported is included in the return value if color mode setup fails<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>TODO: new and changed class members.<\/li>\n<\/ul>\n<p>The bitdepth initialization process will be as follows:<\/p>\n<ul>\n<li>8Bit paletted:\n<ol>\n<li>Engine calls initGraphics (no changes are required on the engine side)<\/li>\n<li>initGraphics initializes a CLUT8 Graphics::PixelFormat, skips compatibility checking because all backends must support CLUT8 exactly they currently do<\/li>\n<li>initGraphics passes the CLUT8 PixelFormat to OSystem::initFormat<\/li>\n<li>Backend sees that the format matches the one that is currently set up, and ignores that part of the transaction<\/li>\n<\/ol>\n<\/li>\n<li>High or true color RGB:\n<ol>\n<li>Engine initializes a Graphics::PixelFormat with the color format that the game uses (games which convert from YUV will query OSystem::getBestFormat to decide this)<\/li>\n<li>Engine passes this format to initGraphics<\/li>\n<li>initGraphics passes this format to OSystem::initFormat<\/li>\n<li>Backend sets up virtual screen format to be applied with transaction<\/li>\n<li>Backend attempts to initialize virtual screen with specified format and resolution, falls back to 8-bit and returns kTransactionPixelFormatNotSupported on failure.<\/li>\n<li>initGraphics checks transaction return for kTransactionPixelFormatNotSupported, and warns if encountered.<\/li>\n<li>Engine queries backend (using OSystem::getScreenFormat) to check the current color format<\/li>\n<li>Engine branches based on result:\n<ul>\n<li>Requested format\n<ol>\n<li>Engine runs happily<\/li>\n<\/ol>\n<\/li>\n<li>CLUT8\n<ul>\n<li>If engine supports a 256 color fallback mode\n<ol>\n<li>Engine falls back to 256 colors, and runs with only minor complaint<\/li>\n<\/ol>\n<\/li>\n<li>If engine does not support a 256 color fallback\n<ol>\n<li>Engine displays error message that the system does not support its required format<\/li>\n<li>Engine returns with error (error code TBD).<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>After a great deal of discussion on the matter, Eugene has given me a final decision: The engine is going to specify a Graphics::PixelFormat to the backend. So here\u2019s how this is going to work: New Methods Graphics::PixelFormat constructor, for convenience of engine developers (details to be determined) OSystem::getBestFormat(void) Returns a Graphics::PixelFormat describing the highest [&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-62","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/posts\/62\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/upthorn\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}