{"id":1440,"date":"2018-08-05T07:39:13","date_gmt":"2018-08-05T07:39:13","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=1440"},"modified":"2025-08-12T12:05:33","modified_gmt":"2025-08-12T09:05:33","slug":"black-screen-opengl","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/hi\/2018\/08\/05\/black-screen-opengl\/","title":{"rendered":"We beat Malevich, black squares Opengl"},"content":{"rendered":"<p> Malevich periodically comes to any developer on OpenGL. This happens unexpectedly and boldly, you just start the project and see a black square instead of a wonderful render: <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1441\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/malevich.png\" alt=\"\" width=\"688\" height=\"553\" srcset=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/malevich.png 688w, https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/malevich-300x241.png 300w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/p>\n<p> Today I will describe for what reason I was visited by a black square, the problems found because of which Opengl does not draw anything on the screen, and sometimes even makes the window transparent. <\/p>\n<h3> Use tools <\/ h3><\/h3>\n<p> For debugging Opengl, two tools helped me: <a href = \"https:\/\/github.com\/baldurk\/renderdoc\" target = \"_ Blank\" rel = \"Noopener\"> renderdoc <\/a> and <aa> and <a href = \"https:\/\/github.com\/apitrace\/apitrace\" target = \"_ Blank\" rel = \"Noopener\"> apitrace <\/a>. Renderdoc &#8211; tool for debugging the OpenGL rendering process, you can view everything &#8211; Vertexes, shaders, textures, debt messages from the driver. Apitrace &#8211; A tool for tracing challenges of a graphic API, makes a dump calls and shows arguments. There is also a great opportunity to compare two dumps via WDIFF (or without, but not so convenient) <\/P><\/p>\n<h3> Check with whom you work <\/ h3><\/h3>\n<p> I have an operating system Ubuntu 16.10 with old dependencies SDL2, GLM, Assimp, Glew. In the latest version of Ubuntu 18.04, I get the assembly of the game <a href = \"https:\/\/gitlab.com\/demensdeum\/death-mask\" Target = \"_ Blank\" Rel = \"Noopener\"> Death-Mask <\/a> which does not show anything on the screen (only a black square). When using Chroot and assembly at 16.10 I <strong> I get a working assembly of the game with graphics <\/strong>. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1446\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/NOTSUREIF.jpg\" alt=\"\" width=\"417\" height=\"234\" \/><\/p>\n<p>It seems something broke in Ubuntu 18.04 <\/p>\n<p> <strong> LDD <\/strong> showed the linkka to identical libraries SDL2, GL. Driving a non -working build in Renderdoc, I saw garbage at the entrance to the vertex shader, but I needed a more solid confirmation. In order to understand the difference between the binarics, I drove them both through <strong> apitrace <\/strong>. Comparison of dumps showed me that the assembly on a fresh Ubunta breaks the program of the prospects in OpenGL, actually sending garbage there: <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1448\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/apicalls.png\" alt=\"\" width=\"1902\" height=\"234\" srcset=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/apicalls.png 1902w, https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/apicalls-300x37.png 300w, https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/apicalls-768x94.png 768w, https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2018\/08\/apicalls-1024x126.png 1024w\" sizes=\"auto, (max-width: 1902px) 100vw, 1902px\" \/><\/p>\n<p> Matrices gather in the GLM library. After copying GLM from 16.04 &#8211; I got the working build of the game again. The problem was the difference in the initialization of a single matrix in GLM 9.9.0, it is necessary to clearly indicate the MAT4 (1.0F) argument in it in the constructor. Having changed the initialization and <a href = \"https:\/\/github.com\/g-truc\/glm\/issues\/797\" rel = \"Noopener\" target = \"_ Blank\"> by writing off <\/a> the author of the library, I began to do <a href = \"https:\/\/gitlab.com\/demensdeum\/fsgltest\" Target = \"_ Blank\" red = \"Noopener\"> tests for fsgl <\/a>. In the process of writing which I found flaws in FSGL, I will describe them further. <\/p>\n<h3> Determine who is in life <\/ h3><\/h3>\n<p> For the correct work with OpenGL, you need to <strong> <em> voluntarily forcibly <\/em> <\/strong> request the context of a certain version. So it looks for SDL2 (you need to put the version strictly before initializing the context): <\/p>\n<p> <!-Html Generated Using Hilite.me-> <\/p>\n<p><Div Style = \"Background: #FFFFFFFLAFFLOW: AUTO; Width: Auto; Border: Solid Gray; Border-Width: .1em .1em .1em .8em; Padding: .2em .6em;\"><br \/>\n<Pre style = \"margin: 0; line-height: 125%;\"> sdl_gl_seettrtribute (sdl_gl_context_major_version, <span style = \"color: #0000dd; font-weight: bold; \"> 3 <\/span>);<br \/>\nSDL_GL_SETTRIBUTE (SDL_GL_CONTEXT_MINOR_VERSION, <SPAN STYLE = \"Color: #0000DD; font-weight;\"> 2 <\/span>);<br \/>\nSDL_GL_SETTRIBUTE (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);<br \/>\n<\/ Pre>\n<\/div>\n<p> For example, Renderdoc does not work with contexts below 3.2. I would like to note that after switching the context <strong> there is a high probability of seeing the same black screen <\/strong>. Why? <Br \/><br \/>\nBecause the <strong> context of Opengl 3.2 must require the presence of VAO buffer <\/strong>, without which 99% of graphic drivers do not work. Add it easy: <br \/>\n<!-Html Generated Using Hilite.me-> <\/p>\n<p><Div Style = \"Background: #FFFFFFFLAFFLOW: AUTO; Width: Auto; Border: Solid Gray; Border-Width: .1em .1em .1em .8em; Padding: .2em .6em;\"><br \/>\n<Pre style = \"Margin: 0; line-height: 125%;\"> Glgenvertexarrays (<span style = \"color: #0000dd; font-weight: bold;\"> 1 <\/span>, <span style = \"color. #333333; \"> &#038; <\/span> vao);<br \/>\nGLBINDVERTEXARAY (VAO);<br \/>\n<\/ Pre>\n<\/div>\n<h3> Do not sleep, freeze <\/ h3><\/h3>\n<p> I also met an interesting problem on Kubuntu, instead of a black square I was displayed transparent, and <strong> sometimes <\/strong> everything was rendered correctly. I found the solution to this problem at Stack Overflow: <br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/38411515\/sdl2-opengl-window-appears-semi-transparent-sometimes\" target=\"_blank\" rel=\"noopener\">https:\/\/stackoverflow.com\/questions\/38411515\/sdl2-opengl-window-appears-semi-transparent-sometimes<\/a><\/p>\n<p> The FSGL test render code was also present <strong> Sleep (2S) <\/strong>; So on the Xubuntu and Ubuntu I received the correct render and sent the application to sleep, but on Kubuntu I received a transparent screen in 80% of the launch of Dolphin and 30% of launches and terminal. To solve this problem, I added rendering in each frame, after a SDlevent survey, as recommended in the documentation. <\/p>\n<p> Test code: <br \/>\n<a href=\"https:\/\/gitlab.com\/demensdeum\/FSGLtests\/blob\/master\/renderModelTest\/\" target=\"_blank\" rel=\"noopener\">https:\/\/gitlab.com\/demensdeum\/FSGLtests\/blob\/master\/renderModelTest\/<\/a><\/p>\n<h3> Talk to the driver <\/ h3><\/h3>\n<p> Opengl supports the communication channel between the application and the driver, to activate it, you need to turn on the flags Gl_debug_outPut, GL_DEBUG_OUTPUT_SYNCHRONUS, affix the warning <SPAN Class = \"PL-C1\"> GLDEBUGMESSAGECONTROL <\/SPAN> and tie the calback through <span class = \"PL-C1\"> GLDEBUGMESSAGECALLBACK <\/SPAN>. <Br\/><br \/>\nAn example of initialization can be taken here: <br \/>\n<a href=\"https:\/\/github.com\/rock-core\/gui-vizkit3d\/blob\/master\/src\/EnableGLDebugOperation.cpp\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/rock-core\/gui-vizkit3d\/blob\/master\/src\/EnableGLDebugOperation.cpp<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Malevich periodically comes to any developer on OpenGL. This happens unexpectedly and boldly, you just start the project and see a black square instead of a wonderful render: Today I will describe for what reason I was visited by a black square, the problems found because of which Opengl does not draw anything on the<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/hi\/2018\/08\/05\/black-screen-opengl\/\">Continue reading <span class=\"screen-reader-text\">&#8220;We beat Malevich, black squares Opengl&#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":[49,61,52],"tags":[],"class_list":["post-1440","post","type-post","status-publish","format-standard","hentry","category-blog","category-techie","category-tutorials","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"hi","enabled_languages":["en","ru","zh","de","fr","ja","pt","hi"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false},"hi":{"title":false,"content":false,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/posts\/1440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/comments?post=1440"}],"version-history":[{"count":23,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/posts\/1440\/revisions"}],"predecessor-version":[{"id":4220,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/posts\/1440\/revisions\/4220"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/media?parent=1440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/categories?post=1440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/hi\/wp-json\/wp\/v2\/tags?post=1440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}