mirror of
https://github.com/TASEmulators/desmume
synced 2025-10-05 16:22:49 +02:00
Remove OSMesa support (#905)
Mesa has now removed OSMesa from its codebase, see https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33836 There is no reason to keep this any longer, especially since EGL can do the same and more.
This commit is contained in:
@@ -107,7 +107,7 @@ Select available 3d emulation:
|
||||
|
||||
0 = 3d disabled
|
||||
1 = internal desmume software rasterizer (default)
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume --help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume --help)
|
||||
|
||||
[edit] --disable-sound [gtk]
|
||||
|
||||
|
@@ -25,7 +25,6 @@
|
||||
<Add option="`pkg-config --libs gtk+-2.0`" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
|
||||
</Linker>
|
||||
</Target>
|
||||
@@ -72,7 +71,6 @@
|
||||
<Add option="`pkg-config --libs gtk+-3.0`" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@@ -2024,20 +2022,6 @@
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/mic_openal.cpp" />
|
||||
<Unit filename="../shared/osmesa_3Demu.cpp">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
<Option target="GTK3_x64_Debug" />
|
||||
<Option target="GTK3_x64_Release" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/osmesa_3Demu.h">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
<Option target="GTK3_x64_Debug" />
|
||||
<Option target="GTK3_x64_Release" />
|
||||
<Option target="GTK3_AArch64_Debug" />
|
||||
<Option target="GTK3_AArch64_Release" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/sdl_3Demu.cpp">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
|
@@ -118,7 +118,7 @@ AM_CONDITIONAL([ENABLE_OPENGL_ES], [test "${have_opengles}" = "yes"])
|
||||
|
||||
dnl - if --enable-glx is used, check for it
|
||||
AC_ARG_ENABLE([glx],
|
||||
[AC_HELP_STRING([--enable-glx], [Use a GLX context, overrides --enable-osmesa and --enable-egl])],
|
||||
[AC_HELP_STRING([--enable-glx], [Use a GLX context, overrides --enable-egl])],
|
||||
[glx=$enableval],
|
||||
[glx=no])
|
||||
|
||||
@@ -143,40 +143,6 @@ if test "$have_glx" = "yes" ; then
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_GLX], [test "${have_glx}" = "yes"])
|
||||
|
||||
dnl - if --enable-osmesa is used, check for it
|
||||
AC_ARG_ENABLE([osmesa],
|
||||
[AC_HELP_STRING([--enable-osmesa], [Use an OSMesa context, overrides --enable-egl])],
|
||||
[osmesa=$enableval],
|
||||
[osmesa=no])
|
||||
|
||||
if test "x$osmesa" = "xyes" ; then
|
||||
AC_CHECK_HEADERS([GL/osmesa.h], [have_osmesa=yes], [have_osmesa=no])
|
||||
if test "have_osmesa" = "no" ; then
|
||||
AC_MSG_WARN([Cannot use OSMesa -- headers not found.])
|
||||
else
|
||||
AC_MSG_WARN([OSMesa contexts are deprecated.])
|
||||
AC_CHECK_LIB(dl, main)
|
||||
AC_CHECK_LIB(GL, main)
|
||||
AC_CHECK_LIB(OSMesa, main)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$have_osmesa" = "yes" ; then
|
||||
if test "$have_opengl" = "yes" ; then
|
||||
AC_DEFINE(ENABLE_OSMESA)
|
||||
OSMESA_LIBS="-lOSMesa"
|
||||
AC_SUBST(OSMESA_LIBS)
|
||||
else
|
||||
have_osmesa=no
|
||||
if test "$have_opengles" = "yes" ; then
|
||||
AC_MSG_WARN([OSMesa contexts are incompatible with OpenGL ES -- cancelling the use of OSMesa.])
|
||||
else
|
||||
AC_MSG_WARN([OSMesa contexts are only compatible with standard OpenGL -- cancelling the use of OSMesa.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_OSMESA], [test "${have_osmesa}" = "yes"])
|
||||
|
||||
dnl - if --enable-egl is used, check for it
|
||||
AC_ARG_ENABLE([egl],
|
||||
[AC_HELP_STRING([--enable-egl], [Use an EGL context])],
|
||||
|
@@ -52,7 +52,7 @@ Select available 3d emulation:
|
||||
1 = internal desmume software rasterizer (default)
|
||||
.RE
|
||||
.RS
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-disable-sound
|
||||
|
@@ -81,8 +81,6 @@
|
||||
|
||||
#if defined(ENABLE_GLX)
|
||||
#include "../shared/glx_3Demu.h"
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
#include "../shared/osmesa_3Demu.h"
|
||||
#elif defined(ENABLE_EGL)
|
||||
#include "../shared/egl_3Demu.h"
|
||||
#else
|
||||
@@ -2325,7 +2323,7 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
{
|
||||
switch (sel3DCore)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -2337,8 +2335,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -2349,8 +2345,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -2361,8 +2355,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -3951,12 +3943,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
oglrender_beginOpenGL = &glx_beginOpenGL;
|
||||
oglrender_endOpenGL = &glx_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &glx_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &osmesa_deinitOpenGL;
|
||||
oglrender_beginOpenGL = &osmesa_beginOpenGL;
|
||||
oglrender_endOpenGL = &osmesa_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &osmesa_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &egl_deinitOpenGL;
|
||||
@@ -3998,7 +3984,7 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
|
||||
switch (core)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -4010,8 +3996,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -4022,8 +4006,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -4034,8 +4016,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -4130,8 +4110,6 @@ static void Teardown() {
|
||||
#if defined(ENABLE_OPENGL_STANDARD) || defined(ENABLE_OPENGL_ES)
|
||||
#if defined(ENABLE_GLX)
|
||||
glx_deinitOpenGL();
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
osmesa_deinitOpenGL();
|
||||
#elif defined(ENABLE_EGL)
|
||||
egl_deinitOpenGL();
|
||||
#else
|
||||
|
@@ -29,10 +29,6 @@ if get_option('glx') and dep_gl.found()
|
||||
desmume_src += [
|
||||
'../shared/glx_3Demu.cpp',
|
||||
]
|
||||
elif get_option('osmesa') and dep_osmesa.found()
|
||||
desmume_src += [
|
||||
'../shared/osmesa_3Demu.cpp',
|
||||
]
|
||||
elif get_option('egl') and dep_egl.found()
|
||||
desmume_src += [
|
||||
'../shared/egl_3Demu.cpp',
|
||||
|
@@ -39,10 +39,6 @@ endif
|
||||
if ENABLE_GLX
|
||||
desmume_SOURCES += ../shared/glx_3Demu.h ../shared/glx_3Demu.cpp
|
||||
else
|
||||
if ENABLE_OSMESA
|
||||
desmume_LDADD += $(OSMESA_LIBS)
|
||||
desmume_SOURCES += ../shared/osmesa_3Demu.h ../shared/osmesa_3Demu.cpp
|
||||
else
|
||||
if ENABLE_EGL
|
||||
desmume_LDADD += $(EGL_LIBS)
|
||||
desmume_SOURCES += ../shared/egl_3Demu.h ../shared/egl_3Demu.cpp
|
||||
@@ -50,7 +46,6 @@ else
|
||||
desmume_SOURCES += ../shared/sdl_3Demu.h ../shared/sdl_3Demu.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
UPDATE_DESKTOP = \
|
||||
appsdir=$(DESTDIR)$(datadir)/applications ; \
|
||||
|
@@ -52,7 +52,7 @@ Select available 3d emulation:
|
||||
1 = internal desmume software rasterizer (default)
|
||||
.RE
|
||||
.RS
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-disable-sound
|
||||
|
@@ -77,8 +77,6 @@
|
||||
|
||||
#if defined(ENABLE_GLX)
|
||||
#include "../shared/glx_3Demu.h"
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
#include "../shared/osmesa_3Demu.h"
|
||||
#elif defined(ENABLE_EGL)
|
||||
#include "../shared/egl_3Demu.h"
|
||||
#else
|
||||
@@ -2613,7 +2611,7 @@ static void GraphicsSettingsDialog() {
|
||||
{
|
||||
switch (sel3DCore)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -2625,8 +2623,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -2637,8 +2633,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -2649,8 +2643,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -3828,12 +3820,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
oglrender_beginOpenGL = &glx_beginOpenGL;
|
||||
oglrender_endOpenGL = &glx_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &glx_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &osmesa_deinitOpenGL;
|
||||
oglrender_beginOpenGL = &osmesa_beginOpenGL;
|
||||
oglrender_endOpenGL = &osmesa_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &osmesa_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &egl_deinitOpenGL;
|
||||
@@ -3875,7 +3861,7 @@ common_gtk_main( class configured_features *my_config)
|
||||
|
||||
switch (core)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -3887,8 +3873,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -3899,8 +3883,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -3911,8 +3893,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -4005,8 +3985,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
#if defined(ENABLE_OPENGL_STANDARD) || defined(ENABLE_OPENGL_ES)
|
||||
#if defined(ENABLE_GLX)
|
||||
glx_deinitOpenGL();
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
osmesa_deinitOpenGL();
|
||||
#elif defined(ENABLE_EGL)
|
||||
egl_deinitOpenGL();
|
||||
#else
|
||||
|
@@ -22,10 +22,6 @@ if get_option('glx') and dep_gl.found()
|
||||
desmume_src += [
|
||||
'../shared/glx_3Demu.cpp',
|
||||
]
|
||||
elif get_option('osmesa') and dep_osmesa.found()
|
||||
desmume_src += [
|
||||
'../shared/osmesa_3Demu.cpp',
|
||||
]
|
||||
elif get_option('egl') and dep_egl.found()
|
||||
desmume_src += [
|
||||
'../shared/egl_3Demu.cpp',
|
||||
|
@@ -22,7 +22,6 @@ dep_alsa = dependency('alsa', required: false)
|
||||
dep_soundtouch = dependency('soundtouch', required: false)
|
||||
dep_agg = dependency('libagg', required: false)
|
||||
dep_fontconfig = dependency('fontconfig', required: false)
|
||||
dep_osmesa = dependency('osmesa', required: false)
|
||||
dep_egl = dependency('egl', required: false)
|
||||
|
||||
# XXX: something wrong with this one.
|
||||
@@ -248,20 +247,6 @@ if get_option('glx')
|
||||
else
|
||||
message('Cannot use GLX -- gl library not found.')
|
||||
endif
|
||||
elif get_option('osmesa')
|
||||
if dep_osmesa.found()
|
||||
if get_option('opengl') and dep_gl.found()
|
||||
message('OSMesa contexts are deprecated.')
|
||||
add_global_arguments('-DENABLE_OSMESA', language: ['c', 'cpp'])
|
||||
dependencies += dep_osmesa
|
||||
elif get_option('opengles')
|
||||
message('OSMesa contexts are incompatible with OpenGL ES -- cancelling the use of OSMesa.')
|
||||
else
|
||||
message('OSMesa contexts are only compatible with standard OpenGL -- cancelling the use of OSMesa.')
|
||||
endif
|
||||
else
|
||||
message('Cannot use OSMesa -- osmesa library not found.')
|
||||
endif
|
||||
elif get_option('egl')
|
||||
if dep_egl.found()
|
||||
add_global_arguments('-DENABLE_EGL', language: ['c', 'cpp'])
|
||||
|
@@ -13,11 +13,6 @@ option('glx',
|
||||
value: false,
|
||||
description: 'Use a GLX context',
|
||||
)
|
||||
option('osmesa',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Use a OSMesa context',
|
||||
)
|
||||
option('egl',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
|
@@ -1,284 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2024 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/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/osmesa.h>
|
||||
|
||||
#include "osmesa_3Demu.h"
|
||||
#include "OGLRender_3_2.h"
|
||||
|
||||
#warning OSMesa contexts are deprecated.
|
||||
|
||||
|
||||
static OSMesaContext currContext = NULL;
|
||||
static GLint currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
static GLint currCtxWidth = 0;
|
||||
static GLint currCtxHeight = 0;
|
||||
static void *currCtxBuffer = NULL;
|
||||
|
||||
static OSMesaContext prevContext = NULL;
|
||||
static GLint prevCtxFormat = GL_UNSIGNED_BYTE;
|
||||
static GLint prevCtxWidth = 0;
|
||||
static GLint prevCtxHeight = 0;
|
||||
static void *prevCtxBuffer = NULL;
|
||||
|
||||
static void *pendingCtxBuffer = NULL;
|
||||
static GLint pendingCtxWidth = 0;
|
||||
static GLint pendingCtxHeight = 0;
|
||||
|
||||
static bool __osmesa_initOpenGL(const int requestedProfile, const int requestedVersionMajor, const int requestedVersionMinor)
|
||||
{
|
||||
GLboolean ret = GL_FALSE;
|
||||
|
||||
if (currContext != NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if (((OSMESA_MAJOR_VERSION * 100) + OSMESA_MINOR_VERSION) >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
|
||||
const int ctxAttributes[] = {
|
||||
OSMESA_FORMAT, OSMESA_RGBA,
|
||||
OSMESA_DEPTH_BITS, ( (requestedProfile == OSMESA_CORE_PROFILE) && ((requestedVersionMajor >= 4) || ((requestedVersionMajor == 3) && (requestedVersionMinor >= 2))) ) ? 0 : 24,
|
||||
OSMESA_STENCIL_BITS, ( (requestedProfile == OSMESA_CORE_PROFILE) && ((requestedVersionMajor >= 4) || ((requestedVersionMajor == 3) && (requestedVersionMinor >= 2))) ) ? 0 : 8,
|
||||
OSMESA_ACCUM_BITS, 0,
|
||||
OSMESA_PROFILE, requestedProfile,
|
||||
OSMESA_CONTEXT_MAJOR_VERSION, requestedVersionMajor,
|
||||
OSMESA_CONTEXT_MINOR_VERSION, requestedVersionMinor,
|
||||
0
|
||||
};
|
||||
|
||||
currContext = OSMesaCreateContextAttribs(ctxAttributes, NULL);
|
||||
if (currContext == NULL)
|
||||
{
|
||||
if (requestedProfile == OSMESA_CORE_PROFILE)
|
||||
{
|
||||
puts("OSMesa: OSMesaCreateContextAttribs() failed!");
|
||||
return false;
|
||||
}
|
||||
else if (requestedProfile == OSMESA_COMPAT_PROFILE)
|
||||
{
|
||||
puts("OSMesa: Could not create a context using OSMesaCreateContextAttribs(). Will attempt to use OSMesaCreateContextExt() instead...");
|
||||
}
|
||||
}
|
||||
|
||||
if ( (currContext == NULL) && (requestedProfile == OSMESA_COMPAT_PROFILE) )
|
||||
#endif
|
||||
{
|
||||
currContext = OSMesaCreateContextExt(OSMESA_RGBA, 24, 8, 0, NULL);
|
||||
if (currContext == NULL)
|
||||
{
|
||||
puts("OSMesa: OSMesaCreateContextExt() failed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
currCtxWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
|
||||
currCtxHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
|
||||
currCtxBuffer = malloc_alignedPage(currCtxWidth * currCtxHeight * sizeof(uint32_t));
|
||||
if (currCtxBuffer == NULL)
|
||||
{
|
||||
OSMesaDestroyContext(currContext);
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
currCtxWidth = 0;
|
||||
currCtxHeight = 0;
|
||||
|
||||
puts("OSMesa: Could not allocate enough memory for the context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
puts("OSMesa: Context creation successful.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_StandardAuto()
|
||||
{
|
||||
bool isContextCreated = __osmesa_initOpenGL(OSMESA_CORE_PROFILE, 4, 1);
|
||||
|
||||
if (!isContextCreated)
|
||||
{
|
||||
isContextCreated = osmesa_initOpenGL_3_2_CoreProfile();
|
||||
}
|
||||
|
||||
if (!isContextCreated)
|
||||
{
|
||||
isContextCreated = osmesa_initOpenGL_LegacyAuto();
|
||||
}
|
||||
|
||||
return isContextCreated;
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_LegacyAuto()
|
||||
{
|
||||
return __osmesa_initOpenGL(OSMESA_COMPAT_PROFILE, 1, 2);
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_3_2_CoreProfile()
|
||||
{
|
||||
return __osmesa_initOpenGL(OSMESA_CORE_PROFILE, 3, 2);
|
||||
}
|
||||
|
||||
void osmesa_deinitOpenGL()
|
||||
{
|
||||
OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0);
|
||||
|
||||
if (currContext != NULL)
|
||||
{
|
||||
OSMesaDestroyContext(currContext);
|
||||
currContext = NULL;
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
if (currCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(currCtxBuffer);
|
||||
currCtxBuffer = NULL;
|
||||
currCtxWidth = 0;
|
||||
currCtxHeight = 0;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(pendingCtxBuffer);
|
||||
pendingCtxBuffer = NULL;
|
||||
pendingCtxWidth = 0;
|
||||
pendingCtxHeight = 0;
|
||||
}
|
||||
|
||||
prevContext = NULL;
|
||||
prevCtxFormat = GL_UNSIGNED_BYTE;
|
||||
prevCtxWidth = 0;
|
||||
prevCtxHeight = 0;
|
||||
prevCtxBuffer = NULL;
|
||||
}
|
||||
|
||||
bool osmesa_beginOpenGL()
|
||||
{
|
||||
GLboolean ret = GL_FALSE;
|
||||
OSMesaContext oldContext = OSMesaGetCurrentContext();
|
||||
|
||||
if (oldContext != NULL)
|
||||
{
|
||||
prevContext = oldContext;
|
||||
OSMesaGetColorBuffer(prevContext, &prevCtxWidth, &prevCtxHeight, &prevCtxFormat, &prevCtxBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
prevContext = currContext;
|
||||
prevCtxFormat = currCtxFormat;
|
||||
prevCtxWidth = currCtxWidth;
|
||||
prevCtxHeight = currCtxHeight;
|
||||
prevCtxBuffer = currCtxBuffer;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
bool previousIsCurrent = (prevCtxBuffer == currCtxBuffer);
|
||||
|
||||
ret = OSMesaMakeCurrent(currContext, pendingCtxBuffer, currCtxFormat, pendingCtxWidth, pendingCtxHeight);;
|
||||
if (ret == GL_TRUE)
|
||||
{
|
||||
free_aligned(currCtxBuffer);
|
||||
currCtxBuffer = pendingCtxBuffer;
|
||||
|
||||
if (previousIsCurrent)
|
||||
{
|
||||
prevCtxBuffer = pendingCtxBuffer;
|
||||
prevCtxWidth = pendingCtxWidth;
|
||||
prevCtxHeight = pendingCtxHeight;
|
||||
}
|
||||
|
||||
pendingCtxBuffer = NULL;
|
||||
pendingCtxWidth = 0;
|
||||
pendingCtxHeight = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = OSMesaMakeCurrent(currContext, currCtxBuffer, currCtxFormat, currCtxWidth, currCtxHeight);
|
||||
}
|
||||
|
||||
return (ret == GL_TRUE);
|
||||
}
|
||||
|
||||
void osmesa_endOpenGL()
|
||||
{
|
||||
if (prevContext == NULL)
|
||||
{
|
||||
prevContext = currContext;
|
||||
}
|
||||
|
||||
if (prevCtxBuffer == NULL)
|
||||
{
|
||||
prevCtxBuffer = currCtxBuffer;
|
||||
}
|
||||
|
||||
if (prevCtxWidth == 0)
|
||||
{
|
||||
prevCtxWidth = currCtxWidth;
|
||||
}
|
||||
|
||||
if (prevCtxHeight == 0)
|
||||
{
|
||||
prevCtxHeight = currCtxHeight;
|
||||
}
|
||||
|
||||
if (prevCtxFormat == GL_UNSIGNED_BYTE)
|
||||
{
|
||||
prevCtxFormat = currCtxFormat;
|
||||
}
|
||||
|
||||
if ( (prevContext != currContext) ||
|
||||
(prevCtxBuffer != currCtxBuffer) ||
|
||||
(prevCtxFormat != currCtxFormat) ||
|
||||
(prevCtxWidth != currCtxWidth) ||
|
||||
(prevCtxHeight != currCtxHeight) )
|
||||
{
|
||||
OSMesaMakeCurrent(prevContext, prevCtxBuffer, prevCtxFormat, prevCtxWidth, prevCtxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
bool osmesa_framebufferDidResizeCallback(bool isFBOSupported, size_t w, size_t h)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (isFBOSupported)
|
||||
{
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( (w == (size_t)currCtxWidth) && (h == (size_t)currCtxHeight) )
|
||||
{
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(pendingCtxBuffer);
|
||||
}
|
||||
|
||||
pendingCtxWidth = (GLint)w;
|
||||
pendingCtxHeight = (GLint)h;
|
||||
pendingCtxBuffer = malloc_alignedPage(w * h * sizeof(uint32_t));
|
||||
|
||||
result = true;
|
||||
return result;
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2024 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 OSMESA_3DEMU_H
|
||||
#define OSMESA_3DEMU_H
|
||||
|
||||
bool osmesa_initOpenGL_StandardAuto();
|
||||
bool osmesa_initOpenGL_LegacyAuto();
|
||||
bool osmesa_initOpenGL_3_2_CoreProfile();
|
||||
|
||||
void osmesa_deinitOpenGL();
|
||||
bool osmesa_beginOpenGL();
|
||||
void osmesa_endOpenGL();
|
||||
bool osmesa_framebufferDidResizeCallback(bool isFBOSupported, size_t w, size_t h);
|
||||
|
||||
#endif // OSMESA_3DEMU_H
|
||||
|
Reference in New Issue
Block a user