{"id":209,"date":"2016-07-04T23:11:21","date_gmt":"2016-07-04T22:11:21","guid":{"rendered":"https:\/\/solidt.eu\/blog\/?p=209"},"modified":"2020-05-14T08:26:47","modified_gmt":"2020-05-14T07:26:47","slug":"c-glfw-example","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-glfw-example\/","title":{"rendered":"C GLFW example"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;GL\/glfw.h>\n\nint main()\n{\n    int     width, height;\n    int     frame = 0;\n    bool    running = true;\n\n    glfwInit();\n\n    if( !glfwOpenWindow( 512, 512, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )\n    {\n        glfwTerminate();\n        return 0;\n    }\n\n    glfwSetWindowTitle(\"GLFW Application\");\n\n    while(running)\n    {\n        frame++;\n\n        glfwGetWindowSize( &amp;width, &amp;height );\n        height = height > 0 ? height : 1;\n\n        glViewport( 0, 0, width, height );\n\n        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );\n        glClear( GL_COLOR_BUFFER_BIT );\n\n        glMatrixMode( GL_PROJECTION );\n        glLoadIdentity();\n        gluPerspective( 65.0f, (GLfloat)width\/(GLfloat)height, 1.0f, 100.0f );\n\n        \/\/ Draw some rotating garbage\n        glMatrixMode( GL_MODELVIEW );\n        glLoadIdentity();\n        gluLookAt(0.0f, -10.0f, 0.0f,\n                0.0f, 0.0f, 0.0f,\n                0.0f, 0.0f, 1.0f );\n\n        \/\/glTranslatef( 1.0f, 1.0f, 0.0f );\n        glRotatef(frame, 0.25f, 1.0f, 0.75f);\n        glBegin( GL_TRIANGLES );\n          glColor3f(0.1f, 0.0f, 0.0f );\n          glVertex3f(0.0f, 3.0f, -4.0f);\n          glColor3f(0.0f, 1.0f, 0.0f );\n          glVertex3f(3.0f, -2.0f, -4.0f);\n          glColor3f(0.0f, 0.0f, 1.0f );\n          glVertex3f(-3.0f, -2.0f, -4.0f);\n        glEnd();\n        glBegin( GL_TRIANGLES );\n          glColor3f(0.0f, 0.1f, 0.0f );\n          glVertex3f(0.0f, 3.0f, -3.0f);\n          glColor3f(0.0f, 0.0f, 1.0f );\n          glVertex3f(3.0f, -2.0f, -2.0f);\n          glColor3f(1.0f, 0.0f, 0.0f );\n          glVertex3f(-3.0f, -2.0f, 2.0f);\n        glEnd();\n        glfwSwapBuffers();\n\n        \/\/ exit if ESC was pressed or window was closed\n        running = !glfwGetKey(GLFW_KEY_ESC) &amp;&amp; glfwGetWindowParam( GLFW_OPENED);\n    }\n\n    glfwTerminate();\n\n    return 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-209","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":4,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":3745,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/209\/revisions\/3745"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}