Linux: start getting somewhere with the whole OpenGL shito
This commit is contained in:
parent
23eccc9439
commit
891ab9fd3c
|
@ -21,9 +21,12 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LTO)
|
if(ENABLE_LTO)
|
||||||
add_compile_options(-flto)
|
add_compile_options(-O2 -flto)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_compile_options(-fno-pic)
|
||||||
|
add_link_options(-no-pie)
|
||||||
|
|
||||||
option(BUILD_LIBUI "Build libui frontend" ON)
|
option(BUILD_LIBUI "Build libui frontend" ON)
|
||||||
option(BUILD_SDL "Build SDL2 frontend" OFF)
|
option(BUILD_SDL "Build SDL2 frontend" OFF)
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,21 @@ add_library(core STATIC
|
||||||
GPU.cpp
|
GPU.cpp
|
||||||
GPU2D.cpp
|
GPU2D.cpp
|
||||||
GPU3D.cpp
|
GPU3D.cpp
|
||||||
|
GPU3D_OpenGL.cpp
|
||||||
GPU3D_Soft.cpp
|
GPU3D_Soft.cpp
|
||||||
NDS.cpp
|
NDS.cpp
|
||||||
NDSCart.cpp
|
NDSCart.cpp
|
||||||
|
OpenGLSupport.cpp
|
||||||
RTC.cpp
|
RTC.cpp
|
||||||
Savestate.cpp
|
Savestate.cpp
|
||||||
SPI.cpp
|
SPI.cpp
|
||||||
SPU.cpp
|
SPU.cpp
|
||||||
Wifi.cpp
|
Wifi.cpp
|
||||||
WifiAP.cpp
|
WifiAP.cpp
|
||||||
# opengl backend stuff
|
|
||||||
GPU3D_OpenGL.cpp
|
|
||||||
OpenGLSupport.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(core OpenGL)
|
target_link_libraries(core GL)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include "OpenGLSupport.h"
|
#include "OpenGLSupport.h"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
|
|
||||||
DO_PROCLIST(DECLPROC);
|
DO_PROCLIST(DECLPROC);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define OPENGLSUPPORT_H
|
#define OPENGLSUPPORT_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ if (UNIX)
|
||||||
--generate-header "${CMAKE_SOURCE_DIR}/melon_grc.xml")
|
--generate-header "${CMAKE_SOURCE_DIR}/melon_grc.xml")
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
target_link_libraries(melonDS dl)
|
target_link_libraries(melonDS dl X11)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_sources(melonDS PUBLIC melon_grc.c)
|
target_sources(melonDS PUBLIC melon_grc.c)
|
||||||
|
|
|
@ -615,6 +615,8 @@ _UI_EXTERN uiGLContext *uiAreaGetGLContext(uiArea* a);
|
||||||
_UI_EXTERN void uiGLMakeContextCurrent(uiGLContext* ctx);
|
_UI_EXTERN void uiGLMakeContextCurrent(uiGLContext* ctx);
|
||||||
_UI_EXTERN unsigned int uiGLGetVersion(uiGLContext* ctx);
|
_UI_EXTERN unsigned int uiGLGetVersion(uiGLContext* ctx);
|
||||||
_UI_EXTERN void *uiGLGetProcAddress(const char* proc);
|
_UI_EXTERN void *uiGLGetProcAddress(const char* proc);
|
||||||
|
_UI_EXTERN int uiGLGetFramebuffer(uiGLContext* ctx);
|
||||||
|
_UI_EXTERN float uiGLGetFramebufferScale(uiGLContext* ctx);
|
||||||
_UI_EXTERN void uiGLSwapBuffers(uiGLContext* ctx);
|
_UI_EXTERN void uiGLSwapBuffers(uiGLContext* ctx);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ struct areaWidgetClass {
|
||||||
GtkDrawingAreaClass parent_class;
|
GtkDrawingAreaClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct uiGLContext uiGLContext;
|
||||||
|
|
||||||
struct uiArea {
|
struct uiArea {
|
||||||
uiUnixControl c;
|
uiUnixControl c;
|
||||||
GtkWidget *widget; // either swidget or areaWidget depending on whether it is scrolling
|
GtkWidget *widget; // either swidget or areaWidget depending on whether it is scrolling
|
||||||
|
@ -41,7 +43,8 @@ struct uiArea {
|
||||||
GtkGLArea *glArea;
|
GtkGLArea *glArea;
|
||||||
areaWidget *area;
|
areaWidget *area;
|
||||||
|
|
||||||
GdkGLContext *glContext;
|
gboolean opengl;
|
||||||
|
uiGLContext *glContext;
|
||||||
|
|
||||||
int bgR, bgG, bgB;
|
int bgR, bgG, bgB;
|
||||||
|
|
||||||
|
@ -125,6 +128,8 @@ static void loadAreaSize(uiArea *a, double *width, double *height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void areaDrawGL(GtkWidget* widget, uiAreaDrawParams* dp, cairo_t* cr, uiGLContext* glctx);
|
||||||
|
|
||||||
static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||||
{
|
{
|
||||||
areaWidget *aw = areaWidget(w);
|
areaWidget *aw = areaWidget(w);
|
||||||
|
@ -136,20 +141,27 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||||
|
|
||||||
loadAreaSize(a, &(dp.AreaWidth), &(dp.AreaHeight));
|
loadAreaSize(a, &(dp.AreaWidth), &(dp.AreaHeight));
|
||||||
|
|
||||||
cairo_clip_extents(cr, &clipX0, &clipY0, &clipX1, &clipY1);
|
if (!a->opengl)
|
||||||
dp.ClipX = clipX0;
|
{
|
||||||
dp.ClipY = clipY0;
|
cairo_clip_extents(cr, &clipX0, &clipY0, &clipX1, &clipY1);
|
||||||
dp.ClipWidth = clipX1 - clipX0;
|
dp.ClipX = clipX0;
|
||||||
dp.ClipHeight = clipY1 - clipY0;
|
dp.ClipY = clipY0;
|
||||||
|
dp.ClipWidth = clipX1 - clipX0;
|
||||||
|
dp.ClipHeight = clipY1 - clipY0;
|
||||||
|
|
||||||
if (a->bgR != -1)
|
if (a->bgR != -1)
|
||||||
{
|
{
|
||||||
cairo_set_source_rgb(cr, a->bgR/255.0, a->bgG/255.0, a->bgB/255.0);
|
cairo_set_source_rgb(cr, a->bgR/255.0, a->bgG/255.0, a->bgB/255.0);
|
||||||
cairo_paint(cr);
|
cairo_paint(cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need to save or restore the graphics state to reset transformations; GTK+ does that for us
|
||||||
|
(*(a->ah->Draw))(a->ah, a, &dp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
areaDrawGL(w, &dp, cr, a->glContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to save or restore the graphics state to reset transformations; GTK+ does that for us
|
|
||||||
(*(a->ah->Draw))(a->ah, a, &dp);
|
|
||||||
|
|
||||||
freeContext(dp.Context);
|
freeContext(dp.Context);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -714,11 +726,12 @@ void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
||||||
uiArea *uiNewArea(uiAreaHandler *ah)
|
uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
{
|
{
|
||||||
uiArea *a;
|
uiArea *a;
|
||||||
|
printf("create regular area\n");
|
||||||
uiUnixNewControl(uiArea, a);
|
uiUnixNewControl(uiArea, a);
|
||||||
|
|
||||||
a->ah = ah;
|
a->ah = ah;
|
||||||
a->scrolling = FALSE;
|
a->scrolling = FALSE;
|
||||||
|
a->opengl = FALSE;
|
||||||
|
|
||||||
a->areaWidget = GTK_WIDGET(g_object_new(areaWidgetType,
|
a->areaWidget = GTK_WIDGET(g_object_new(areaWidgetType,
|
||||||
"libui-area", a,
|
"libui-area", a,
|
||||||
|
@ -733,35 +746,54 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiGLContext* FARTOMATIC(int major, int minor);
|
||||||
|
void databotte(GtkWidget* gla, uiGLContext* ctx);
|
||||||
|
void majoricc(GtkWidget* widget, gpointer data)
|
||||||
|
{
|
||||||
|
printf("ACTUALLY CREATE CONTEXT\n");
|
||||||
|
|
||||||
|
uiArea* a = (uiArea*)data;
|
||||||
|
uiGLContext* ctx = a->glContext;
|
||||||
|
|
||||||
|
databotte(a->widget, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
uiArea *uiNewGLArea(uiAreaHandler *ah, const unsigned int* req_versions)
|
uiArea *uiNewGLArea(uiAreaHandler *ah, const unsigned int* req_versions)
|
||||||
{
|
{
|
||||||
uiArea *a;
|
uiArea *a;
|
||||||
|
printf("create glarea\n");
|
||||||
uiUnixNewControl(uiArea, a);
|
uiUnixNewControl(uiArea, a);
|
||||||
|
|
||||||
a->ah = ah;
|
a->ah = ah;
|
||||||
a->scrolling = FALSE;
|
a->scrolling = FALSE;
|
||||||
|
a->opengl = TRUE;
|
||||||
|
|
||||||
GtkGLArea* gla = (GtkGLArea*)gtk_gl_area_new();
|
//GtkGLArea* gla = (GtkGLArea*)gtk_gl_area_new();
|
||||||
GdkGLContext* ctx = NULL;
|
uiGLContext* ctx = NULL;
|
||||||
|
printf("create sdfsf\n");
|
||||||
for (int i = 0; req_versions[i] && !ctx; i++) {
|
for (int i = 0; req_versions[i] && !ctx; i++) {
|
||||||
int major = uiGLVerMajor(req_versions[i]);
|
int major = uiGLVerMajor(req_versions[i]);
|
||||||
int minor = uiGLVerMinor(req_versions[i]);
|
int minor = uiGLVerMinor(req_versions[i]);
|
||||||
gtk_gl_area_set_required_version(gla, major, minor);
|
//gtk_gl_area_set_required_version(gla, major, minor);
|
||||||
ctx = createGLContext(gla, major, minor);
|
//ctx = createGLContext(gla, major, minor);
|
||||||
|
ctx = FARTOMATIC(major, minor);
|
||||||
}
|
}
|
||||||
|
printf("create jfghjjgh: %p\n", ctx);
|
||||||
a->glContext = ctx;
|
a->glContext = ctx;
|
||||||
a->areaWidget = GTK_WIDGET(g_object_new(areaWidgetType, "libui-area",
|
//a->areaWidget = GTK_WIDGET(gla);
|
||||||
a, NULL));
|
//a->glArea = gla;
|
||||||
a->glArea = gla;
|
a->areaWidget = GTK_WIDGET(g_object_new(areaWidgetType,
|
||||||
|
"libui-area", a,
|
||||||
|
NULL));
|
||||||
a->area = areaWidget(a->areaWidget);
|
a->area = areaWidget(a->areaWidget);
|
||||||
|
|
||||||
a->widget = a->areaWidget;
|
a->widget = a->areaWidget;
|
||||||
|
|
||||||
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
g_signal_connect(a->widget, "realize", G_CALLBACK(majoricc), a);
|
||||||
|
|
||||||
|
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
||||||
|
//printf("is area realized: %d\n", gtk_widget_get_realized(GTK_WIDGET(gla)));
|
||||||
|
printf("create qssssq\n");
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,6 +813,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
||||||
a->scrolling = TRUE;
|
a->scrolling = TRUE;
|
||||||
a->scrollWidth = width;
|
a->scrollWidth = width;
|
||||||
a->scrollHeight = height;
|
a->scrollHeight = height;
|
||||||
|
a->opengl = FALSE;
|
||||||
|
|
||||||
a->swidget = gtk_scrolled_window_new(NULL, NULL);
|
a->swidget = gtk_scrolled_window_new(NULL, NULL);
|
||||||
a->scontainer = GTK_CONTAINER(a->swidget);
|
a->scontainer = GTK_CONTAINER(a->swidget);
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
// 26 may 2019
|
// 26 may 2019
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glx.h>
|
||||||
|
|
||||||
|
extern GThread* gtkthread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*(melonDS:17013): Gtk-CRITICAL **: 00:28:09.095: gtk_gl_area_set_required_version: assertion 'GTK_IS_GL_AREA (area)' failed
|
*(melonDS:17013): Gtk-CRITICAL **: 00:28:09.095: gtk_gl_area_set_required_version: assertion 'GTK_IS_GL_AREA (area)' failed
|
||||||
|
|
||||||
|
@ -9,32 +15,409 @@
|
||||||
|
|
||||||
struct uiGLContext {
|
struct uiGLContext {
|
||||||
GtkGLArea *gla;
|
GtkGLArea *gla;
|
||||||
|
GtkWidget* widget;
|
||||||
|
GdkWindow* window;
|
||||||
GdkGLContext *gctx;
|
GdkGLContext *gctx;
|
||||||
|
|
||||||
|
Display* xdisp;
|
||||||
|
GLXPixmap glxpm;
|
||||||
|
GLXContext glxctx;
|
||||||
int vermaj, vermin;
|
int vermaj, vermin;
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
int scale;
|
||||||
|
GLuint renderbuffer[2];
|
||||||
|
GLuint framebuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static PFNGLGENRENDERBUFFERSPROC _glGenRenderbuffers;
|
||||||
|
static PFNGLDELETERENDERBUFFERSPROC _glDeleteRenderbuffers;
|
||||||
|
static PFNGLBINDRENDERBUFFERPROC _glBindRenderbuffer;
|
||||||
|
static PFNGLRENDERBUFFERSTORAGEPROC _glRenderbufferStorage;
|
||||||
|
static PFNGLGETRENDERBUFFERPARAMETERIVPROC _glGetRenderbufferParameteriv;
|
||||||
|
|
||||||
|
static PFNGLGENRENDERBUFFERSPROC _glGenFramebuffers;
|
||||||
|
static PFNGLDELETERENDERBUFFERSPROC _glDeleteFramebuffers;
|
||||||
|
static PFNGLBINDRENDERBUFFERPROC _glBindFramebuffer;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTUREPROC _glFramebufferTexture;
|
||||||
|
static PFNGLFRAMEBUFFERRENDERBUFFERPROC _glFramebufferRenderbuffer;
|
||||||
|
static PFNGLCHECKFRAMEBUFFERSTATUSPROC _glCheckFramebufferStatus;
|
||||||
|
|
||||||
|
static int _procsLoaded = 0;
|
||||||
|
|
||||||
|
static void _loadGLProcs()
|
||||||
|
{
|
||||||
|
if (_procsLoaded) return;
|
||||||
|
|
||||||
|
_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)uiGLGetProcAddress("glGenRenderbuffers");
|
||||||
|
_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)uiGLGetProcAddress("glDeleteRenderbuffers");
|
||||||
|
_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)uiGLGetProcAddress("glBindRenderbuffer");
|
||||||
|
_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)uiGLGetProcAddress("glRenderbufferStorage");
|
||||||
|
_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)uiGLGetProcAddress("glGetRenderbufferParameteriv");
|
||||||
|
|
||||||
|
_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)uiGLGetProcAddress("glGenFramebuffers");
|
||||||
|
_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)uiGLGetProcAddress("glDeleteFramebuffers");
|
||||||
|
_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)uiGLGetProcAddress("glBindFramebuffer");
|
||||||
|
_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)uiGLGetProcAddress("glFramebufferTexture");
|
||||||
|
_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)uiGLGetProcAddress("glFramebufferRenderbuffer");
|
||||||
|
_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)uiGLGetProcAddress("glCheckFramebufferStatus");
|
||||||
|
|
||||||
|
_procsLoaded = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Display* derp;
|
||||||
|
|
||||||
uiGLContext *createGLContext(GtkGLArea* gla, int maj, int min)
|
uiGLContext *createGLContext(GtkGLArea* gla, int maj, int min)
|
||||||
{
|
{
|
||||||
uiGLContext *ret = uiAlloc(sizeof(uiGLContext), "uiGLContext");
|
printf("barp\n");
|
||||||
|
uiGLContext *ret = uiNew(uiGLContext);//uiAlloc(sizeof(uiGLContext), "uiGLContext");
|
||||||
|
|
||||||
|
// herp
|
||||||
|
ret->gla = gla;
|
||||||
|
ret->gctx = NULL;
|
||||||
|
//while (!ret->gctx)
|
||||||
|
/*{
|
||||||
|
gtk_widget_realize(GTK_WIDGET(gla));
|
||||||
|
printf("is area realized: %d\n", gtk_widget_get_realized(GTK_WIDGET(gla)));
|
||||||
ret->gla = gla;
|
ret->gla = gla;
|
||||||
ret->gctx = gtk_gl_area_get_context(gla);
|
ret->gctx = gtk_gl_area_get_context(gla);
|
||||||
|
printf("context: %p\n", ret->gctx);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
GtkAllocation allocation;
|
||||||
|
GdkWindow *window;
|
||||||
|
Display *display;
|
||||||
|
int id;
|
||||||
|
|
||||||
|
window = gtk_widget_get_window(widget);
|
||||||
|
display = gdk_x11_display_get_xdisplay(gdk_window_get_display(window));
|
||||||
|
id = gdk_x11_window_get_xid(window);
|
||||||
|
|
||||||
|
if (glXMakeCurrent(display, id, context) == TRUE) {*/
|
||||||
|
|
||||||
|
|
||||||
|
/*GdkWindow* window;
|
||||||
|
Display* disp;
|
||||||
|
|
||||||
|
window = gtk_widget_get_window(GTK_WIDGET(gla));
|
||||||
|
display = */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ret->vermaj = maj; ret->vermin = min;
|
ret->vermaj = maj; ret->vermin = min;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void areaAllocRenderbuffer(uiGLContext* glctx);
|
||||||
|
|
||||||
|
void databotte(GtkWidget* widget, uiGLContext* ctx)
|
||||||
|
{
|
||||||
|
/*printf("is area realized: %d\n", gtk_widget_get_realized(GTK_WIDGET(gla)));
|
||||||
|
ctx->gctx = gtk_gl_area_get_context(gla);
|
||||||
|
printf("context: %p\n", ctx->gctx);*/
|
||||||
|
|
||||||
|
printf("DATABOTTE\n");
|
||||||
|
|
||||||
|
GdkWindow* gdkwin = gtk_widget_get_window(widget);
|
||||||
|
printf("window=%p\n", gdkwin);
|
||||||
|
|
||||||
|
GError* err = NULL;
|
||||||
|
GdkGLContext* glctx = gdk_window_create_gl_context(gdkwin, &err);
|
||||||
|
if (err != NULL)
|
||||||
|
{
|
||||||
|
printf("CONTEXT SHAT ITSELF\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_gl_context_set_use_es(glctx, FALSE);
|
||||||
|
gdk_gl_context_set_required_version(glctx, 3, 2);
|
||||||
|
|
||||||
|
gdk_gl_context_realize(glctx, &err);
|
||||||
|
if (err != NULL)
|
||||||
|
{
|
||||||
|
printf("CONTEXT REALIZE SHAT ITSELF\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkAllocation allocation;
|
||||||
|
gtk_widget_get_allocation(widget, &allocation);
|
||||||
|
int window_scale = gdk_window_get_scale_factor(gdkwin);
|
||||||
|
ctx->width = allocation.width;
|
||||||
|
ctx->height = allocation.height;
|
||||||
|
ctx->scale = window_scale;
|
||||||
|
|
||||||
|
gdk_gl_context_make_current(glctx);
|
||||||
|
_loadGLProcs();
|
||||||
|
areaAllocRenderbuffer(ctx);
|
||||||
|
|
||||||
|
ctx->widget = widget;
|
||||||
|
ctx->window = gdkwin;
|
||||||
|
ctx->gctx = glctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void areaAllocRenderbuffer(uiGLContext* glctx)
|
||||||
|
{
|
||||||
|
_glGenRenderbuffers(2, &glctx->renderbuffer[0]);printf("ylarg0 %04X, %d %d\n", glGetError(), glctx->width, glctx->height);
|
||||||
|
//glGenTextures(2, &glctx->renderbuffer[0]);
|
||||||
|
_glGenFramebuffers(1, &glctx->framebuffer);printf("ylarg1 %04X\n", glGetError());
|
||||||
|
printf("FB %08X created under ctx %p (%p %p)\n", glctx?glctx->framebuffer:0, gdk_gl_context_get_current(), glctx?glctx->gctx:NULL, glctx);
|
||||||
|
/*glBindTexture(GL_TEXTURE_2D, glctx->renderbuffer[0]);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, glctx->renderbuffer[1]);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);*/
|
||||||
|
|
||||||
|
_glBindRenderbuffer(GL_RENDERBUFFER, glctx->renderbuffer[0]);printf("ylarg1 %04X\n", glGetError());
|
||||||
|
_glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, glctx->width*glctx->scale, glctx->height*glctx->scale);printf("ylarg1 %04X\n", glGetError());
|
||||||
|
_glBindRenderbuffer(GL_RENDERBUFFER, glctx->renderbuffer[1]);printf("ylarg1 %04X\n", glGetError());
|
||||||
|
_glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, glctx->width*glctx->scale, glctx->height*glctx->scale);printf("ylarg1 %04X\n", glGetError());
|
||||||
|
|
||||||
|
_glBindFramebuffer(GL_FRAMEBUFFER, glctx->framebuffer);printf("ylarg2 %04X\n", glGetError());
|
||||||
|
/*_glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glctx->renderbuffer[0], 0);
|
||||||
|
_glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, glctx->renderbuffer[1], 0);*/
|
||||||
|
_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, glctx->renderbuffer[0]);printf("ylarg3 %04X\n", glGetError());
|
||||||
|
_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, glctx->renderbuffer[1]);printf("ylarg4 %04X\n", glGetError());
|
||||||
|
//printf("ylarg: %08X, %04X, %08X %08X\n", glctx->framebuffer, glGetError(), glctx->renderbuffer[0], glctx->renderbuffer[1]);
|
||||||
|
|
||||||
|
if(_glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
printf("FRAMEBUFFER IS BAD!! %04X\n", _glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||||
|
|
||||||
|
int alpha_size;
|
||||||
|
_glBindRenderbuffer(GL_RENDERBUFFER, glctx->renderbuffer[0]);
|
||||||
|
_glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
|
||||||
|
printf("FRAMEBUFFER GOOD. ALPHA SIZE IS %d\n", alpha_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void areaRellocRenderbuffer(uiGLContext* glctx)
|
||||||
|
{
|
||||||
|
_glBindRenderbuffer(GL_RENDERBUFFER, glctx->renderbuffer[0]);
|
||||||
|
_glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, glctx->width*glctx->scale, glctx->height*glctx->scale);
|
||||||
|
_glBindRenderbuffer(GL_RENDERBUFFER, glctx->renderbuffer[1]);
|
||||||
|
_glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, glctx->width*glctx->scale, glctx->height*glctx->scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void areaDrawGL(GtkWidget* widget, uiAreaDrawParams* dp, cairo_t* cr, uiGLContext* glctx)
|
||||||
|
{
|
||||||
|
int window_scale = gdk_window_get_scale_factor(glctx->window);
|
||||||
|
|
||||||
|
if (glctx->width != dp->AreaWidth || glctx->height != dp->AreaHeight || glctx->scale != window_scale)
|
||||||
|
{
|
||||||
|
glctx->width = dp->AreaWidth;
|
||||||
|
glctx->height = dp->AreaHeight;
|
||||||
|
glctx->scale = window_scale;
|
||||||
|
areaRellocRenderbuffer(glctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(widget),
|
||||||
|
glctx->renderbuffer[0], GL_RENDERBUFFER,
|
||||||
|
1, 0, 0, glctx->width*glctx->scale, glctx->height*glctx->scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiGLContext* FARTOMATIC(int major, int minor)
|
||||||
|
{
|
||||||
|
uiGLContext *_ret = uiNew(uiGLContext);
|
||||||
|
_ret->vermaj = major;
|
||||||
|
_ret->vermin = minor;
|
||||||
|
_ret->width = -1;
|
||||||
|
_ret->height = -1;
|
||||||
|
_ret->renderbuffer[0] = 0;
|
||||||
|
_ret->renderbuffer[1] = 0;
|
||||||
|
_ret->framebuffer = 0;
|
||||||
|
|
||||||
|
return _ret;
|
||||||
|
|
||||||
|
Display* disp;
|
||||||
|
XVisualInfo* vizir;
|
||||||
|
GLXFBConfig *cfg;
|
||||||
|
Pixmap pm;
|
||||||
|
GLXPixmap glxpm;
|
||||||
|
GLXContext ctx;
|
||||||
|
|
||||||
|
disp = XOpenDisplay(NULL);
|
||||||
|
derp = disp;
|
||||||
|
|
||||||
|
int kaa, baa;
|
||||||
|
glXQueryVersion(disp, &kaa, &baa);
|
||||||
|
printf("GL VERSION: %d.%d\n", kaa, baa);
|
||||||
|
|
||||||
|
const int sbAttrib[] = { GLX_RGBA,
|
||||||
|
GLX_RED_SIZE, 1,
|
||||||
|
GLX_GREEN_SIZE, 1,
|
||||||
|
GLX_BLUE_SIZE, 1,
|
||||||
|
None };
|
||||||
|
const int dbAttrib[] = { GLX_RGBA,
|
||||||
|
GLX_RED_SIZE, 1,
|
||||||
|
GLX_GREEN_SIZE, 1,
|
||||||
|
GLX_BLUE_SIZE, 1,
|
||||||
|
GLX_DOUBLEBUFFER,
|
||||||
|
None };
|
||||||
|
|
||||||
|
int scrnum = DefaultScreen( disp );
|
||||||
|
Window root = RootWindow( disp, scrnum );
|
||||||
|
|
||||||
|
vizir = glXChooseVisual( disp, scrnum, (int *) sbAttrib );
|
||||||
|
if (!vizir) {
|
||||||
|
vizir = glXChooseVisual( disp, scrnum, (int *) dbAttrib );
|
||||||
|
if (!vizir) {
|
||||||
|
printf("Error: couldn't get an RGB visual\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int fb_attr[] = {
|
||||||
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||||
|
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
|
||||||
|
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
|
||||||
|
GLX_DOUBLEBUFFER, True,
|
||||||
|
GLX_X_RENDERABLE, True,
|
||||||
|
GLX_RED_SIZE, 8,
|
||||||
|
GLX_GREEN_SIZE, 8,
|
||||||
|
GLX_BLUE_SIZE, 8,
|
||||||
|
GLX_ALPHA_SIZE, 8,
|
||||||
|
GLX_DEPTH_SIZE, 24,
|
||||||
|
GLX_STENCIL_SIZE, 8,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
int configs;
|
||||||
|
cfg = glXChooseFBConfig(disp, scrnum, (int *)&fb_attr, &configs);
|
||||||
|
|
||||||
|
if (!cfg)
|
||||||
|
{
|
||||||
|
printf("NO GOOD FBCONFIG\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*ctx = glXCreateContext( disp, vizir, NULL, True );
|
||||||
|
if (!ctx)
|
||||||
|
{
|
||||||
|
printf("Error: glXCreateContext failed\n");
|
||||||
|
return NULL;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
PFNGLXCREATECONTEXTATTRIBSARBPROC createctx;
|
||||||
|
createctx = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB("glXCreateContextAttribsARB");
|
||||||
|
if (!createctx)
|
||||||
|
{
|
||||||
|
printf("bad shito\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int ctx_attr[] =
|
||||||
|
{
|
||||||
|
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||||
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,//major,
|
||||||
|
GLX_CONTEXT_MINOR_VERSION_ARB, 2,//minor,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx = glXCreateContextAttribsARB(disp, cfg[0], 0, True, ctx_attr);
|
||||||
|
if (!ctx)
|
||||||
|
{
|
||||||
|
printf("FAILED TO CREATE FANCYPANTS GL CONTEXT\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("CONTEXT GOOD. Direct rendering: %s\n", glXIsDirect(disp, ctx) ? "Yes" : "No");
|
||||||
|
|
||||||
|
printf("blorp: %d\n", vizir->depth);
|
||||||
|
pm = XCreatePixmap(disp, root, 256, 384, vizir->depth);
|
||||||
|
if (!pm) printf("PIXMAP SHAT ITSELF\n");
|
||||||
|
else printf("PIXMAP GOOD\n");
|
||||||
|
|
||||||
|
glxpm = glXCreateGLXPixmap(disp, vizir, pm);
|
||||||
|
if (!glxpm) printf("GLXPIXMAP SHAT ITSELF\n");
|
||||||
|
else printf("GLXPIXMAP GOOD\n");
|
||||||
|
|
||||||
|
uiGLContext *ret = uiNew(uiGLContext);
|
||||||
|
printf("CREATE CTX: %p, %p\n", ret, g_thread_self());
|
||||||
|
ret->xdisp = disp;
|
||||||
|
ret->glxpm = glxpm;
|
||||||
|
ret->glxctx = ctx;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int uiGLGetFramebuffer(uiGLContext* ctx)
|
||||||
|
{
|
||||||
|
return ctx->framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
float uiGLGetFramebufferScale(uiGLContext* ctx)
|
||||||
|
{
|
||||||
|
return (float)ctx->scale;
|
||||||
|
}
|
||||||
|
|
||||||
void uiGLSwapBuffers(uiGLContext* ctx)
|
void uiGLSwapBuffers(uiGLContext* ctx)
|
||||||
{
|
{
|
||||||
if (!ctx) return;
|
if (!ctx) return;
|
||||||
gtk_gl_area_attach_buffers(ctx->gla);
|
//gtk_gl_area_attach_buffers(ctx->gla);
|
||||||
|
}
|
||||||
|
|
||||||
|
static volatile int _ctxset_done;
|
||||||
|
|
||||||
|
gboolean _threadsafe_ctxset(gpointer data)
|
||||||
|
{
|
||||||
|
uiGLContext* ctx = (uiGLContext*)data;
|
||||||
|
gtk_gl_area_make_current(ctx->gla);
|
||||||
|
_ctxset_done = 1;
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiGLMakeContextCurrent(uiGLContext* ctx)
|
void uiGLMakeContextCurrent(uiGLContext* ctx)
|
||||||
{
|
{
|
||||||
if (!ctx) return;
|
//if (!ctx) return;
|
||||||
gtk_gl_area_make_current(ctx->gla);
|
/*if (g_thread_self() != gtkthread)
|
||||||
|
{
|
||||||
|
_ctxset_done = 0;
|
||||||
|
g_idle_add(_threadsafe_ctxset, ctx);
|
||||||
|
while (!_ctxset_done);
|
||||||
|
}
|
||||||
|
else*/
|
||||||
|
//gtk_gl_area_make_current(ctx->gla);
|
||||||
|
/*printf("MAKE CONTEXT CURRENT %p, %p\n", ctx, g_thread_self());
|
||||||
|
if (!ctx)
|
||||||
|
{
|
||||||
|
// BLERUGEHZFZF
|
||||||
|
glXMakeCurrent(derp, None, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bool ret = True;
|
||||||
|
if (glXGetCurrentContext() != ctx->glxctx)
|
||||||
|
{printf("DZJSKFLD\n");
|
||||||
|
ret = glXMakeCurrent(ctx->xdisp, ctx->glxpm, ctx->glxctx);
|
||||||
|
//glXMakeContextCurrent(ctx->xdisp, ctx->glxpm, ctx->glxpm, ctx->glxctx);
|
||||||
|
}
|
||||||
|
printf("WE MAED IT CURRENT: %d\n", ret);*/
|
||||||
|
|
||||||
|
printf("[%p] MAKE CONTEXT CURRENT %p, %p\n", g_thread_self(), ctx, ctx?ctx->gctx:NULL);
|
||||||
|
if (!ctx)
|
||||||
|
{
|
||||||
|
gdk_gl_context_clear_current();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//gtk_gl_area_make_current(ctx->gla);
|
||||||
|
gdk_gl_context_make_current(ctx->gctx);
|
||||||
|
GdkGLContext* burp = gdk_gl_context_get_current();
|
||||||
|
//gtk_gl_area_attach_buffers(ctx->gla);
|
||||||
|
//printf("burp = %p / %p\n", burp, ctx->gctx);
|
||||||
}
|
}
|
||||||
void *uiGLGetProcAddress(const char* proc)
|
void *uiGLGetProcAddress(const char* proc)
|
||||||
{
|
{
|
||||||
|
printf("get: %s - ", proc);
|
||||||
|
void* a = dlsym(NULL, proc);
|
||||||
|
void* b = glXGetProcAddress(proc);
|
||||||
|
void* c = glXGetProcAddressARB(proc);
|
||||||
|
printf("%p / %p / %p\n", a, b, c);
|
||||||
|
return c;
|
||||||
// this *will* break for older systems that don't have libglvnd!
|
// this *will* break for older systems that don't have libglvnd!
|
||||||
// TODO: use a real solution
|
// TODO: use a real solution
|
||||||
return dlsym(NULL /* RTLD_DEFAULT */, proc);
|
return dlsym(NULL /* RTLD_DEFAULT */, proc);
|
||||||
|
|
|
@ -194,17 +194,24 @@ bool GLScreen_InitShader(GLuint* shader, const char* fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLScreen_Init()
|
bool GLScreen_Init()
|
||||||
{
|
{printf("BEGINNING GL SHITO\n");
|
||||||
if (!OpenGL_Init())
|
if (!OpenGL_Init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
printf("GL INIT: %p, %p\n", glGenFramebuffers, glCreateShader);
|
||||||
|
|
||||||
|
const GLubyte* renderer = glGetString(GL_RENDERER); // get renderer string
|
||||||
|
const GLubyte* version = glGetString(GL_VERSION); // version as a string
|
||||||
|
printf("OpenGL: renderer: %s\n", renderer);
|
||||||
|
printf("OpenGL: version: %s\n", version);
|
||||||
|
|
||||||
if (!GLScreen_InitShader(GL_ScreenShader, kScreenFS))
|
if (!GLScreen_InitShader(GL_ScreenShader, kScreenFS))
|
||||||
return false;
|
return false;
|
||||||
if (!GLScreen_InitShader(GL_ScreenShaderAccel, kScreenFS_Accel))
|
if (!GLScreen_InitShader(GL_ScreenShaderAccel, kScreenFS_Accel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(&GL_ShaderConfig, 0, sizeof(GL_ShaderConfig));
|
memset(&GL_ShaderConfig, 0, sizeof(GL_ShaderConfig));
|
||||||
|
printf("morp0\n");
|
||||||
glGenBuffers(1, &GL_ShaderConfigUBO);
|
glGenBuffers(1, &GL_ShaderConfigUBO);
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, GL_ShaderConfigUBO);
|
glBindBuffer(GL_UNIFORM_BUFFER, GL_ShaderConfigUBO);
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(GL_ShaderConfig), &GL_ShaderConfig, GL_STATIC_DRAW);
|
glBufferData(GL_UNIFORM_BUFFER, sizeof(GL_ShaderConfig), &GL_ShaderConfig, GL_STATIC_DRAW);
|
||||||
|
@ -213,14 +220,14 @@ bool GLScreen_Init()
|
||||||
glGenBuffers(1, &GL_ScreenVertexBufferID);
|
glGenBuffers(1, &GL_ScreenVertexBufferID);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(GL_ScreenVertices), NULL, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(GL_ScreenVertices), NULL, GL_STATIC_DRAW);
|
||||||
|
printf("morp1\n");
|
||||||
glGenVertexArrays(1, &GL_ScreenVertexArrayID);
|
glGenVertexArrays(1, &GL_ScreenVertexArrayID);
|
||||||
glBindVertexArray(GL_ScreenVertexArrayID);
|
glBindVertexArray(GL_ScreenVertexArrayID);
|
||||||
glEnableVertexAttribArray(0); // position
|
glEnableVertexAttribArray(0); // position
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(0));
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(0));
|
||||||
glEnableVertexAttribArray(1); // texcoord
|
glEnableVertexAttribArray(1); // texcoord
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(2*4));
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(2*4));
|
||||||
|
printf("morp2\n");
|
||||||
glGenTextures(1, &GL_ScreenTexture);
|
glGenTextures(1, &GL_ScreenTexture);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, GL_ScreenTexture);
|
glBindTexture(GL_TEXTURE_2D, GL_ScreenTexture);
|
||||||
|
@ -231,7 +238,7 @@ bool GLScreen_Init()
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, 256*3 + 1, 192*2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, 256*3 + 1, 192*2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
GL_ScreenSizeDirty = true;
|
GL_ScreenSizeDirty = true;
|
||||||
|
printf("morp3\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +255,8 @@ void GLScreen_DeInit()
|
||||||
|
|
||||||
void GLScreen_DrawScreen()
|
void GLScreen_DrawScreen()
|
||||||
{
|
{
|
||||||
|
float scale = uiGLGetFramebufferScale(GLContext);
|
||||||
|
|
||||||
if (GL_ScreenSizeDirty)
|
if (GL_ScreenSizeDirty)
|
||||||
{
|
{
|
||||||
GL_ScreenSizeDirty = false;
|
GL_ScreenSizeDirty = false;
|
||||||
|
@ -370,23 +379,26 @@ void GLScreen_DrawScreen()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GL_ScreenVertices), GL_ScreenVertices);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GL_ScreenVertices), GL_ScreenVertices);
|
||||||
}
|
}
|
||||||
|
printf("rarp4 %04X\n", glGetError());
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
printf("rarp2 %04X\n", glGetError());
|
||||||
|
|
||||||
glViewport(0, 0, WindowWidth, WindowHeight);
|
glViewport(0, 0, WindowWidth*scale, WindowHeight*scale);
|
||||||
|
printf("draw screen: viewport=%d/%d\n", WindowWidth, WindowHeight);
|
||||||
|
|
||||||
if (GPU3D::Renderer == 0)
|
if (GPU3D::Renderer == 0)
|
||||||
OpenGL_UseShaderProgram(GL_ScreenShader);
|
OpenGL_UseShaderProgram(GL_ScreenShader);
|
||||||
else
|
else
|
||||||
OpenGL_UseShaderProgram(GL_ScreenShaderAccel);
|
OpenGL_UseShaderProgram(GL_ScreenShaderAccel);
|
||||||
|
printf("rarp3 %04X\n", glGetError());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, uiGLGetFramebuffer(GLContext));
|
||||||
glClearColor(0, 0, 0, 1);
|
printf("rarp8 %04X\n", glGetError());
|
||||||
|
glClearColor(0, 0, 1, 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
printf("rarp5 %04X\n", glGetError());
|
||||||
int frontbuf = GPU::FrontBuffer;
|
int frontbuf = GPU::FrontBuffer;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, GL_ScreenTexture);
|
glBindTexture(GL_TEXTURE_2D, GL_ScreenTexture);
|
||||||
|
@ -412,15 +424,21 @@ void GLScreen_DrawScreen()
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if (GPU3D::Renderer != 0)
|
if (GPU3D::Renderer != 0)
|
||||||
GPU3D::GLRenderer::SetupAccelFrame();
|
GPU3D::GLRenderer::SetupAccelFrame();
|
||||||
|
printf("rarp6 %04X\n", glGetError());
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID);
|
||||||
glBindVertexArray(GL_ScreenVertexArrayID);
|
glBindVertexArray(GL_ScreenVertexArrayID);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 4*3);
|
glDrawArrays(GL_TRIANGLES, 0, 4*3);
|
||||||
|
printf("rarp7 %04X\n", glGetError());
|
||||||
glFlush();
|
glFlush();
|
||||||
uiGLSwapBuffers(GLContext);
|
uiGLSwapBuffers(GLContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void norp(void* data)
|
||||||
|
{
|
||||||
|
uiGLMakeContextCurrent(GLContext);
|
||||||
|
GLScreen_DrawScreen();
|
||||||
|
}
|
||||||
|
|
||||||
void MicLoadWav(char* name)
|
void MicLoadWav(char* name)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec format;
|
SDL_AudioSpec format;
|
||||||
|
@ -901,6 +919,8 @@ int EmuThreadFunc(void* burp)
|
||||||
{
|
{
|
||||||
uiGLMakeContextCurrent(GLContext);
|
uiGLMakeContextCurrent(GLContext);
|
||||||
GLScreen_DrawScreen();
|
GLScreen_DrawScreen();
|
||||||
|
//uiGLMakeContextCurrent(NULL);
|
||||||
|
//uiQueueMain(norp, NULL);
|
||||||
}
|
}
|
||||||
uiAreaQueueRedrawAll(MainDrawArea);
|
uiAreaQueueRedrawAll(MainDrawArea);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue