Bug fixes for GL linear filters and double buffering options.
This commit is contained in:
parent
3e2802a2de
commit
cfbe2dc5f3
|
@ -206,7 +206,7 @@ InitConfig()
|
|||
config->addOption("SDL.LastXRes", 0);
|
||||
config->addOption("SDL.LastYRes", 0);
|
||||
config->addOption('b', "bpp", "SDL.BitsPerPixel", 32);
|
||||
config->addOption("doublebuf", "SDL.DoubleBuffering", 0);
|
||||
config->addOption("doublebuf", "SDL.DoubleBuffering", 1);
|
||||
config->addOption("autoscale", "SDL.AutoScale", 1);
|
||||
config->addOption("keepratio", "SDL.KeepRatio", 1);
|
||||
config->addOption("xscale", "SDL.XScale", 1.0);
|
||||
|
@ -219,8 +219,8 @@ InitConfig()
|
|||
config->addOption("togglemenu", "SDL.ToggleMenu", 0);
|
||||
|
||||
// OpenGL options
|
||||
config->addOption("opengl", "SDL.OpenGL", 0);
|
||||
config->addOption("openglip", "SDL.OpenGLip", 0);
|
||||
config->addOption("opengl", "SDL.OpenGL", 1);
|
||||
config->addOption("openglip", "SDL.OpenGLip", 1);
|
||||
config->addOption("SDL.SpecialFilter", 0);
|
||||
config->addOption("SDL.SpecialFX", 0);
|
||||
config->addOption("SDL.Vsync", 1);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
static Display *dpy = NULL;
|
||||
static Window root;
|
||||
static GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
|
||||
static XVisualInfo *vi = NULL;
|
||||
static Colormap cmap;
|
||||
static XSetWindowAttributes swa;
|
||||
|
@ -33,9 +32,10 @@ static Window win;
|
|||
static GLXContext glc = NULL;
|
||||
static XWindowAttributes gwa;
|
||||
static XEvent xev;
|
||||
static GLint double_buffer_ena = True;
|
||||
|
||||
static GLuint gltexture = 0;
|
||||
static int spawn_new_window = 1;
|
||||
static int spawn_new_window = 0;
|
||||
|
||||
glxwin_shm_t *glx_shm = NULL;
|
||||
|
||||
|
@ -84,17 +84,32 @@ static glxwin_shm_t *open_shm(void)
|
|||
return vaddr;
|
||||
}
|
||||
//************************************************************************
|
||||
static void genTextures(void)
|
||||
static void getAttrbList( GLint *buf )
|
||||
{
|
||||
int ipolate = 1;
|
||||
int i=0;
|
||||
|
||||
buf[i] = GLX_RGBA; i++;
|
||||
buf[i] = GLX_DEPTH_SIZE; i++;
|
||||
buf[i] = 24; i++;
|
||||
buf[i] = GLX_DOUBLEBUFFER ; i++;
|
||||
buf[i] = double_buffer_ena; i++;
|
||||
buf[i] = None;
|
||||
|
||||
}
|
||||
//************************************************************************
|
||||
static void genTextures( int ipolate )
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
if ( gltexture )
|
||||
{
|
||||
printf("GL Texture already exists\n");
|
||||
return;
|
||||
}
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glGenTextures(1, &gltexture);
|
||||
else
|
||||
{
|
||||
glGenTextures(1, &gltexture);
|
||||
}
|
||||
printf("Linear Interpolation on GL Texture: %s \n", ipolate ? "Enabled" : "Disabled");
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, gltexture);
|
||||
|
||||
|
@ -107,6 +122,9 @@ static void genTextures(void)
|
|||
//************************************************************************
|
||||
static int open_window(void)
|
||||
{
|
||||
GLint att[32];
|
||||
|
||||
getAttrbList( att );
|
||||
|
||||
dpy = XOpenDisplay(NULL);
|
||||
|
||||
|
@ -157,7 +175,7 @@ static int open_window(void)
|
|||
|
||||
glXMakeCurrent(dpy, win, glc);
|
||||
|
||||
genTextures();
|
||||
genTextures(1);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Background color to black.
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@ -171,16 +189,16 @@ static int open_window(void)
|
|||
return 0;
|
||||
}
|
||||
//************************************************************************
|
||||
static void print_pixbuf(void)
|
||||
{
|
||||
for (int x=0; x<256; x++)
|
||||
{
|
||||
for (int y=0; y<256; y++)
|
||||
{
|
||||
printf("(%i,%i) = %08X \n", x, y, glx_shm->pixbuf[x*256+y] );
|
||||
}
|
||||
}
|
||||
}
|
||||
//static void print_pixbuf(void)
|
||||
//{
|
||||
// for (int x=0; x<256; x++)
|
||||
// {
|
||||
// for (int y=0; y<256; y++)
|
||||
// {
|
||||
// printf("(%i,%i) = %08X \n", x, y, glx_shm->pixbuf[y*256+x] );
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//************************************************************************
|
||||
static void render_image(void)
|
||||
{
|
||||
|
@ -286,23 +304,10 @@ static int mainWindowLoop(void)
|
|||
}
|
||||
else if (xev.type == ConfigureNotify)
|
||||
{
|
||||
//XGetWindowAttributes(dpy, win, &gwa);
|
||||
|
||||
screen_width = xev.xconfigure.width;
|
||||
screen_height = xev.xconfigure.height;
|
||||
|
||||
//if (gltexture) {
|
||||
// glDeleteTextures(1, &gltexture);
|
||||
//}
|
||||
//gltexture=0;
|
||||
|
||||
//genTextures();
|
||||
|
||||
//printf("Resize Request: (%i,%i)\n", screen_width, screen_height );
|
||||
render_image();
|
||||
//glViewport(0, 0, gwa.width, gwa.height);
|
||||
//DrawAQuad();
|
||||
//glXSwapBuffers(dpy, win);
|
||||
}
|
||||
else if (xev.type == KeyPress)
|
||||
{
|
||||
|
@ -377,11 +382,18 @@ int spawn_glxwin( int flags )
|
|||
return pid;
|
||||
}
|
||||
//************************************************************************
|
||||
int init_gtk3_GLXContext( void )
|
||||
int init_gtk3_GLXContext( int flags )
|
||||
{
|
||||
GLint att[32];
|
||||
|
||||
XWindowAttributes xattrb;
|
||||
|
||||
double_buffer_ena = (flags & GLXWIN_DOUBLE_BUFFER) ? 1 : 0;
|
||||
|
||||
getAttrbList( att );
|
||||
|
||||
printf("Init GLX Context\n");
|
||||
printf("Double Buffering: %s\n", double_buffer_ena ? "Enabled" : "Disabled");
|
||||
|
||||
GdkWindow *gdkWin = gtk_widget_get_window(evbox);
|
||||
|
||||
|
@ -436,7 +448,7 @@ int init_gtk3_GLXContext( void )
|
|||
|
||||
glXMakeCurrent(dpy, win, glc);
|
||||
|
||||
genTextures();
|
||||
genTextures( flags & GLXWIN_PIXEL_LINEAR_FILTER ? 1 : 0 );
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Background color to black.
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
|
||||
int spawn_glxwin( int flags );
|
||||
|
||||
int init_gtk3_GLXContext( void );
|
||||
#define GLXWIN_PIXEL_LINEAR_FILTER 0x0001
|
||||
#define GLXWIN_DOUBLE_BUFFER 0x0002
|
||||
|
||||
int init_gtk3_GLXContext( int flags );
|
||||
|
||||
int destroy_gtk3_GLXContext( void );
|
||||
|
||||
int gtk3_glx_render(void);
|
||||
|
|
|
@ -3444,8 +3444,18 @@ int init_gui_video( int use_openGL )
|
|||
|
||||
if ( use_openGL )
|
||||
{
|
||||
int flags=0;
|
||||
int linear_interpolation_ena=0;
|
||||
int double_buffer_ena=0;
|
||||
|
||||
g_config->getOption("SDL.OpenGLip" , &linear_interpolation_ena );
|
||||
g_config->getOption("SDL.DoubleBuffering", &double_buffer_ena );
|
||||
|
||||
if ( linear_interpolation_ena ) flags |= GLXWIN_PIXEL_LINEAR_FILTER;
|
||||
if ( double_buffer_ena ) flags |= GLXWIN_DOUBLE_BUFFER;
|
||||
|
||||
destroy_cairo_screen();
|
||||
init_gtk3_GLXContext();
|
||||
init_gtk3_GLXContext( flags );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3604,10 +3614,7 @@ drawAreaRealizeCB (GtkWidget *widget,
|
|||
{
|
||||
printf("Draw Area Realize\n");
|
||||
|
||||
if ( drawAreaGL )
|
||||
{
|
||||
init_gtk3_GLXContext();
|
||||
}
|
||||
init_gui_video( drawAreaGL );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue