{"author_name":"Tenoch","cat":"LD #17 - Islands - 2010","comments":[{"author_name":"","time":"April 24, 2010 6:09 am","epoch":1272107340,"text":"If you don&#8217;t need to deform your mesh, try using display lists.","spam":"N"},{"author_name":"","time":"April 26, 2010 8:42 am","epoch":1272289320,"text":"Another idea would be to use your viewing frustrum to clip out any geometry that doesn&#8217;t need to be sent to the video card.","spam":"N"}],"epoch":1272105300,"likes":0,"metadata":{"p_key":"71199","p_author":"Tenoch","p_authorkey":"328","p_urlkey":"107020","p_title":"LuaGL performance fail!","p_cat":"LD #17 - Islands - 2010","p_event":"LD17","p_time":"1272105300","p_likes":"0","p_comments":"2","p_status":"UPD5","us_key":"328","us_name":"Tenoch","us_username":"tenoch","event_start":"1271980800","event_key":"3","event_name":"LD17"},"text":"<p>For obvious reasons, it&#8217;s not a good idea to use immediate mode (gl.Begin() gl.End()) with an interpreted language (lots of slow function calls).<\/p>\n <p>I therefore tried to use vertex arrays, since it&#8217;s apparently recommended by the Redbook of OpenGL. So be it. &#8216;Twas fine, until I realised that LuaGL would flatten arrays of vertices at every frame, which is slow as hell.<\/p>\n <p>I therefore transfered that part of the code to pure C. Once I have my nice mesh in Lua, I flatten it once, copy everything in one C array, and then uses this one with glDrawArrays. It&#8217;s a looot better.<\/p>\n <p>However, I wonder if my EeePC is really a 3D\u00a0 beast, because the following scene:<\/p>\n <div id=\"attachment_17290\" style=\"width: 560px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2010\/04\/Screenshot-1.png\"><img class=\"size-large wp-image-17290\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2010\/04\/Screenshot-1-550x358.png\" alt=\"200*200 heightfield, with 2 triangles per cell --&gt; 80000 polys, rendered twice (filled, outlined)\" width=\"550\" height=\"358\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2010\/04\/Screenshot-1-300x195.png 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2010\/04\/Screenshot-1-550x358.png 550w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2010\/04\/Screenshot-1.png 808w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><p class=\"wp-caption-text\">200*200 heightfield, with 2 triangles per cell --&gt; 80000 polys, rendered twice (filled, outlined)<\/p><\/div>\n <p>runs at about 4 fps. Laaaame.<\/p>\n <p>OK now I never did 3D before, so maybe I&#8217;m just not doing it rite (insert kitty picture).<\/p>\n <ul>\n <li>Vertex Arrays not supposed to be used like that? For now I have all the coordinates of all vertices of all polys one after the other into a 1D array of size (n tris * 3 vertices * 3 coordinates). So lots of vertices are repeated. Is that wrong? I see we can also use glDrawElements() to avoid repeating vertices, but that implies using an array of vertex indices. Would that be faster?<\/li>\n <li>Better technique than vertex arrays?<\/li>\n <li>Just plain too much polys, try to do level of detail, or manual clipping before drawing?<\/li>\n <li>Get rid of the nice outline (um, which gives as about 5 more fps&#8230;)?<\/li>\n <\/ul>\n <p>For now I&#8217;ll just reduce the size, try to get some proper terrain generation, and gameplay into that. Cause yeah, it&#8217;s supposed to be\u00a0 a game at some point&#8230;<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/screenshot\/\" rel=\"tag\">screenshot<\/a><\/p>","time":"April 24th, 2010 5:35 am","title":"LuaGL performance fail!"}