fix opengl on win32

This commit is contained in:
Vadim Lopatin 2016-02-29 09:14:18 +03:00
parent a2a4523e13
commit d73eeb0c3f
3 changed files with 15 additions and 9 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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();