Linux Port (GTK): Fix OSMesa context creation. (Regression from r4905. Fixes #119.)
- Also do some code cleanup.
This commit is contained in:
parent
b9ada994df
commit
010efff31b
|
@ -75,7 +75,7 @@ AM_CONDITIONAL([HAVE_GL], [test "${have_gl_h}" = "yes"])
|
|||
|
||||
dnl - if --enable-osmesa is used, check for it
|
||||
AC_ARG_ENABLE([osmesa],
|
||||
[AC_HELP_STRING([--enable-osmesa], [use off-screen mesa])],
|
||||
[AC_HELP_STRING([--enable-osmesa], [use off-screen mesa, overrides GLX])],
|
||||
[osmesa=$enableval],
|
||||
[osmesa=no])
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/*
|
||||
Copyright (C) 2013 The Lemon Man
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2013 The Lemon Man
|
||||
Copyright (C) 2013-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GL_GLX
|
||||
#include <stdio.h>
|
||||
|
@ -24,9 +22,11 @@
|
|||
#include <GL/glx.h>
|
||||
#include "../OGLRender.h"
|
||||
|
||||
#include "glx_3Demu.h"
|
||||
|
||||
static bool glx_beginOpenGL(void) { return 1; }
|
||||
static void glx_endOpenGL(void) { }
|
||||
static bool glx_init(void) { return true; }
|
||||
static bool glx_init(void) { return is_glx_initialized(); }
|
||||
static int xerror_handler(Display *dpy, XErrorEvent *ev) { return 0; }
|
||||
|
||||
static GLXContext ctx = NULL;
|
||||
|
@ -34,7 +34,7 @@ static GLXPbuffer pbuf;
|
|||
|
||||
typedef GLXContext (*wtf)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
||||
|
||||
int deinit_glx_3Demu(void)
|
||||
bool deinit_glx_3Demu(void)
|
||||
{
|
||||
Display *dpy = glXGetCurrentDisplay();
|
||||
|
||||
|
@ -53,7 +53,7 @@ int deinit_glx_3Demu(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
int init_glx_3Demu(void)
|
||||
bool init_glx_3Demu(void)
|
||||
{
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
XVisualInfo *vis;
|
||||
|
@ -159,7 +159,7 @@ int init_glx_3Demu(void)
|
|||
|
||||
bool is_glx_initialized(void)
|
||||
{
|
||||
return ctx != NULL;
|
||||
return (ctx != NULL);
|
||||
}
|
||||
|
||||
#endif // HAVE_GLX
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
/*
|
||||
Copyright (C) 2013 The Lemon Man
|
||||
/*
|
||||
Copyright (C) 2013 The Lemon Man
|
||||
Copyright (C) 2013-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
This file is part of DeSmuME
|
||||
#ifndef GLX_3DEMU_H
|
||||
#define GLX_3DEMU_H
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GL_GLX
|
||||
int init_glx_3Demu(void);
|
||||
int deinit_glx_3Demu(void);
|
||||
bool init_glx_3Demu(void);
|
||||
bool deinit_glx_3Demu(void);
|
||||
bool is_glx_initialized(void);
|
||||
#endif
|
||||
|
||||
#endif // GLX_3DEMU_H
|
||||
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
/* main.cpp - this file is part of DeSmuME
|
||||
*
|
||||
* Copyright (C) 2006-2016 DeSmuME Team
|
||||
* Copyright (C) 2007 Pascal Giard (evilynux)
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
/*
|
||||
Copyright (C) 2007 Pascal Giard (evilynux)
|
||||
Copyright (C) 2006-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GTK_UI
|
||||
|
@ -65,17 +62,25 @@
|
|||
#include "filter/videofilter.h"
|
||||
|
||||
#ifdef GDB_STUB
|
||||
#include "armcpu.h"
|
||||
#include "gdbstub.h"
|
||||
#include "armcpu.h"
|
||||
#include "gdbstub.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "OGLRender.h"
|
||||
#include "OGLRender_3_2.h"
|
||||
#include "osmesa_3Demu.h"
|
||||
#include "glx_3Demu.h"
|
||||
#define HAVE_OPENGL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "OGLRender.h"
|
||||
#include "OGLRender_3_2.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GL_GLX)
|
||||
#include "glx_3Demu.h"
|
||||
#elif defined(HAVE_LIBOSMESA)
|
||||
#include "osmesa_3Demu.h"
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
@ -617,7 +622,7 @@ NULL
|
|||
GPU3DInterface *core3DList[] = {
|
||||
&gpu3DNull,
|
||||
&gpu3DRasterize,
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
&gpu3Dgl,
|
||||
#endif
|
||||
};
|
||||
|
@ -693,7 +698,7 @@ fill_configured_features( class configured_features *config,
|
|||
{ "3d-render", 0, 0, G_OPTION_ARG_INT, &config->engine_3d, "Select 3D rendering engine. Available engines:\n"
|
||||
"\t\t\t\t 0 = 3d disabled\n"
|
||||
"\t\t\t\t 1 = internal rasterizer (default)\n"
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
"\t\t\t\t 2 = opengl\n"
|
||||
#endif
|
||||
,"ENGINE"},
|
||||
|
@ -737,12 +742,12 @@ fill_configured_features( class configured_features *config,
|
|||
// Check if the commandLine argument was actually passed
|
||||
if (config->engine_3d != -1) {
|
||||
if (config->engine_3d != 0 && config->engine_3d != 1
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
&& config->engine_3d != 2
|
||||
#endif
|
||||
) {
|
||||
g_printerr("Currently available ENGINES: 0, 1"
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
", 2"
|
||||
#endif
|
||||
"\n");
|
||||
|
@ -2185,8 +2190,8 @@ static void GraphicsSettingsDialog() {
|
|||
|
||||
coreCombo = gtk_combo_box_text_new();
|
||||
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(coreCombo), 0, "Null");
|
||||
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(coreCombo), 1, "Software Raserizer");
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(coreCombo), 1, "SoftRasterizer");
|
||||
#ifdef HAVE_OPENGL
|
||||
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(coreCombo), 2, "OpenGL");
|
||||
#endif
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(coreCombo), cur3DCore);
|
||||
|
@ -2230,17 +2235,17 @@ static void GraphicsSettingsDialog() {
|
|||
static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), 0, 0);
|
||||
|
||||
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
// OpenGL Multisample
|
||||
wMultisample = gtk_check_button_new_with_label("Multisample (OpenGL)");
|
||||
wMultisample = gtk_check_button_new_with_label("Multisample Antialiasing (OpenGL)");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wMultisample), CommonSettings.GFX3D_Renderer_Multisample);
|
||||
gtk_table_attach(GTK_TABLE(wTable), wMultisample, 1, 2, 2, 3,
|
||||
static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL),
|
||||
static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), 10, 0);
|
||||
#endif
|
||||
|
||||
// SoftwareRasterizer High Color Interpolation
|
||||
wHCInterpolate = gtk_check_button_new_with_label("High Resolution Color Interpolation (SoftwareRasterizer)");
|
||||
// SoftRasterizer High Color Interpolation
|
||||
wHCInterpolate = gtk_check_button_new_with_label("High Resolution Color Interpolation (SoftRasterizer)");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wHCInterpolate), CommonSettings.GFX3D_HighResolutionInterpolateColor);
|
||||
gtk_table_attach(GTK_TABLE(wTable), wHCInterpolate, 1, 2, 3, 4,
|
||||
static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL),
|
||||
|
@ -2256,20 +2261,31 @@ static void GraphicsSettingsDialog() {
|
|||
int sel3DCore = gtk_combo_box_get_active(GTK_COMBO_BOX(coreCombo));
|
||||
|
||||
// Change only if needed
|
||||
if (sel3DCore != cur3DCore) {
|
||||
#if defined(HAVE_LIBOSMESA)
|
||||
if (sel3DCore == 2 && !is_osmesa_initialized()) {
|
||||
init_osmesa_3Demu();
|
||||
}
|
||||
if (sel3DCore != cur3DCore)
|
||||
{
|
||||
if (sel3DCore == 2)
|
||||
{
|
||||
#if !defined(HAVE_OPENGL)
|
||||
sel3DCore = RENDERID_SOFTRASTERIZER;
|
||||
#elif defined(HAVE_GL_GLX)
|
||||
if (sel3DCore == 2 && !is_glx_initialized()) {
|
||||
init_glx_3Demu();
|
||||
}
|
||||
if (!is_glx_initialized())
|
||||
{
|
||||
init_glx_3Demu();
|
||||
}
|
||||
#elif defined(HAVE_LIBOSMESA)
|
||||
if (!is_osmesa_initialized())
|
||||
{
|
||||
init_osmesa_3Demu();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (GPU->Change3DRendererByID(sel3DCore)) {
|
||||
if (GPU->Change3DRendererByID(sel3DCore))
|
||||
{
|
||||
config.core3D = sel3DCore;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
GPU->Change3DRendererByID(RENDERID_SOFTRASTERIZER);
|
||||
g_printerr("3D renderer initialization failed!\nFalling back to 3D core: %s\n", core3DList[RENDERID_SOFTRASTERIZER]->name);
|
||||
config.core3D = RENDERID_SOFTRASTERIZER;
|
||||
|
@ -2292,7 +2308,7 @@ static void GraphicsSettingsDialog() {
|
|||
CommonSettings.GFX3D_Renderer_TextureSmoothing = config.textureSmoothing = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wSmoothing));
|
||||
CommonSettings.GFX3D_Renderer_TextureScalingFactor = config.textureUpscale = scale;
|
||||
CommonSettings.GFX3D_HighResolutionInterpolateColor = config.highColorInterpolation = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wHCInterpolate));
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
#ifdef HAVE_OPENGL
|
||||
CommonSettings.GFX3D_Renderer_Multisample = config.multisampling = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wMultisample));
|
||||
#endif
|
||||
}
|
||||
|
@ -3348,8 +3364,10 @@ common_gtk_main( class configured_features *my_config)
|
|||
gtk_toggle_action_set_active((GtkToggleAction *)action, FALSE);
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENGL) && defined(OGLRENDER_3_2_H)
|
||||
OGLLoadEntryPoints_3_2_Func = OGLLoadEntryPoints_3_2;
|
||||
OGLCreateRenderer_3_2_Func = OGLCreateRenderer_3_2;
|
||||
#endif
|
||||
|
||||
//Set the 3D emulation to use
|
||||
int core = my_config->engine_3d;
|
||||
|
@ -3362,23 +3380,29 @@ common_gtk_main( class configured_features *my_config)
|
|||
|
||||
// Check if it is valid
|
||||
if (!(core >= 0 && core <= 2)) {
|
||||
// If it is invalid, reset it to softwareRasterizer
|
||||
// If it is invalid, reset it to SoftRasterizer
|
||||
core = 1;
|
||||
}
|
||||
//Set this too for clarity
|
||||
my_config->engine_3d = core;
|
||||
}
|
||||
#if defined(HAVE_LIBOSMESA) || defined(HAVE_GL_GLX)
|
||||
if(core == 2)
|
||||
{
|
||||
#if defined(HAVE_LIBOSMESA)
|
||||
core = init_osmesa_3Demu()
|
||||
|
||||
if (core == 2)
|
||||
{
|
||||
#if !defined(HAVE_OPENGL)
|
||||
core = RENDERID_SOFTRASTERIZER;
|
||||
#elif defined(HAVE_GL_GLX)
|
||||
core = init_glx_3Demu()
|
||||
#endif
|
||||
? 2 : RENDERID_NULL;
|
||||
}
|
||||
if (!is_glx_initialized())
|
||||
{
|
||||
init_glx_3Demu();
|
||||
}
|
||||
#elif defined(HAVE_LIBOSMESA)
|
||||
if (!is_osmesa_initialized())
|
||||
{
|
||||
init_osmesa_3Demu();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!GPU->Change3DRendererByID(core)) {
|
||||
GPU->Change3DRendererByID(RENDERID_SOFTRASTERIZER);
|
||||
|
@ -3443,10 +3467,10 @@ common_gtk_main( class configured_features *my_config)
|
|||
|
||||
desmume_free();
|
||||
|
||||
#if defined(HAVE_LIBOSMESA)
|
||||
deinit_osmesa_3Demu();
|
||||
#elif defined(HAVE_GL_GLX)
|
||||
deinit_glx_3Demu();
|
||||
#if defined(HAVE_GL_GLX)
|
||||
deinit_glx_3Demu();
|
||||
#elif defined(HAVE_LIBOSMESA)
|
||||
deinit_osmesa_3Demu();
|
||||
#endif
|
||||
|
||||
/* Unload joystick */
|
||||
|
|
|
@ -1,60 +1,98 @@
|
|||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBOSMESA
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/osmesa.h>
|
||||
#include "../OGLRender.h"
|
||||
#include "../OGLRender_3_2.h"
|
||||
|
||||
#include "osmesa_3Demu.h"
|
||||
|
||||
static void *buffer = NULL;
|
||||
static OSMesaContext ctx = NULL;
|
||||
|
||||
static bool osmesa_beginOpenGL(void) { return 1; }
|
||||
static void osmesa_endOpenGL(void) { }
|
||||
static bool osmesa_init(void) { return true; }
|
||||
|
||||
static void * buffer = NULL;
|
||||
static OSMesaContext ctx;
|
||||
static bool osmesa_init(void) { return is_osmesa_initialized(); }
|
||||
|
||||
void deinit_osmesa_3Demu (void)
|
||||
{
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
|
||||
OSMesaDestroyContext(ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
|
||||
int init_osmesa_3Demu(void)
|
||||
bool init_osmesa_3Demu(void)
|
||||
{
|
||||
if (!ctx)
|
||||
{
|
||||
printf("OSMesaCreateContext failed!\n");
|
||||
return false;
|
||||
}
|
||||
#if (((OSMESA_MAJOR_VERSION * 100) + OSMESA_MINOR_VERSION) >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
|
||||
static const int attributes_3_2_core_profile[] = {
|
||||
OSMESA_FORMAT, OSMESA_RGBA,
|
||||
OSMESA_DEPTH_BITS, 24,
|
||||
OSMESA_STENCIL_BITS, 8,
|
||||
OSMESA_ACCUM_BITS, 0,
|
||||
OSMESA_PROFILE, OSMESA_CORE_PROFILE,
|
||||
OSMESA_CONTEXT_MAJOR_VERSION, 3,
|
||||
OSMESA_CONTEXT_MINOR_VERSION, 2,
|
||||
0 };
|
||||
|
||||
ctx = OSMesaCreateContextAttribs(attributes_3_2_core_profile, NULL);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
printf("OSMesa: Could not create a 3.2 Core Profile context. Will attempt to create a 2.1 compatibility context...\n");
|
||||
|
||||
static const int attributes_2_1[] = {
|
||||
OSMESA_FORMAT, OSMESA_RGBA,
|
||||
OSMESA_DEPTH_BITS, 24,
|
||||
OSMESA_STENCIL_BITS, 8,
|
||||
OSMESA_ACCUM_BITS, 0,
|
||||
OSMESA_PROFILE, OSMESA_COMPAT_PROFILE,
|
||||
OSMESA_CONTEXT_MAJOR_VERSION, 2,
|
||||
OSMESA_CONTEXT_MINOR_VERSION, 1,
|
||||
0 };
|
||||
|
||||
ctx = OSMesaCreateContextAttribs(attributes_2_1, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer = malloc(256 * 192 * 4);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
ctx = OSMesaCreateContextExt(OSMESA_RGBA, 24, 8, 0, NULL);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
printf("OSMesa: OSMesaCreateContextExt() failed!\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
buffer = malloc(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(uint32_t));
|
||||
if (!buffer)
|
||||
{
|
||||
printf("Could not allocate enough memory!\n");
|
||||
printf("OSMesa: Could not allocate enough memory for the context!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, 256, 192))
|
||||
if (!OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT))
|
||||
{
|
||||
printf("OSMesaMakeCurrent failed!\n");
|
||||
printf("OSMesa: OSMesaMakeCurrent() failed!\n");
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
|
@ -68,6 +106,7 @@ int init_osmesa_3Demu(void)
|
|||
|
||||
bool is_osmesa_initialized(void)
|
||||
{
|
||||
return ctx != NULL;
|
||||
return (ctx != NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
This file is part of DeSmuME
|
||||
#ifndef OSMESA_3DEMU_H
|
||||
#define OSMESA_3DEMU_H
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBOSMESA
|
||||
int init_osmesa_3Demu(void);
|
||||
bool init_osmesa_3Demu(void);
|
||||
void deinit_osmesa_3Demu(void);
|
||||
bool is_osmesa_initialized(void);
|
||||
#endif
|
||||
|
||||
#endif // OSMESA_3DEMU_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue