{"id":1267,"date":"2015-02-09T01:27:13","date_gmt":"2015-02-09T01:27:13","guid":{"rendered":"http:\/\/phoenixgamedevelopment.com\/blog\/?p=1267"},"modified":"2015-02-09T01:27:13","modified_gmt":"2015-02-09T01:27:13","slug":"p-155-phoenix-engine-update-6-text-rendering","status":"publish","type":"post","link":"https:\/\/phoenixgamedevelopment.com\/blog\/p-155-phoenix-engine-update-6-text-rendering\/","title":{"rendered":"P-155: Phoenix Engine Update 6: Text Rendering"},"content":{"rendered":"<p>I have now implemented the ability for the player to cycle the text onscreen. Finalising the text rendering took a little more work than I thought, since I had to integrate it into my existing rendering code.<\/p>\n<p>I realised that the main reason for my issues was a slight confusion over the way OpenGL works. Unlike a high-level games engine, OpenGL doesn&#8217;t use objects. It is a state machine, which means, instead of doing, for example:<\/p>\n<p>myobject.setrendermode(&#8220;wireframe&#8221;);<\/p>\n<p>you must first do something like this;<\/p>\n<p>SetModeWireframe<\/p>\n<p>Render Myobject<\/p>\n<p>SetModeNormal<\/p>\n<p>The reason why my text was not appearing properly was simply because I was setting the render mode to wireframe to create an &#8220;edged faces&#8221; effect\u00a0\u00a0around my shapes, like this:<br \/>\nglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );<\/p>\n<p>and I was not turning off wireframe, causing the text to render as an outline. Adding this line after rendering my wireframe fixed this issue:<\/p>\n<p>glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );<\/p>\n<p>&nbsp;<\/p>\n<p>I also learned about saving and loading the OpenGL state, which solved a lot of problems I was having with vertex attribute objects not rendering correctly. In OpenGL, is extremely important to reset the state after rendering, by doing something like this:<\/p>\n<p>glBindVertexArray(0);<br \/>\nglDeleteVertexArrays(1, &amp;vao);<\/p>\n<p>I think I have really turned a corner with my knowledge of OpenGL, I have much more of a command of it now. The next step in this project is to enable click-detection, so that the user can select objects in the world.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have now implemented the ability for the player to cycle the text onscreen. Finalising the text rendering took a little more work than I thought, since I had to integrate it into my existing rendering code. I realised that the main reason for my issues was a slight confusion over the way OpenGL works. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,16],"tags":[],"class_list":["post-1267","post","type-post","status-publish","format-standard","hentry","category-software-and-games","category-software-engines","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"aioseo_notices":[],"builder_content":"","_links":{"self":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/1267"}],"collection":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/comments?post=1267"}],"version-history":[{"count":1,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/1267\/revisions"}],"predecessor-version":[{"id":1268,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/1267\/revisions\/1268"}],"wp:attachment":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/media?parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/categories?post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/tags?post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}