{"id":509,"date":"2011-07-15T15:07:04","date_gmt":"2011-07-15T14:07:04","guid":{"rendered":"http:\/\/shadowcovenant.com\/blog\/2011\/07\/15\/textures-working\/"},"modified":"2011-07-15T15:07:04","modified_gmt":"2011-07-15T14:07:04","slug":"textures-working","status":"publish","type":"post","link":"http:\/\/shadowcovenant.com\/blog\/2011\/07\/15\/textures-working\/","title":{"rendered":"Textures working"},"content":{"rendered":"<p align=\"justify\">Worked a bit on the port of Spellbook to the Marmalade framework, got textures working:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/Textures.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"Textures\" border=\"0\" alt=\"Textures\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/Textures_thumb.jpg\" width=\"198\" height=\"374\" \/><\/a><\/p>\n<p align=\"justify\">That\u2019s on the emulator (couldn\u2019t take a decent photograph on my Samsung Galaxy S)\u2026 <\/p>\n<p align=\"justify\">Was quite complicated getting this to work, actually\u2026 <\/p>\n<p align=\"justify\">1) Had to build a DDS loader\u2026 Although it currently only supports R8G8B8A8, R8G8B8 and A8 formats, it can be easily extended in the future (specially when I understand some more about OpenGL, since OGL ES 1.0 only supports RGB, RGBA and LUMINANCE textures). Thankfully, I did half the work some time before when I did an iPhone application.<\/p>\n<p align=\"justify\">2) After I got this working, I only had a white square on the screen, where my sprite should be\u2026 After loads of mucking around in all the wrong places, I found out on a forum the solution: I had mipmapping enabled when I did the glTexImage2D to load the texture, so the function was still waiting for the rest of the data (for the mipmaps), and I wasn\u2019t giving it any\u2026 so the texture creation process wasn\u2019t finished and hence the white square\u2026<\/p>\n<p align=\"justify\">3) Channel ordering:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/Red_Blue_Channel_Switch_OpenGL.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"Red_Blue_Channel_Switch_OpenGL\" border=\"0\" alt=\"Red_Blue_Channel_Switch_OpenGL\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/Red_Blue_Channel_Switch_OpenGL_thumb.jpg\" width=\"170\" height=\"293\" \/><\/a><\/p>\n<p>Might have trouble seeing it, but the red and blue channel is switched\u2026 OpenGL stores the information differently from DirectX, which might be a problem in the future, when I want to do cross platform dynamic texture updating.<\/p>\n<p>Anyway, the sprite you\u2019re seeing is animated. It was generated with IBGen, a tool I built that grabs a 3d model and its animations and export a sprite sheet, an image bank and animation data to be used in 2d games. Below you can see an example of a sprite sheet:<\/p>\n<p><a href=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/afonso0400.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"afonso0400\" border=\"0\" alt=\"afonso0400\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/07\/afonso0400_thumb.jpg\" width=\"244\" height=\"244\" \/><\/a><\/p>\n<p>The packing system isn\u2019t very good yet, but it serves my purposes\u2026<\/p>\n<p>Still don\u2019t know what my next step is, but probably a better reaction to different orientations of the mobile (currently the graphics get drawn offscreen, etc, because Marmalade is reacting to it itself, which makes for weird effects).<\/p>\n<div id=\"tweetbutton509\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F07%2F15%2Ftextures-working%2F&amp;text=Textures%20working&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F07%2F15%2Ftextures-working%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Worked a bit on the port of Spellbook to the Marmalade framework, got textures working: That\u2019s on the emulator (couldn\u2019t take a decent photograph on my Samsung Galaxy S)\u2026 Was quite complicated getting this to work, actually\u2026 1) Had to build a DDS loader\u2026 Although it currently only supports R8G8B8A8, R8G8B8 and A8 formats, it [&hellip;]<\/p>\n<div id=\"tweetbutton509\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F07%2F15%2Ftextures-working%2F&amp;text=Textures%20working&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F07%2F15%2Ftextures-working%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,6],"tags":[],"class_list":["post-509","post","type-post","status-publish","format-standard","hentry","category-development","category-games"],"_links":{"self":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/comments?post=509"}],"version-history":[{"count":0,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/509\/revisions"}],"wp:attachment":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/media?parent=509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/categories?post=509"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/tags?post=509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}