{"id":1133,"date":"2017-07-12T16:02:37","date_gmt":"2017-07-12T16:02:37","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=1133"},"modified":"2024-12-16T22:32:46","modified_gmt":"2024-12-16T19:32:46","slug":"sdl2-opengl-es","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/fr\/2017\/07\/12\/sdl2-opengl-es\/","title":{"rendered":"SDL2 &#8211; OpenGL ES"},"content":{"rendered":"<p>I love <strong>Panda3D<\/strong> game engine. But right now this engine is very hard to compile and debug on Microsoft Windows operation system. So as I said some time ago, I begin to develop my own graphics library. Right now it&#8217;s based on OpenGL ES and SDL2.<br \/>\nIn this article I am going to tell how to initialize OpenGL ES context and how SDL2 helps in this task. We are going to show <strong>nothing<\/strong>.<\/p>\n<h3>King Nothing<\/h3>\n<p>First of all you need to install OpenGL ES3 &#8211; GLES 3 libraries. This operation is platform dependant, for Ubuntu Linux you can just type <strong>sudo apt-get install libgles2-mesa-dev<\/strong>. To work with OpenGL you need to initialize OpenGL context. There is many ways to do that, by using one of libraries &#8211; SDL2, GLFW, GLFM etc. Actually there is no <strong>one<\/strong> right way to initialize OpenGL context, but I chose SDL2 because it&#8217;s cross-platform solution, code will look same for Windows\/*nix\/HTML5\/iOS\/Android\/etc.<\/p>\n<p>To install sdl2 on Ubuntu use this command <strong>sudo apt-get install libsdl2-dev<\/strong><\/p>\n<p>So here is OpenGL context initialization code with SDL2:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\">    SDL_Window *window = SDL_CreateWindow(\r\n            <span style=\"color: #0000ff;\">\"SDL2 - OGLES\"<\/span>,\r\n            SDL_WINDOWPOS_UNDEFINED,\r\n            SDL_WINDOWPOS_UNDEFINED,\r\n            <span style=\"color: #0000ff;\">640<\/span>,\r\n            <span style=\"color: #0000ff;\">480<\/span>,\r\n            SDL_WINDOW_OPENGL\r\n            );\r\n\t    \r\n\r\n    SDL_GLContext glContext = SDL_GL_CreateContext(window);\r\n<\/pre>\n<\/div>\n<p>After that, you can use any OpenGL calls in that context.<\/p>\n<p>Here is example code for this article:<br \/>\n<a href=\"https:\/\/github.com\/demensdeum\/OpenGLES3-Experiments\/tree\/master\/3sdl-gles\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/demensdeum\/OpenGLES3-Experiments\/tree\/master\/3sdl-gles<\/a><br \/>\n<a href=\"https:\/\/github.com\/demensdeum\/OpenGLES3-Experiments\/blob\/master\/3sdl-gles\/sdlgles.cpp\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/demensdeum\/OpenGLES3-Experiments\/blob\/master\/3sdl-gles\/sdlgles.cpp<br \/>\n<\/a><\/p>\n<p>You can build and test it with command <strong>cmake . &amp;&amp; make &amp;&amp; .\/SDLGles<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I love Panda3D game engine. But right now this engine is very hard to compile and debug on Microsoft Windows operation system. So as I said some time ago, I begin to develop my own graphics library. Right now it&#8217;s based on OpenGL ES and SDL2. In this article I am going to tell how<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/fr\/2017\/07\/12\/sdl2-opengl-es\/\">Continue reading <span class=\"screen-reader-text\">&#8220;SDL2 &#8211; OpenGL ES&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[61,52],"tags":[76,77],"class_list":["post-1133","post","type-post","status-publish","format-standard","hentry","category-techie","category-tutorials","tag-opengl","tag-sdl","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"fr","enabled_languages":["en","ru","zh","de","fr","ja","pt"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":false,"content":false,"excerpt":false},"de":{"title":false,"content":false,"excerpt":false},"fr":{"title":false,"content":false,"excerpt":false},"ja":{"title":false,"content":false,"excerpt":false},"pt":{"title":false,"content":false,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/posts\/1133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/comments?post=1133"}],"version-history":[{"count":9,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/posts\/1133\/revisions"}],"predecessor-version":[{"id":1142,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/posts\/1133\/revisions\/1142"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/media?parent=1133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/categories?post=1133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/fr\/wp-json\/wp\/v2\/tags?post=1133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}