Linux Port (GTK-Glade): Fix screen drawing for GTK-GL. (Regression from commit f5c9a36.)
This commit is contained in:
parent
43e740c661
commit
8be15113e2
|
@ -185,12 +185,13 @@ gboolean screen (GtkWidget * widget, int off) {
|
||||||
|
|
||||||
/* OUTPUT SCREENS */
|
/* OUTPUT SCREENS */
|
||||||
gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
|
gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
|
||||||
int scr = dyn_CAST(int,user_data);
|
NDSDisplayID displayID = (NDSDisplayID)dyn_CAST(int,user_data);
|
||||||
return screen(widget, scr);
|
return screen(widget, displayID);
|
||||||
}
|
}
|
||||||
gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) {
|
gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) {
|
||||||
int scr = dyn_CAST(int,user_data);
|
NDSDisplayID displayID = (NDSDisplayID)dyn_CAST(int,user_data);
|
||||||
reshape(widget, scr); return TRUE;
|
reshape(widget, displayID);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ static int colnum=0;
|
||||||
static void refresh();
|
static void refresh();
|
||||||
static GtkWidget * wPaint;
|
static GtkWidget * wPaint;
|
||||||
static GtkSpinButton * wSpin;
|
static GtkSpinButton * wSpin;
|
||||||
static int gl_context_num=0;
|
static NDSDisplayID gl_context_num = NDSDisplayID_Main;
|
||||||
|
|
||||||
#define TILE_NUM_MAX 1024
|
#define TILE_NUM_MAX 1024
|
||||||
#define TILE_W_SZ 8
|
#define TILE_W_SZ 8
|
||||||
|
@ -270,7 +270,7 @@ static void initialize() {
|
||||||
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory");
|
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory");
|
||||||
init_combo_memory(combo, mem_addr);
|
init_combo_memory(combo, mem_addr);
|
||||||
|
|
||||||
gl_context_num = init_GL_free_s(wPaint,0);
|
gl_context_num = init_GL_free_s(wPaint, NDSDisplayID_Main);
|
||||||
reshape(wPaint, gl_context_num);
|
reshape(wPaint, gl_context_num);
|
||||||
gtk_widget_show(wPaint);
|
gtk_widget_show(wPaint);
|
||||||
init=TRUE;
|
init=TRUE;
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
#include "../GPU.h"
|
|
||||||
|
|
||||||
#define _DUP8(a) a,a,a,a, a,a,a,a
|
#define _DUP8(a) a,a,a,a, a,a,a,a
|
||||||
#define _DUP4(a) a,a,a,a
|
#define _DUP4(a) a,a,a,a
|
||||||
#define _DUP2(a) a,a
|
#define _DUP2(a) a,a
|
||||||
|
@ -50,52 +48,58 @@ GLuint screen_texture[2];
|
||||||
/* BEGIN & END */
|
/* BEGIN & END */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
BOOL my_gl_Begin (int screen) {
|
BOOL my_gl_Begin (NDSDisplayID displayID)
|
||||||
return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext[screen]);
|
{
|
||||||
|
return gdk_gl_drawable_gl_begin(my_glDrawable[displayID], my_glContext[displayID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_gl_End (int screen) {
|
void my_gl_End (NDSDisplayID displayID)
|
||||||
if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen]))
|
{
|
||||||
gdk_gl_drawable_swap_buffers (my_glDrawable[screen]);
|
if (gdk_gl_drawable_is_double_buffered (my_glDrawable[displayID]))
|
||||||
|
gdk_gl_drawable_swap_buffers (my_glDrawable[displayID]);
|
||||||
else
|
else
|
||||||
glFlush();
|
glFlush();
|
||||||
gdk_gl_drawable_gl_end(my_glDrawable[screen]);
|
gdk_gl_drawable_gl_end(my_glDrawable[displayID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
/* OTHER GL COMMANDS */
|
/* OTHER GL COMMANDS */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
void my_gl_Identity() {
|
void my_gl_Identity()
|
||||||
|
{
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_gl_Clear(int screen) {
|
void my_gl_Clear(NDSDisplayID displayID)
|
||||||
if (!my_gl_Begin(screen)) return;
|
{
|
||||||
|
if (!my_gl_Begin(displayID))
|
||||||
|
return;
|
||||||
|
|
||||||
/* Set the background black */
|
/* Set the background black */
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
my_gl_End(screen);
|
my_gl_End(displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
/* INITIALIZATION */
|
/* INITIALIZATION */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
void init_GL(GtkWidget * widget, int screen, int share_num) {
|
void init_GL(GtkWidget *widget, NDSDisplayID displayID, NDSDisplayID sharedContextDisplayID)
|
||||||
|
{
|
||||||
// for (n=gtk_events_pending(); n>0; n--)
|
// for (n=gtk_events_pending(); n>0; n--)
|
||||||
// gtk_main_iteration();
|
// gtk_main_iteration();
|
||||||
// init GL capability
|
// init GL capability
|
||||||
my_glContext[screen]=NULL;
|
my_glContext[displayID] = NULL;
|
||||||
my_glDrawable[screen]=NULL;
|
my_glDrawable[displayID] = NULL;
|
||||||
if (!gtk_widget_set_gl_capability(
|
if (!gtk_widget_set_gl_capability(
|
||||||
widget, my_glConfig,
|
widget, my_glConfig,
|
||||||
my_glContext[share_num],
|
my_glContext[sharedContextDisplayID],
|
||||||
//NULL,
|
//NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
GDK_GL_RGBA_TYPE)) {
|
GDK_GL_RGBA_TYPE)) {
|
||||||
|
@ -107,29 +111,34 @@ void init_GL(GtkWidget * widget, int screen, int share_num) {
|
||||||
// make sure we realize
|
// make sure we realize
|
||||||
gdk_flush();
|
gdk_flush();
|
||||||
|
|
||||||
my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget);
|
my_glDrawable[displayID] = gtk_widget_get_gl_drawable(widget);
|
||||||
|
|
||||||
if (screen == share_num) {
|
if (displayID == sharedContextDisplayID)
|
||||||
my_glContext[screen] = gtk_widget_get_gl_context(widget);
|
{
|
||||||
} else {
|
my_glContext[displayID] = gtk_widget_get_gl_context(widget);
|
||||||
my_glContext[screen] = my_glContext[share_num];
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my_glContext[displayID] = my_glContext[sharedContextDisplayID];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reshape(widget, screen);
|
reshape(widget, displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_GL_free_s(GtkWidget * widget, int share_num) {
|
NDSDisplayID init_GL_free_s(GtkWidget *widget, NDSDisplayID sharedContextDisplayID)
|
||||||
int r = free_gl_drawable;
|
{
|
||||||
|
NDSDisplayID r = (NDSDisplayID)free_gl_drawable;
|
||||||
my_glContext[r] = NULL;
|
my_glContext[r] = NULL;
|
||||||
my_glDrawable[r] = NULL;
|
my_glDrawable[r] = NULL;
|
||||||
init_GL(widget, r, share_num);
|
init_GL(widget, r, sharedContextDisplayID);
|
||||||
free_gl_drawable++;
|
free_gl_drawable++;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_GL_free(GtkWidget * widget) {
|
NDSDisplayID init_GL_free(GtkWidget *widget)
|
||||||
int r = free_gl_drawable;
|
{
|
||||||
|
NDSDisplayID r = (NDSDisplayID)free_gl_drawable;
|
||||||
my_glContext[r] = NULL;
|
my_glContext[r] = NULL;
|
||||||
my_glDrawable[r] = NULL;
|
my_glDrawable[r] = NULL;
|
||||||
init_GL(widget, r, r);
|
init_GL(widget, r, r);
|
||||||
|
@ -149,10 +158,11 @@ void init_GL_capabilities() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// initialize 1st drawing area
|
// initialize 1st drawing area
|
||||||
init_GL(pDrawingArea,0,0);
|
init_GL(pDrawingArea, NDSDisplayID_Main, NDSDisplayID_Main);
|
||||||
my_gl_Clear(0);
|
my_gl_Clear(NDSDisplayID_Main);
|
||||||
|
|
||||||
if (!my_gl_Begin(0)) return;
|
if (!my_gl_Begin(NDSDisplayID_Main))
|
||||||
|
return;
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glGenTextures(2, screen_texture);
|
glGenTextures(2, screen_texture);
|
||||||
|
@ -176,25 +186,26 @@ void init_GL_capabilities() {
|
||||||
blank_texture);
|
blank_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_gl_End(0);
|
my_gl_End(NDSDisplayID_Main);
|
||||||
|
|
||||||
// initialize 2nd drawing area (sharing context)
|
// initialize 2nd drawing area (sharing context)
|
||||||
init_GL(pDrawingArea2,1,0);
|
init_GL(pDrawingArea2, NDSDisplayID_Touch, NDSDisplayID_Main);
|
||||||
my_gl_Clear(1);
|
my_gl_Clear(NDSDisplayID_Touch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
/* RESHAPE */
|
/* RESHAPE */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
void reshape (GtkWidget * widget, int screen) {
|
void reshape(GtkWidget *widget, NDSDisplayID displayID)
|
||||||
if (my_glDrawable[screen] == NULL ||
|
{
|
||||||
!my_gl_Begin(screen)) return;
|
if (my_glDrawable[displayID] == NULL || !my_gl_Begin(displayID))
|
||||||
|
return;
|
||||||
|
|
||||||
glViewport (0, 0, widget->allocation.width, widget->allocation.height);
|
glViewport (0, 0, widget->allocation.width, widget->allocation.height);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
my_gl_End(screen);
|
my_gl_End(displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
@ -202,7 +213,8 @@ void reshape (GtkWidget * widget, int screen) {
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_gl_ScreenTex() {
|
my_gl_ScreenTex()
|
||||||
|
{
|
||||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, screen_texture[NDSDisplayID_Main]);
|
glBindTexture(GL_TEXTURE_2D, screen_texture[NDSDisplayID_Main]);
|
||||||
|
@ -218,27 +230,18 @@ my_gl_ScreenTex() {
|
||||||
displayInfo.renderedBuffer[NDSDisplayID_Touch]);
|
displayInfo.renderedBuffer[NDSDisplayID_Touch]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_gl_ScreenTexApply(int screen) {
|
static void my_gl_ScreenTexApply(NDSDisplayID displayID)
|
||||||
|
{
|
||||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||||
|
|
||||||
GLfloat backlightIntensity = displayInfo.backlightIntensity[NDSDisplayID_Main];
|
GLfloat backlightIntensity = displayInfo.backlightIntensity[displayID];
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, screen_texture[NDSDisplayID_Main]);
|
glBindTexture(GL_TEXTURE_2D, screen_texture[displayID]);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0.00f, 0.00f); glVertex2f(-1.0f, 1.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
glColor3f(backlightIntensity, backlightIntensity, backlightIntensity); glTexCoord2f(0.00f, 0.00f); glVertex2f(-1.0f, 1.0f);
|
||||||
glTexCoord2f(1.00f, 0.00f); glVertex2f( 1.0f, 1.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
glColor3f(backlightIntensity, backlightIntensity, backlightIntensity); glTexCoord2f(1.00f, 0.00f); glVertex2f( 1.0f, 1.0f);
|
||||||
glTexCoord2f(1.00f, 0.75f); glVertex2f( 1.0f, 0.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
glColor3f(backlightIntensity, backlightIntensity, backlightIntensity); glTexCoord2f(1.00f, 0.75f); glVertex2f( 1.0f, -1.0f);
|
||||||
glTexCoord2f(0.00f, 0.75f); glVertex2f(-1.0f, 0.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
glColor3f(backlightIntensity, backlightIntensity, backlightIntensity); glTexCoord2f(0.00f, 0.75f); glVertex2f(-1.0f, -1.0f);
|
||||||
glEnd();
|
|
||||||
|
|
||||||
backlightIntensity = displayInfo.backlightIntensity[NDSDisplayID_Touch];
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, screen_texture[NDSDisplayID_Touch]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0.00f, 0.00f); glVertex2f(-1.0f, 0.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
|
||||||
glTexCoord2f(1.00f, 0.00f); glVertex2f( 1.0f, 0.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
|
||||||
glTexCoord2f(1.00f, 0.75f); glVertex2f( 1.0f, -1.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
|
||||||
glTexCoord2f(0.00f, 0.75f); glVertex2f(-1.0f, -1.0f); glColor4f(backlightIntensity, backlightIntensity, backlightIntensity, 1.0f);
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,15 +249,19 @@ static void my_gl_ScreenTexApply(int screen) {
|
||||||
/* RENDERING */
|
/* RENDERING */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
gboolean screen (GtkWidget * widget, int viewportscreen) {
|
gboolean screen(GtkWidget *widget, NDSDisplayID displayID)
|
||||||
int screen;
|
{
|
||||||
|
NDSDisplayID displayToDraw = displayID;
|
||||||
|
|
||||||
// we take care to draw the right thing the right place
|
// we take care to draw the right thing the right place
|
||||||
// we need to rearrange widgets not to use this trick
|
// we need to rearrange widgets not to use this trick
|
||||||
screen = (ScreenInvert)?1-viewportscreen:viewportscreen;
|
if (ScreenInvert)
|
||||||
// screen = viewportscreen;
|
{
|
||||||
|
displayToDraw = (displayID == NDSDisplayID_Main) ? NDSDisplayID_Touch : NDSDisplayID_Main;
|
||||||
|
}
|
||||||
|
|
||||||
if (!my_gl_Begin(viewportscreen)) return TRUE;
|
if (!my_gl_Begin(displayID))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
@ -268,18 +275,21 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
|
||||||
glDisable(GL_DITHER);
|
glDisable(GL_DITHER);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
|
||||||
if (desmume_running()) {
|
if (desmume_running())
|
||||||
|
{
|
||||||
// rotate
|
// rotate
|
||||||
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
|
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
|
||||||
if (viewportscreen==0) {
|
if (displayID == NDSDisplayID_Main)
|
||||||
|
{
|
||||||
my_gl_ScreenTex();
|
my_gl_ScreenTex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply part of the texture
|
// apply part of the texture
|
||||||
my_gl_ScreenTexApply(screen);
|
my_gl_ScreenTexApply(displayToDraw);
|
||||||
|
|
||||||
|
my_gl_End(displayID);
|
||||||
|
|
||||||
my_gl_End(viewportscreen);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,19 @@
|
||||||
#include <gtk/gtkglwidget.h>
|
#include <gtk/gtkglwidget.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../GPU.h"
|
||||||
|
|
||||||
BOOL my_gl_Begin (int screen);
|
BOOL my_gl_Begin (NDSDisplayID displayID);
|
||||||
void my_gl_End (int screen);
|
void my_gl_End (NDSDisplayID displayID);
|
||||||
void my_gl_Clear(int screen);
|
void my_gl_Clear(NDSDisplayID displayID);
|
||||||
void my_gl_DrawBeautifulQuad( void);
|
void my_gl_DrawBeautifulQuad( void);
|
||||||
void my_gl_Identity( void);
|
void my_gl_Identity( void);
|
||||||
|
|
||||||
void init_GL_capabilities( int use_software_convert);
|
void init_GL_capabilities();
|
||||||
void init_GL(GtkWidget * widget, int screen, int share_num);
|
void init_GL(GtkWidget *widget, NDSDisplayID displayID, NDSDisplayID sharedContextDisplayID);
|
||||||
int init_GL_free_s(GtkWidget * widget, int share_num);
|
NDSDisplayID init_GL_free_s(GtkWidget *widget, NDSDisplayID sharedContextDisplayID);
|
||||||
int init_GL_free(GtkWidget * widget);
|
NDSDisplayID init_GL_free(GtkWidget *widget);
|
||||||
void reshape (GtkWidget * widget, int screen);
|
void reshape(GtkWidget *widget, NDSDisplayID displayID);
|
||||||
gboolean screen (GtkWidget * widget, int off);
|
gboolean screen(GtkWidget *widget, NDSDisplayID displayID);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue