{"id":41,"date":"2015-04-16T00:57:30","date_gmt":"2015-04-16T00:57:30","guid":{"rendered":"http:\/\/blog.qubekwest.com\/?p=41"},"modified":"2016-04-14T18:34:34","modified_gmt":"2016-04-14T18:34:34","slug":"learning-opengl-and-shaders","status":"publish","type":"post","link":"https:\/\/blog.qubekwest.com\/?p=41","title":{"rendered":"Learning OpenGL and Shaders"},"content":{"rendered":"<p>I&#8217;ve never really coded &#8220;to the metal&#8221; with a graphics library so this is going to be a bit of me talking out random non-mouth orifices. \u00a0Actually, never isn&#8217;t fully accurate I suppose. \u00a0For the sake of full disclosure I did what seemed like about 20 minutes worth of OpenGL 1.2 when I was in college the first time (16 years ago) and a full course with Direct3D during my second attempt at college (but didn&#8217;t make anything like a game). \u00a0Direct3D isn&#8217;t going to help me much since I&#8217;ve chosen Java and LWJGL and a tiny bit of 16 year old experience with OpenGL is as good as having never used it at all.<\/p>\n<p>This inspired another round of buying books. \u00a0I actually bought 5 of them, but the important ones for this conversation are &#8220;The Red Book&#8221; and &#8220;The Orange Book.&#8221; \u00a0More specifically, <em>OpenGL Programming Guide: Eighth Edition<\/em> and <em>OpenGL Shading Language: Third Edition<\/em>. \u00a0This is particularly amusing for me because when I was learning a little about OpenGL the first time, I actually bought the Second Edition of the Red Book and there was no such thing as a shader.<\/p>\n<p>So here I am, with literally thousands of pages to look over. \u00a0I&#8217;m not going to pretend that I will read all of these books cover to cover, but I have at least started to pick them over for useful bits and educational potential. \u00a0This is a mountain of a learning curve, but it&#8217;s a fun one to climb.<\/p>\n<p>Things I&#8217;ve pieced together so far&#8230; \u00a0The graphics pipeline used to be &#8220;fixed&#8221;. \u00a0This means that it always did roughly the same thing all the time. \u00a0Over time they made that pipeline more and more configurable in lots of fun ways. \u00a0Turning features on and off was the most control you had over how things worked.<\/p>\n<p>Over time, the processors on video cards got more powerful and more parallel and they introduced the ability to program them with small programs called shaders. \u00a0Sort of like the ability to configure the pipeline, only way more powerful. \u00a0The original shaders were extremely limited in the number of instructions they could do and what those instructions were allowed to be, but were still considered a step up from mere configuration options.<\/p>\n<p>Eventually shaders evolved into general purpose programs and the number of instructions you were allowed to use got large enough for them to be truly useful. \u00a0Video card makers saw this as an opportunity. \u00a0Why keep around the old fixed pipeline that was buried in configuration items when you could replace it with shaders by themselves? \u00a0Why create chips that have specific features that game designers may not even want when you can provide a way to run any features they want and leave the other ones out to avoid wasting overhead on them? \u00a0That&#8217;s how the &#8220;shader pipeline&#8221; was born.<\/p>\n<p>And now I have to learn how to use them&#8230; \u00a0:)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve never really coded &#8220;to the metal&#8221; with a graphics library so this is going to be a bit of me talking out random non-mouth orifices. \u00a0Actually, never isn&#8217;t fully accurate I suppose. \u00a0For the sake of full disclosure I did what seemed like about 20 minutes worth of OpenGL 1.2 when I was in &hellip; <a href=\"https:\/\/blog.qubekwest.com\/?p=41\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Learning OpenGL and Shaders<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":6,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}