Skip to content

Commit

Permalink
Fixed|Windows: Build errors and deferred GL calls
Browse files Browse the repository at this point in the history
Cleaned up some Windows-specific older code. The deferred OpenGL
function pointers were all nullptr.
  • Loading branch information
skyjake committed Oct 8, 2016
1 parent 2a2ea08 commit 861f2ba
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 19 deletions.
10 changes: 10 additions & 0 deletions doomsday/apps/client/src/gl/gl_defer.cpp
Expand Up @@ -157,6 +157,8 @@ static deferredtask_t* nextTask(void)

LIBDENG_GL_DEFER1(e, GLenum e)
{
DENG2_ASSERT(ptr != nullptr);

apifunc_t* api = (apifunc_t *) M_Malloc(sizeof(apifunc_t));
api->func.ptr_e = ptr;
api->param.e = e;
Expand All @@ -166,6 +168,8 @@ LIBDENG_GL_DEFER1(e, GLenum e)

LIBDENG_GL_DEFER2(i, GLenum e, GLint i)
{
DENG2_ASSERT(ptr != nullptr);

apifunc_t* api = (apifunc_t *) M_Malloc(sizeof(apifunc_t));
api->func.ptr_ei = ptr;
api->param.ei.e = e;
Expand All @@ -175,6 +179,8 @@ LIBDENG_GL_DEFER2(i, GLenum e, GLint i)

LIBDENG_GL_DEFER2(f, GLenum e, GLfloat f)
{
DENG2_ASSERT(ptr != nullptr);

apifunc_t* api = (apifunc_t *) M_Malloc(sizeof(apifunc_t));
api->func.ptr_ef = ptr;
api->param.ef.e = e;
Expand All @@ -184,6 +190,8 @@ LIBDENG_GL_DEFER2(f, GLenum e, GLfloat f)

LIBDENG_GL_DEFER2(fv4, GLenum e, const GLfloat* floatArrayWithFourValues)
{
DENG2_ASSERT(ptr != nullptr);

apifunc_t* api = (apifunc_t *) M_Malloc(sizeof(apifunc_t));
api->func.ptr_efv4 = ptr;
api->param.efv4.e = e;
Expand All @@ -193,6 +201,8 @@ LIBDENG_GL_DEFER2(fv4, GLenum e, const GLfloat* floatArrayWithFourValues)

LIBDENG_GL_DEFER2(uintArray, GLsizei s, const GLuint* v)
{
DENG2_ASSERT(ptr != nullptr);

apifunc_t* api = (apifunc_t *) M_Malloc(sizeof(apifunc_t));
api->func.ptr_uintArray = ptr;
api->param.uintArray.count = s;
Expand Down
42 changes: 36 additions & 6 deletions doomsday/apps/client/src/gl/gl_deferredapi.cpp
Expand Up @@ -37,37 +37,67 @@ static QOpenGLContext &context()
return *ClientWindow::main().context();
}

static void deng_glEnable(GLenum e)
{
LIBGUI_GL.glEnable(e);
}

static void deng_glDisable(GLenum e)
{
LIBGUI_GL.glDisable(e);
}

static void deng_glDeleteTextures(GLsizei num, GLuint const *names)
{
LIBGUI_GL.glDeleteTextures(num, names);
}

static void deng_glFogi(GLenum p, GLint v)
{
LIBGUI_GL.glFogi(p, v);
}

static void deng_glFogf(GLenum p, GLfloat v)
{
LIBGUI_GL.glFogf(p, v);
}

static void deng_glFogfv(GLenum p, GLfloat const *v)
{
LIBGUI_GL.glFogfv(p, v);
}

#define GL_CALL1(form, func, x) \
if(mustDefer()) GL_Defer_##form(func, x); else func(x);
#define GL_CALL2(form, func, x, y) \
if(mustDefer()) GL_Defer_##form(func, x, y); else func(x, y);

DENG_EXTERN_C void Deferred_glEnable(GLenum e)
{
GL_CALL1(e, reinterpret_cast<void (*)(GLenum)>(context().getProcAddress("glEnable")), e);
GL_CALL1(e, deng_glEnable, e);
}

DENG_EXTERN_C void Deferred_glDisable(GLenum e)
{
GL_CALL1(e, reinterpret_cast<void (*)(GLenum)>(context().getProcAddress("glDisable")), e);
GL_CALL1(e, deng_glDisable, e);
}

DENG_EXTERN_C void Deferred_glDeleteTextures(GLsizei num, GLuint const *names)
{
GL_CALL2(uintArray, reinterpret_cast<void (*)(GLsizei, GLuint const *)>(context().getProcAddress("glDeleteTextures")), num, names);
GL_CALL2(uintArray, deng_glDeleteTextures, num, names);
}

DENG_EXTERN_C void Deferred_glFogi(GLenum p, GLint v)
{
GL_CALL2(i, reinterpret_cast<void (*)(GLenum, GLint)>(context().getProcAddress("glFogi")), p, v);
GL_CALL2(i, deng_glFogi, p, v);
}

DENG_EXTERN_C void Deferred_glFogf(GLenum p, GLfloat v)
{
GL_CALL2(f, reinterpret_cast<void (*)(GLenum, GLfloat)>(context().getProcAddress("glFogf")), p, v);
GL_CALL2(f, deng_glFogf, p, v);
}

DENG_EXTERN_C void Deferred_glFogfv(GLenum p, GLfloat const *v)
{
GL_CALL2(fv4, reinterpret_cast<void (*)(GLenum, GLfloat const *)>(context().getProcAddress("glFogfv")), p, v);
GL_CALL2(fv4, deng_glFogfv, p, v);
}
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -81,12 +81,12 @@
#include "ui/editors/modelasseteditor.h"
#include "ui/ui_main.h"
#include "ui/postprocessing.h"

#include "ui/editors/edit_bias.h"

#include "sys_system.h"
#include "dd_main.h"
#include "clientapp.h"
#include "network/net_main.h"

#include <doomsday/console/cmd.h>
#include <doomsday/console/var.h>
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -473,13 +473,13 @@ DENG2_PIMPL(ClientWindow)

self.eventHandler().audienceForFocusChange() += this;

#ifdef WIN32
/*#ifdef WIN32
if (self.isFullScreen())
{
// It would seem we must manually give our canvas focus. Bug in Qt?
self.canvas().setFocus();
}
#endif
#endif*/

DD_FinishInitializationAfterWindowReady();

Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/ui/mouse_qt.cpp
Expand Up @@ -120,9 +120,9 @@ static void Mouse_Qt_GetState(mousestate_t *state)

static void Mouse_Qt_ShowCursor(bool yes)
{
#ifndef MACOSX
/*#ifndef MACOSX
de::Canvas &canvas = ClientWindowSystem::main().canvas();
#endif
#endif*/

LOG_INPUT_VERBOSE("%s cursor (presently visible? %b)")
<< (yes? "showing" : "hiding") << !cursorHidden;
Expand All @@ -133,7 +133,7 @@ static void Mouse_Qt_ShowCursor(bool yes)
#ifdef MACOSX
Cursor_Show(false);
#else
canvas.setCursor(QCursor(Qt::BlankCursor));
//canvas.setCursor(QCursor(Qt::BlankCursor));
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
#endif
}
Expand All @@ -144,7 +144,7 @@ static void Mouse_Qt_ShowCursor(bool yes)
Cursor_Show(true);
#else
qApp->restoreOverrideCursor();
canvas.setCursor(QCursor(Qt::ArrowCursor)); // Default cursor.
//canvas.setCursor(QCursor(Qt::ArrowCursor)); // Default cursor.
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/sdk/libgui/src/displaymode_windows.cpp
Expand Up @@ -29,7 +29,7 @@
#include <vector>

#include "de/gui/displaymode_native.h"
#include "de/PersistentCanvasWindow"
#include "de/PersistentGLWindow"

static std::vector<DEVMODE> devModes;
static DEVMODE currentDevMode;
Expand Down Expand Up @@ -115,9 +115,9 @@ int DisplayMode_Native_Change(const DisplayMode* mode, int shouldCapture)

void DisplayMode_Native_SetColorTransfer(DisplayColorTransfer const *colors)
{
if (!de::CanvasWindow::mainExists()) return;
if (!de::GLWindow::mainExists()) return;

HWND hWnd = (HWND) de::CanvasWindow::main().nativeHandle();
HWND hWnd = (HWND) de::GLWindow::main().nativeHandle();
DENG2_ASSERT(hWnd != 0);

HDC hDC = GetDC(hWnd);
Expand All @@ -130,7 +130,7 @@ void DisplayMode_Native_SetColorTransfer(DisplayColorTransfer const *colors)

void DisplayMode_Native_GetColorTransfer(DisplayColorTransfer *colors)
{
HWND hWnd = (HWND) de::CanvasWindow::main().nativeHandle();
HWND hWnd = (HWND) de::GLWindow::main().nativeHandle();
DENG2_ASSERT(hWnd != 0);

HDC hDC = GetDC(hWnd);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/sdk/libgui/src/glwindow.cpp
Expand Up @@ -323,14 +323,14 @@ void GLWindow::wheelEvent(QWheelEvent *ev)

bool GLWindow::event(QEvent *ev)
{
#ifdef WIN32
/*#ifdef WIN32
if (ev->type() == QEvent::ActivationChange)
{
//LOG_DEBUG("GLWindow: Forwarding QEvent::KeyRelease, Qt::Key_Alt");
QKeyEvent keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Alt, Qt::NoModifier);
return QApplication::sendEvent(&canvas(), &keyEvent);
}
#endif
#endif*/
return QOpenGLWindow::event(ev);
}

Expand Down

0 comments on commit 861f2ba

Please sign in to comment.