{"id":193,"date":"2013-08-17T19:03:54","date_gmt":"2013-08-17T19:03:54","guid":{"rendered":"https:\/\/dario.scarpa.dev\/tobutomablo\/?p=193"},"modified":"2013-08-17T21:48:46","modified_gmt":"2013-08-17T21:48:46","slug":"learning-opengl-a-few-months-later","status":"publish","type":"post","link":"https:\/\/dario.scarpa.dev\/tobutomablo\/2013\/08\/17\/learning-opengl-a-few-months-later\/","title":{"rendered":"Learning OpenGL: a few months later"},"content":{"rendered":"<p>Yeah, I know, I failed to post at least once a month, the previous post dates back to April&#8230; but hey, did you read the title of the blog?<\/p>\n<p>In <a title=\"Learning OpenGL: getting started and picking the \u201cright\u201d libraries\" href=\"https:\/\/dario.scarpa.dev\/tobutomablo\/2013\/03\/04\/learning-opengl-getting-started-and-picking-the-right-libraries\/\" target=\"_blank\">this post<\/a>, in March, I wrote about documentation and libraries I found useful in getting started with modern OpenGL.<br \/>\nAfter a few months, I have a small addendum to do, both regarding documentation and libraries.<\/p>\n<h2>Documentation<\/h2>\n<p>When I wrote the old post, I suggested some tutorials and online documentation I had been consulting, and I wrote that I hadn&#8217;t heard of any single book suitable to learn modern OpenGL. A few weeks after my post, the <a href=\"http:\/\/www.opengl-redbook.com\" target=\"_blank\"><strong>OpenGL Programming Guide (8th edition)<\/strong><\/a>, also known as &#8220;<em>the red book<\/em>&#8220;, was published &#8211; and things changed.<br \/>\nI bought it from Amazon (33,50 \u20ac &#8211; definitely affordable) and spent the last week reading it cover to cover: it&#8217;s great stuff, clearly written, well organized, with the amount of detail I expected (not so much to make you feel lost, but enough to give a comprehensive introduction to the API).<br \/>\nI wish I had it when I started learning, and I strongly advise anybody trying to learn OpenGL to buy it right now &#8211; it will be a time saver.<\/p>\n<p><a href=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/openglredbook.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-195\" alt=\"openglredbook\" src=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/openglredbook-231x300.jpg\" width=\"231\" height=\"300\" srcset=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/openglredbook-231x300.jpg 231w, https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/openglredbook.jpg 501w\" sizes=\"auto, (max-width: 231px) 100vw, 231px\" \/><\/a><\/p>\n<p>I read that the previous editions were heavily criticized for mixing modern OpenGL with deprecated stuff, probably as a result of incrementally updating the book. Moreover, GLSL had its own book (&#8220;OpenGL Shading Language&#8221;, a.k.a. the &#8220;orange book&#8221;) that, I guess, you definitely needed to supplement the &#8220;red book&#8221; if you were using shaders.<\/p>\n<p>The 8th edition, instead, is a complete rewrite: it doesn&#8217;t use or describe the deprecated API, and it covers GLSL too.\u00a0Yay! Thankyou, book authors!<\/p>\n<h2>Libraries<\/h2>\n<p>If you read the old post, you might remember that I was quite confused about what was the best image handling library to be used with OpenGL.<\/p>\n<p>I listed DevIL, FreeImage, ImageMagick, OpenGL Image (GLI), and Simple OpenGL Image Library (SOIL).<br \/>\nRecently, I also stumbled on GL Image, part of the Unofficial OpenGL SDK, that looks promising.<\/p>\n<p>The &#8220;<a title=\"Unofficial OpenGL SDK\" href=\"https:\/\/www.google.it\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CC0QFjAA&amp;url=http%3A%2F%2Fglsdk.sourceforge.net%2F&amp;ei=DrwPUveDLMnvswaInYDYAg&amp;usg=AFQjCNG8Iz-EXDAajCRsOTsAEgHLOt10QQ&amp;sig2=bKMQcILmY55hzAb5yVBTdQ&amp;bvm=bv.50768961,d.Yms\" target=\"_blank\"><strong>Unofficial OpenGL SDK<\/strong><\/a>&#8221; deserves a special mention by itself: it&#8217;s a collection of libraries and utilities helpful in getting started with OpenGL development.<\/p>\n<p>I motivated my library-picks (GLFW, GLM, GLEW, Assimp) in my previous post, and I was glad to see that more experienced developers also choosed GLFW and GLM for their SDK. For image handling, the thing I was mostly in doubt about, they provided a custom library: I guess I wasn&#8217;t the only one unsatisfied in some way by all the popular libs?<br \/>\nOn the paper, GL Image rocks, and only lazyness and the dependancy on GL Load (the SDK alternative to GLEW, that I&#8217;m using) have prevented me to try it up to now.<\/p>\n<p>I don&#8217;t exclude switching to the SDK: as for the &#8220;red book&#8221;, I wish it was available earlier. Anyway, it&#8217;s worth noting that the SDK currently misses an asset loading library. Why don&#8217;t they include <a title=\"Assimp\" href=\"http:\/\/assimp.sourceforge.net\" target=\"_blank\">Assimp<\/a>? I&#8217;m using it, so I hope they don&#8217;t have any good reason! \ud83d\ude42<\/p>\n<p>A comparison of all the image handling libraries on some key points (formats supported, features, syntax, license, usability, portability, documentation) would be interesting: it looks like a lot of work, but maybe I&#8217;ll try to write something about it in the future.<\/p>\n<p>If you were wondering what I am using now, it&#8217;s <a title=\"DevIL\" href=\"http:\/\/openil.sourceforge.net\" target=\"_blank\">DevIL<\/a>.<br \/>\nThe library API is similar in some way to the OpenGL one, and for the very limited usage I&#8217;m doing, no problems arise.<br \/>\nUnfortunately, it looks like DevIL development ceased in 2010 &#8211; you&#8217;ve been warned.<\/p>\n<p>Anyway, postponing my final choice about image handling, there&#8217;s another library I&#8217;d like to suggest today: <strong><a title=\"AntTweakBar\" href=\"http:\/\/anttweakbar.sourceforge.net\" target=\"_blank\">AntTweakBar<\/a><\/strong>, a GUI library.<\/p>\n<p>At the beginning, I limited myself to using keyboard\/mouse events to select\/move objects and adjust colors or other properties in my test programs.<br \/>\nOf course, after a while, I ended up having an unspokable number of unpractical keyboard shortcuts, and no visual feedback about the current state (for example: coordinates of the selected object), that I only printed to the console in response to some key-presses.<\/p>\n<p>Don&#8217;t even reach that point: <strong>use a GUI library<\/strong> to interact with your OpenGL programs right from the beginning, you&#8217;ll save time later.<\/p>\n<p>I think Ant Tweak Bar is a very valuable choice in this field:<\/p>\n<ul>\n<li>it&#8217;s easy to integrate into your project (with simplified interfacing to popular libs such as GLUT, SDL, GLFW, SFML)<\/li>\n<li>it&#8217;s portable (Win\/Linux\/Mac)<\/li>\n<li>it looks cool &#8211; semi-transparent, floating windows<\/li>\n<li>it&#8217;s lightweight and easy to switch on\/off<\/li>\n<li>it provides some GUI components specifically thought for computer graphics: orientation, color, direction<\/li>\n<li>it allows grouping and hierarchically structuring components<\/li>\n<\/ul>\n<p>A GUI component worth a special mention is the &#8220;rotoslider&#8221;: you use it to change a value, like you do with a normal slider, but the circular motion allows you to:<\/p>\n<ul>\n<li>spin around multiple times \u00a0(e.g.: each full clockwise rotation increases the value by 100.0), while with a normal slider you are limited by the min\/max values associated with the start\/end positions<\/li>\n<li>vary the precision\/speed of the value changing: moving the mouse far from the circle gives precision, while moving it near the circle allows to increase\/decrease rapidly<\/li>\n<\/ul>\n<p>It&#8217; better understood with a picture, taken from the <a title=\"rotoslider\" href=\"http:\/\/anttweakbar.sourceforge.net\/doc\/tools:anttweakbar:rotoslider\" target=\"_blank\">wiki page of the rotoslider<\/a>:<\/p>\n<p><a href=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/rotoslider.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-196\" alt=\"rotoslider\" src=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/rotoslider.jpg\" width=\"366\" height=\"260\" srcset=\"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/rotoslider.jpg 366w, https:\/\/dario.scarpa.dev\/tobutomablo\/wp-content\/uploads\/2013\/08\/rotoslider-300x213.jpg 300w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><\/a><\/p>\n<p>That&#8217;s it for today! I have many half-written posts in my drafts, so I hope to publish something else soon.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yeah, I know, I failed to post at least once a month, the previous post dates back to April&#8230; but hey, did you read the title of the blog? In this post, in March, I wrote about documentation and libraries I found useful in getting started with modern OpenGL. After a few months, I have&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/dario.scarpa.dev\/tobutomablo\/2013\/08\/17\/learning-opengl-a-few-months-later\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[24,25,10,35,23],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-opengl","tag-anttweakbar","tag-image-handling","tag-libraries","tag-opengl","tag-red-book"],"_links":{"self":[{"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":5,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/posts\/193\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dario.scarpa.dev\/tobutomablo\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}