From d73eeb0c3fac578ed2b8f2a5077966a79dcc6adb Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 29 Feb 2016 09:14:18 +0300 Subject: [PATCH] fix opengl on win32 --- examples/d3d/src/d3d.d | 3 +++ src/dlangui/graphics/glsupport.d | 14 +++++++++++--- src/dlangui/platforms/windows/winapp.d | 7 +------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/d3d/src/d3d.d b/examples/d3d/src/d3d.d index f168b136..9696e5d0 100644 --- a/examples/d3d/src/d3d.d +++ b/examples/d3d/src/d3d.d @@ -14,6 +14,9 @@ mixin APP_ENTRY_POINT; /// entry point for dlangui based application extern (C) int UIAppMain(string[] args) { + // embed resources listed in views/resources.list into executable + embeddedResourceList.addResources(embedResourcesFromList!("resources.list")()); + // create window Window window = Platform.instance.createWindow("DlangUI example - 3D Application", null, WindowFlag.Resizable, 600, 500); window.mainWidget = new UiWidget(); diff --git a/src/dlangui/graphics/glsupport.d b/src/dlangui/graphics/glsupport.d index 86f506b9..7e965174 100644 --- a/src/dlangui/graphics/glsupport.d +++ b/src/dlangui/graphics/glsupport.d @@ -1086,7 +1086,13 @@ class GLVertexBuffer : VertexBuffer { /// bind into current context override void bind() { - glBindVertexArray(_vao); + checkgl!glBindVertexArray(_vao); + + // TODO: is it necessary to bind vertex/index buffers? + // specify vertex buffer + checkgl!glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); + // specify index buffer + checkgl!glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); } /// unbind from current context @@ -1102,8 +1108,10 @@ class GLVertexBuffer : VertexBuffer { for(int i = 0; i < _format.length; i++) { int loc = effect.getVertexElementLocation(_format[i].type); if (loc >= 0) { - glVertexAttribPointer(loc, _format[i].size, GL_FLOAT, GL_FALSE, _format.vertexSize, cast(char*)(offset)); - glEnableVertexAttribArray(loc); + checkgl!glVertexAttribPointer(loc, _format[i].size, GL_FLOAT, GL_FALSE, _format.vertexSize, cast(char*)(offset)); + checkgl!glEnableVertexAttribArray(loc); + } else { + Log.d("Attribute location not found for ", _format[i].type); } offset += _format[i].byteSize; } diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index b76ac52e..81fbc9ff 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -223,11 +223,6 @@ class Win32Window : Window { Win32Platform _platform; HWND _hwnd; - static if (ENABLE_OPENGL) { - HGLRC _hGLRC; // opengl context - HPALETTE _hPalette; - //GLSupport _gl; - } dstring _caption; Win32ColorDrawBuf _drawbuf; bool useOpengl; @@ -560,7 +555,7 @@ class Win32Window : Window { debug(DebugRedraw) Log.d("onPaint()"); long paintStart = currentTimeMillis; static if (ENABLE_OPENGL) { - if (useOpengl && _hGLRC) { + if (useOpengl && sharedGLContext._hGLRC) { paintUsingOpenGL(); } else { paintUsingGDI();