{"assets":[],"author_link":"author\/mjau\/","author_name":"mjau","cat":"LD #23","categories":["LD #23"],"comments":[],"epoch":1334932620,"event":"LD23","likes":4,"metadata":{"p_key":"78047","p_author":"mjau","p_authorkey":"0","p_urlkey":"287057","p_title":"Dynamic OpenGL for LuaJIT","p_cat":"LD #23","p_event":"LD23","p_time":"1334932620","p_likes":"4","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1334880000","event_key":"10","event_name":"LD23"},"source_url":"2012\/04\/20\/dynamic-opengl-for-luajit\/","text":"<p>I\u2019ve been toying around with <a href=\"http:\/\/luajit.org\/\" title=\"LuaJIT\">LuaJIT<\/a> lately. If you\u2019re not familiar with LuaJIT, it\u2019s a just-in-time compiler that not only makes your Lua code run super fast, but it also makes it possible to call native code from Lua without any native glue code at all. Pretty cool tech.<\/p>\n<p>OpenGL requires some special handling though, so I made an OpenGL loader for it that handles all the dynamic loading, version differences and extensions and such for you (based on the official spec files), and added some extra code to make shaders easier to work with. I didn\u2019t really plan on using this for LD, but hey, might as well post it now so that I have the option: <a href=\"http:\/\/d011.org\/misc\/ld23base.zip\">ld23base.zip<\/a> (zlib license)<\/p>\n<p>That zip includes some example code using SDL + OpenGL to draw a spinning rectangle in pure Lua =).\u00a0 I doubt anyone else will use this, but you\u2019re of course welcome to if you want =). Please let me know if you do! It\u2019s a bit WIP-y still, but fully usable and should be pretty straightforward if you\u2019re familiar with SDL and OpenGL. It probably requires LuaJIT 2.0 (beta) to run, and it\u2019s only been tested on 64-bit Linux, but it should hopefully run on anything supported by LuaJIT as long as SDL and OpenGL libs are available.<\/p>\n<p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/basecode\/\" rel=\"tag\">basecode<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/lua\/\" rel=\"tag\">lua<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/luajit\/\" rel=\"tag\">luajit<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/opengl\/\" rel=\"tag\">opengl<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/sdl\/\" rel=\"tag\">SDL<\/a><\/p>","time":"April 20th, 2012 2:37 pm","title":"Dynamic OpenGL for LuaJIT","title_was_empty":false}