{"id":21,"date":"2007-06-03T14:47:23","date_gmt":"2007-06-03T20:47:23","guid":{"rendered":"http:\/\/blog.blockos.org\/?p=64"},"modified":"2010-06-27T20:51:16","modified_gmt":"2010-06-27T19:51:16","slug":"having-fun-with-opengl","status":"publish","type":"post","link":"https:\/\/blog.blockos.org\/?p=21","title":{"rendered":"Having fun with OpenGL"},"content":{"rendered":"<p>This weekend i played a little bit with <a href=\"http:\/\/www.opengl.org\">OpenGL<\/a>. First, i helped my brother with some issues using the <a href=\"http:\/\/www.opengl.org\/registry\/specs\/ARB\/texture_rectangle.txt\">GL_ARB_texture_rectangle<\/a> extensions. I never used it before. It&#8217;s very easy to use. You just have to use <strong>GL_TEXTURE_RECTANGLE_ARB<\/strong> instead of <strong>GL_ GL_TEXTURE_2D<\/strong> when you call openGL texture functions (or when you want to enable \/ disable texturing). The tricky part is that you have to specify that the pixel elements are stored one after the one. Also, textures coordinates values <em>(u,v)<\/em> are between <em>[0,twidth]x[0,theight]<\/em> instead of <em>[0,1]x[0,1]<\/em>.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Enable non rectangular textures\r\nglEnable( GL_TEXTURE_RECTANGLE_ARB );\r\n\/\/ Generate texture id\r\nglGenTextures( 1, &amp;id);\r\n\/\/ Pixel component are stored linearly\r\nglPixelStorei( GL_UNPACK_ALIGNMENT, 1 );\r\n\/\/ And now store the texture data\r\nglBindTexture( GL_TEXTURE_RECTANGLE_ARB, id);\r\nglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR );\r\nglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR );\r\nglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, textureWidth, textureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, data );\r\n<\/pre>\n<p>I must admit that i only used it to display a rectangular texture on screen. I found several examples on the web where it was used to avoid to scale the framebuffer when you save it to a texture.<\/p>\n<p>As one of the <a href=\"http:\/\/www.ggi-project.org\">GGI<\/a> <a href=\"http:\/\/code.google.com\/soc\/\">gsoc<\/a>  student is working on libggigl, i decided to code a little <a href=\"http:\/\/www.opengl.org\/documentation\/specs\/glx\/glx1.4.pdf\">GLX<\/a> example so that i don&#8217;t look stupid if he had questions about it \ud83d\ude42<br \/>\n<a href=\"http:\/\/blockos.untergrund.net\/data\/glxTest.c\">Here it is!<\/a><br \/>\nThere&#8217;re no functions, no structures. Everything is the main. That&#8217;s what I call pigforce coding.<br \/>\nIf I have time, I&#8217;ll try to play with offscreen rendering with GLX.<\/p>\n<p><strong>PCEngine tracker status<\/strong> : I&#8217;m writing code for hsync and vsync interrupts. It&#8217;s mostly a cleanup\/study of <a href=\"http:\/\/www.magicengine.com\/mkit\">mkit<\/a> code. I hope to finish them this week and then start with tile\/map management.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This weekend i played a little bit with OpenGL. First, i helped my brother with some issues using the GL_ARB_texture_rectangle extensions. I never used it before. It&#8217;s very easy to use. You just have to use GL_TEXTURE_RECTANGLE_ARB instead of GL_ GL_TEXTURE_2D when you call openGL texture functions (or when you\u2026 <a class=\"continue-reading-link\" href=\"https:\/\/blog.blockos.org\/?p=21\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,5],"tags":[27,29],"_links":{"self":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/21"}],"collection":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":1,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions\/137"}],"wp:attachment":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}