OpenGL support removed. Voodoo emulation updated to remove all OpenGL

calls and voodoo_ogl calls, leaving behind software rasterizer.
This commit is contained in:
Jonathan Campbell 2013-10-20 10:38:26 -07:00
parent ef487137fe
commit aca04918fe
14 changed files with 51 additions and 3214 deletions

View File

@ -89,9 +89,6 @@
/* Define to 1 to enable NE2000 ethernet passthrough, requires libpcap */
#undef C_NE2000
/* Define to 1 to use opengl display output support */
#undef C_OPENGL
/* Define to 1 if you have setpriority support */
#undef C_SET_PRIORITY

122
configure vendored
View File

@ -752,7 +752,6 @@ enable_dynrec
enable_fpu
enable_fpu_x86
enable_unaligned_memory
enable_opengl
with_dx_headers
with_dx_libs
enable_shaders
@ -1406,7 +1405,6 @@ Optional Features:
--disable-fpu-x86 Disable x86 assembly fpu core
--disable-unaligned-memory
Disable unaligned memory access
--disable-opengl Disable opengl support
--disable-shaders Disable d3d pixelshader support (which requires
libd3dx9)
@ -7201,126 +7199,6 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lGL" >&5
$as_echo_n "checking for main in -lGL... " >&6; }
if ${ac_cv_lib_GL_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lGL $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_GL_main=yes
else
ac_cv_lib_GL_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_GL_main" >&5
$as_echo "$ac_cv_lib_GL_main" >&6; }
if test "x$ac_cv_lib_GL_main" = xyes; then :
have_gl_lib=yes
else
have_gl_lib=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lopengl32" >&5
$as_echo_n "checking for main in -lopengl32... " >&6; }
if ${ac_cv_lib_opengl32_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lopengl32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_opengl32_main=yes
else
ac_cv_lib_opengl32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opengl32_main" >&5
$as_echo "$ac_cv_lib_opengl32_main" >&6; }
if test "x$ac_cv_lib_opengl32_main" = xyes; then :
have_opengl32_lib=yes
else
have_opengl32_lib=no
fi
ac_fn_c_check_header_mongrel "$LINENO" "GL/gl.h" "ac_cv_header_GL_gl_h" "$ac_includes_default"
if test "x$ac_cv_header_GL_gl_h" = xyes; then :
have_gl_h=yes
else
have_gl_h=no
fi
# Check whether --enable-opengl was given.
if test "${enable_opengl+set}" = set; then :
enableval=$enable_opengl;
else
enable_opengl=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether opengl display output will be enabled" >&5
$as_echo_n "checking whether opengl display output will be enabled... " >&6; }
if test x$enable_opengl = xyes; then
case "$host" in
*-*-darwin*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LIBS="$LIBS -framework OpenGL"
$as_echo "#define C_OPENGL 1" >>confdefs.h
;;
*)
if test x$have_gl_h = xyes -a x$have_gl_lib = xyes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LIBS="$LIBS -lGL"
$as_echo "#define C_OPENGL 1" >>confdefs.h
elif test x$have_gl_h = xyes -a x$have_opengl32_lib = xyes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LIBS="$LIBS -lopengl32"
$as_echo "#define C_OPENGL 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
;;
esac
fi
ac_fn_c_check_header_mongrel "$LINENO" "fluidsynth.h" "ac_cv_header_fluidsynth_h" "$ac_includes_default"
if test "x$ac_cv_header_fluidsynth_h" = xyes; then :
have_fluidsynth_h=yes

View File

@ -404,35 +404,6 @@ else
AC_MSG_RESULT(no)
fi
AH_TEMPLATE(C_OPENGL,[Define to 1 to use opengl display output support])
AC_CHECK_LIB(GL, main, have_gl_lib=yes, have_gl_lib=no , )
AC_CHECK_LIB(opengl32, main, have_opengl32_lib=yes,have_opengl32_lib=no , )
AC_CHECK_HEADER(GL/gl.h, have_gl_h=yes , have_gl_h=no , )
AC_ARG_ENABLE(opengl,AC_HELP_STRING([--disable-opengl],[Disable opengl support]),,enable_opengl=yes)
AC_MSG_CHECKING(whether opengl display output will be enabled)
if test x$enable_opengl = xyes; then
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(yes)
LIBS="$LIBS -framework OpenGL"
AC_DEFINE(C_OPENGL,1)
;;
*)
if test x$have_gl_h = xyes -a x$have_gl_lib = xyes ; then
AC_MSG_RESULT(yes)
LIBS="$LIBS -lGL"
AC_DEFINE(C_OPENGL,1)
elif test x$have_gl_h = xyes -a x$have_opengl32_lib = xyes ; then
AC_MSG_RESULT(yes)
LIBS="$LIBS -lopengl32"
AC_DEFINE(C_OPENGL,1)
else
AC_MSG_RESULT(no)
fi
;;
esac
fi
AH_TEMPLATE(C_FLUIDSYNTH,[Define to 1 to enable fluidsynth MIDI synthesis])
AC_CHECK_HEADER(fluidsynth.h,have_fluidsynth_h=yes,)
AC_CHECK_LIB(fluidsynth, new_fluid_synth, have_fluidsynth_lib=yes,,)

0
ogl Normal file
View File

View File

@ -776,9 +776,6 @@ void DOSBOX_Init(void) {
const char* voodoo_settings[] = {
"false",
"software",
#if C_OPENGL
"opengl",
#endif
"auto",
0
};

View File

@ -74,43 +74,6 @@
#define MAPPERFILE "mapper-" VERSION ".map"
//#define DISABLE_JOYSTICK
#if C_OPENGL
#include "SDL_opengl.h"
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GL_ARB_pixel_buffer_object
#define GL_ARB_pixel_buffer_object 1
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
#endif
#ifndef GL_ARB_vertex_buffer_object
#define GL_ARB_vertex_buffer_object 1
typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
#endif
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
PFNGLMAPBUFFERARBPROC glMapBufferARB = NULL;
PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB = NULL;
#endif //C_OPENGL
extern void UI_Init();
extern void UI_Run(bool);
@ -206,20 +169,6 @@ struct SDL_Block {
SCREEN_TYPES type;
SCREEN_TYPES want_type;
} desktop;
#if C_OPENGL
struct {
Bitu pitch;
void * framebuf;
GLuint buffer;
GLuint texture;
GLuint displaylist;
GLint max_texsize;
bool bilinear;
bool packed_pixel;
bool paletted_texture;
bool pixel_buffer_object;
} opengl;
#endif
struct {
SDL_Surface * surface;
#if (HAVE_DDRAW_H) && defined(WIN32)
@ -531,13 +480,6 @@ check_gotbpp:
flags|=GFX_SCALING;
flags&=~(GFX_CAN_8|GFX_CAN_15|GFX_CAN_16);
break;
#if C_OPENGL
case SCREEN_OPENGL:
if (flags & GFX_RGBONLY || !(flags&GFX_CAN_32)) goto check_surface;
flags|=GFX_SCALING;
flags&=~(GFX_CAN_8|GFX_CAN_15|GFX_CAN_16);
break;
#endif
#if (HAVE_D3D9_H) && defined(WIN32)
case SCREEN_DIRECT3D:
flags|=GFX_SCALING;
@ -905,101 +847,6 @@ dosurface:
retFlags = GFX_CAN_32 | GFX_SCALING | GFX_HARDWARE;
break;
}
#if C_OPENGL
case SCREEN_OPENGL:
{
GFX_ResetSDL();
if (sdl.opengl.pixel_buffer_object) {
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
if (sdl.opengl.buffer) glDeleteBuffersARB(1, &sdl.opengl.buffer);
} else if (sdl.opengl.framebuf) {
free(sdl.opengl.framebuf);
}
sdl.opengl.framebuf=0;
if (!(flags&GFX_CAN_32) || (flags & GFX_RGBONLY)) goto dosurface;
// SDLScreen_Reset();
int texsize=2 << int_log2(width > height ? width : height);
if (texsize>sdl.opengl.max_texsize) {
LOG_MSG("SDL:OPENGL:No support for texturesize of %d, falling back to surface",texsize);
goto dosurface;
}
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
#if SDL_VERSION_ATLEAST(1, 2, 11)
Section_prop * sec=static_cast<Section_prop *>(control->GetSection("vsync"));
if(sec) {
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, (!strcmp(sec->Get_string("vsyncmode"),"host"))?1:0 );
}
#endif
GFX_SetupSurfaceScaled(SDL_OPENGL|SDL_RESIZABLE,0);
if (!sdl.surface || sdl.surface->format->BitsPerPixel<15) {
LOG_MSG("SDL:OPENGL:Can't open drawing surface, are you running in 16bpp(or higher) mode?");
goto dosurface;
}
/* Create the texture and display list */
if (sdl.opengl.pixel_buffer_object) {
glGenBuffersARB(1, &sdl.opengl.buffer);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, sdl.opengl.buffer);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, width*height*4, NULL, GL_STREAM_DRAW_ARB);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
} else {
sdl.opengl.framebuf=malloc(width*height*4); //32 bit color
}
sdl.opengl.pitch=width*4;
glViewport(sdl.clip.x,sdl.clip.y,sdl.clip.w,sdl.clip.h);
glMatrixMode (GL_PROJECTION);
glDeleteTextures(1,&sdl.opengl.texture);
glGenTextures(1,&sdl.opengl.texture);
glBindTexture(GL_TEXTURE_2D,sdl.opengl.texture);
// No borders
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
if (sdl.opengl.bilinear) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texsize, texsize, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 0);
glClearColor (0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT);
glShadeModel (GL_FLAT);
glDisable (GL_DEPTH_TEST);
glDisable (GL_LIGHTING);
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
GLfloat tex_width=((GLfloat)(width)/(GLfloat)texsize);
GLfloat tex_height=((GLfloat)(height)/(GLfloat)texsize);
if (glIsList(sdl.opengl.displaylist)) glDeleteLists(sdl.opengl.displaylist, 1);
sdl.opengl.displaylist = glGenLists(1);
glNewList(sdl.opengl.displaylist, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, sdl.opengl.texture);
glBegin(GL_QUADS);
// lower left
glTexCoord2f(0,tex_height); glVertex2f(-1.0f,-1.0f);
// lower right
glTexCoord2f(tex_width,tex_height); glVertex2f(1.0f, -1.0f);
// upper right
glTexCoord2f(tex_width,0); glVertex2f(1.0f, 1.0f);
// upper left
glTexCoord2f(0,0); glVertex2f(-1.0f, 1.0f);
glEnd();
glEndList();
sdl.desktop.type=SCREEN_OPENGL;
retFlags = GFX_CAN_32 | GFX_SCALING;
if (sdl.opengl.pixel_buffer_object)
retFlags |= GFX_HARDWARE;
break;
}//OPENGL
#endif //C_OPENGL
#if (HAVE_D3D9_H) && defined(WIN32)
case SCREEN_DIRECT3D: {
// Calculate texture size
@ -1518,17 +1365,6 @@ bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch) {
pitch=*(sdl.overlay->pitches);
sdl.updating=true;
return true;
#if C_OPENGL
case SCREEN_OPENGL:
if(sdl.opengl.pixel_buffer_object) {
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, sdl.opengl.buffer);
pixels=(Bit8u *)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
} else
pixels=(Bit8u *)sdl.opengl.framebuf;
pitch=sdl.opengl.pitch;
sdl.updating=true;
return true;
#endif
#if (HAVE_D3D9_H) && defined(WIN32)
case SCREEN_DIRECT3D:
sdl.updating=d3d->LockTexture(pixels, pitch);
@ -1624,43 +1460,6 @@ void GFX_EndUpdate( const Bit16u *changedLines ) {
if(!menu.hidecycles && !sdl.desktop.fullscreen) frames++;
SDL_DisplayYUVOverlay(sdl.overlay,&sdl.clip);
break;
#if C_OPENGL
case SCREEN_OPENGL:
if (sdl.opengl.pixel_buffer_object) {
if(changedLines && (changedLines[0] == sdl.draw.height))
return;
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
glBindTexture(GL_TEXTURE_2D, sdl.opengl.texture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
sdl.draw.width, sdl.draw.height, GL_BGRA_EXT,
GL_UNSIGNED_INT_8_8_8_8_REV, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
glCallList(sdl.opengl.displaylist);
SDL_GL_SwapBuffers();
} else if (changedLines) {
if(changedLines[0] == sdl.draw.height)
return;
Bitu y = 0, index = 0;
glBindTexture(GL_TEXTURE_2D, sdl.opengl.texture);
while (y < sdl.draw.height) {
if (!(index & 1)) {
y += changedLines[index];
} else {
Bit8u *pixels = (Bit8u *)sdl.opengl.framebuf + y * sdl.opengl.pitch;
Bitu height = changedLines[index];
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, y,
sdl.draw.width, height, GL_BGRA_EXT,
GL_UNSIGNED_INT_8_8_8_8_REV, pixels );
y += height;
}
index++;
}
glCallList(sdl.opengl.displaylist);
}
if(!menu.hidecycles && !sdl.desktop.fullscreen) frames++;
SDL_GL_SwapBuffers();
break;
#endif
#if (HAVE_D3D9_H) && defined(WIN32)
case SCREEN_DIRECT3D:
if(!menu.hidecycles) frames++; //implemented
@ -2013,14 +1812,6 @@ static void GUI_StartUp(Section * sec) {
#endif
} else if (output == "overlay") {
sdl.desktop.want_type=SCREEN_OVERLAY;
#if C_OPENGL
} else if (output == "opengl") {
sdl.desktop.want_type=SCREEN_OPENGL;
sdl.opengl.bilinear=true;
} else if (output == "openglnb") {
sdl.desktop.want_type=SCREEN_OPENGL;
sdl.opengl.bilinear=false;
#endif
#if (HAVE_D3D9_H) && defined(WIN32)
} else if (output == "direct3d") {
sdl.desktop.want_type=SCREEN_DIRECT3D;
@ -2052,39 +1843,6 @@ static void GUI_StartUp(Section * sec) {
// sdl.overscan_color=section->Get_int("overscancolor");
sdl.overlay=0;
#if C_OPENGL
if(sdl.desktop.want_type==SCREEN_OPENGL){ /* OPENGL is requested */
sdl.surface=SDL_SetVideoMode(640,400,0,SDL_OPENGL);
if (sdl.surface == NULL) {
LOG_MSG("Could not initialize OpenGL, switching back to surface");
sdl.desktop.want_type=SCREEN_SURFACE;
} else {
sdl.opengl.buffer=0;
sdl.opengl.framebuf=0;
sdl.opengl.texture=0;
sdl.opengl.displaylist=0;
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &sdl.opengl.max_texsize);
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)SDL_GL_GetProcAddress("glGenBuffersARB");
glBindBufferARB = (PFNGLBINDBUFFERARBPROC)SDL_GL_GetProcAddress("glBindBufferARB");
glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)SDL_GL_GetProcAddress("glDeleteBuffersARB");
glBufferDataARB = (PFNGLBUFFERDATAARBPROC)SDL_GL_GetProcAddress("glBufferDataARB");
glMapBufferARB = (PFNGLMAPBUFFERARBPROC)SDL_GL_GetProcAddress("glMapBufferARB");
glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)SDL_GL_GetProcAddress("glUnmapBufferARB");
const char * gl_ext = (const char *)glGetString (GL_EXTENSIONS);
if(gl_ext && *gl_ext){
sdl.opengl.packed_pixel=(strstr(gl_ext,"EXT_packed_pixels") > 0);
sdl.opengl.paletted_texture=(strstr(gl_ext,"EXT_paletted_texture") > 0);
sdl.opengl.pixel_buffer_object=false;
//sdl.opengl.pixel_buffer_object=(strstr(gl_ext,"GL_ARB_pixel_buffer_object") >0 ) &&
// glGenBuffersARB && glBindBufferARB && glDeleteBuffersARB && glBufferDataARB &&
// glMapBufferARB && glUnmapBufferARB;
} else {
sdl.opengl.packed_pixel=sdl.opengl.paletted_texture=false;
}
}
} /* OPENGL is requested end */
#endif //OPENGL
/* Initialize screen for first time */
sdl.surface=SDL_SetVideoMode(640,400,0,SDL_RESIZABLE);
if (sdl.surface == NULL) E_Exit("Could not initialize video: %s",SDL_GetError());
@ -2769,36 +2527,6 @@ void* GetSetSDLValue(int isget, std::string target, void* setval) {
} else if (target == "desktop.want_type") {
if (isget) return (void*) sdl.desktop.want_type;
else sdl.desktop.want_type = *static_cast<SCREEN_TYPES*>(setval);
#if C_OPENGL
/*
} else if (target == "opengl.framebuf") {
if (isget) return (void*) sdl.opengl.framebuf;
else sdl.opengl.framebuf = setval;
} else if (target == "opengl.buffer") {
if (isget) return (void*) sdl.opengl.buffer;
else sdl.opengl.buffer = *static_cast<GLuint*>(setval);
} else if (target == "opengl.texture") {
if (isget) return (void*) sdl.opengl.texture;
else sdl.opengl.texture = *static_cast<GLuint*>(setval);
} else if (target == "opengl.max_texsize") {
if (isget) return (void*) sdl.opengl.max_texsize;
else sdl.opengl.max_texsize = *static_cast<GLint*>(setval);
*/
} else if (target == "opengl.bilinear") {
if (isget) return (void*) sdl.opengl.bilinear;
else sdl.opengl.bilinear = setval;
/*
} else if (target == "opengl.packed_pixel") {
if (isget) return (void*) sdl.opengl.packed_pixel;
else sdl.opengl.packed_pixel = setval;
} else if (target == "opengl.paletted_texture") {
if (isget) return (void*) sdl.opengl.paletted_texture;
else sdl.opengl.paletted_texture = setval;
} else if (target == "opengl.pixel_buffer_object") {
if (isget) return (void*) sdl.opengl.pixel_buffer_object;
else sdl.opengl.pixel_buffer_object = setval;
*/
#endif
/*
} else if (target == "surface") {
if (isget) return (void*) sdl.surface;
@ -3042,9 +2770,6 @@ void Config_Add_SDL() {
const char* outputs[] = {
"surface", "overlay",
#if C_OPENGL
"opengl", "openglnb", "openglhq",
#endif
#if (HAVE_DDRAW_H) && defined(WIN32)
"ddraw",
#endif
@ -3828,22 +3553,6 @@ struct SDL_Block sdl
SCREEN_TYPES type;
SCREEN_TYPES want_type;
} desktop;
#if C_OPENGL
// - struct system data
struct {
Bitu pitch;
void * framebuf;
GLuint texture;
GLuint displaylist;
GLint max_texsize;
bool bilinear;
bool packed_pixel;
bool paletted_texture;
#if defined(NVIDIA_PixelDataRange)
bool pixel_data_range;
#endif
} opengl;
#endif
// - struct system data
struct {

View File

@ -52,13 +52,8 @@ public:
emulation_type=0;
} else if (voodoo_type_str=="software") {
emulation_type=1;
#if C_OPENGL
} else if ((voodoo_type_str=="opengl") || (voodoo_type_str=="auto")) {
emulation_type=2;
#else
} else if (voodoo_type_str=="auto") {
emulation_type=1;
#endif
} else {
emulation_type=0;
}

View File

@ -791,8 +791,6 @@ struct _voodoo_state
bool send_config;
UINT32 tmu_config;
bool ogl;
bool ogl_dimchange;
bool clock_enabled;
bool output_on;
bool active;

View File

@ -685,11 +685,6 @@ void voodoo_swap_buffers(voodoo_state *v)
{
// if (LOG_VBLANK_SWAP) LOG(LOG_VOODOO,LOG_WARN)("--- swap_buffers @ %d\n", video_screen_get_vpos(v->screen));
if (v->ogl && v->active) {
voodoo_ogl_swap_buffer();
return;
}
/* keep a history of swap intervals */
v->reg[fbiSwapHistory].u = (v->reg[fbiSwapHistory].u << 4);
@ -1575,14 +1570,7 @@ void register_w(UINT32 offset, UINT32 data) {
if (v->type < VOODOO_2)
data &= 0x001fffff;
if (chips & 1) {
if (v->ogl && v->active && (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u)!=FBZMODE_Y_ORIGIN(data))) {
v->reg[fbzMode].u = data;
CPU_Core_Dyn_X86_SaveDHFPUState();
voodoo_ogl_set_window(v);
CPU_Core_Dyn_X86_RestoreDHFPUState();
} else {
v->reg[fbzMode].u = data;
}
v->reg[fbzMode].u = data;
}
break;
@ -1740,7 +1728,6 @@ void register_w(UINT32 offset, UINT32 data) {
if ((v->fbi.width != new_width) || (v->fbi.height != new_height)) {
v->fbi.width = new_width;
v->fbi.height = new_height;
v->ogl_dimchange = true;
}
// v->fbi.xoffs = hbp;
// v->fbi.yoffs = vbp;
@ -1907,11 +1894,6 @@ void register_w(UINT32 offset, UINT32 data) {
case clipLowYHighY:
case clipLeftRight:
if (chips & 1) v->reg[0x000 + regnum].u = data;
if (v->ogl) {
CPU_Core_Dyn_X86_SaveDHFPUState();
voodoo_ogl_clip_window(v);
CPU_Core_Dyn_X86_RestoreDHFPUState();
}
break;
/* these registers are referenced in the renderer; we must wait for pending work before changing */
@ -2203,37 +2185,25 @@ void lfb_w(UINT32 offset, UINT32 data, UINT32 mem_mask) {
bool has_rgb = (mask & LFB_RGB_PRESENT) > 0;
bool has_alpha = ((mask & LFB_ALPHA_PRESENT) > 0) && (FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u) > 0);
bool has_depth = ((mask & (LFB_DEPTH_PRESENT | LFB_DEPTH_PRESENT_MSW)) && !FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u));
if (v->ogl && v->active) {
if (has_rgb || has_alpha) {
// if enabling dithering: output is 565 not 888 anymore
// APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
voodoo_ogl_draw_pixel(x, scry+1, has_rgb, has_alpha, sr[pix], sg[pix], sb[pix], sa[pix]);
}
if (has_depth) {
#if 0 /* HOW DO WE DO THIS NON-OPENGL? */
voodoo_ogl_draw_z(x, scry+1, sw[pix]);
#endif
}
} else {
/* write to the RGB buffer */
if (has_rgb && bufoffs < destmax)
{
/* apply dithering and write to the screen */
APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
dest[bufoffs] = (UINT16)((sr[pix] << 11) | (sg[pix] << 5) | sb[pix]);
}
/* make sure we have an aux buffer to write to */
if (depth && bufoffs < depthmax)
{
/* write to the alpha buffer */
if (has_alpha)
depth[bufoffs] = (UINT16)sa[pix];
/* write to the RGB buffer */
if (has_rgb && bufoffs < destmax)
{
/* apply dithering and write to the screen */
APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
dest[bufoffs] = (UINT16)((sr[pix] << 11) | (sg[pix] << 5) | sb[pix]);
}
/* write to the depth buffer */
if (has_depth)
depth[bufoffs] = (UINT16)sw[pix];
}
/* make sure we have an aux buffer to write to */
if (depth && bufoffs < depthmax)
{
/* write to the alpha buffer */
if (has_alpha)
depth[bufoffs] = (UINT16)sa[pix];
/* write to the depth buffer */
if (has_depth)
depth[bufoffs] = (UINT16)sw[pix];
}
/* track pixel writes to the frame buffer regardless of mask */
@ -2293,7 +2263,6 @@ void lfb_w(UINT32 offset, UINT32 data, UINT32 mem_mask) {
}
/* pixel pipeline part 1 handles depth testing and stippling */
// TODO: in the v->ogl case this macro doesn't really work with depth testing
PIXEL_PIPELINE_BEGIN(v, x, y, v->reg[fbzColorPath].u, v->reg[fbzMode].u, iterz, iterw);
color.rgb.r = sr[pix];
@ -2514,23 +2483,10 @@ void lfb_w(UINT32 offset, UINT32 data, UINT32 mem_mask) {
if (FBZCP_CCA_INVERT_OUTPUT(v->reg[fbzColorPath].u))
a ^= 0xff;
if (v->ogl && v->active) {
if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u)) {
// APPLY_DITHER(FBZMODE, XX, DITHER_LOOKUP, r, g, b);
voodoo_ogl_draw_pixel_pipeline(x, scry+1, r, g, b);
}
/* if (depth && FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u)) {
if (FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u) == 0)
voodoo_ogl_draw_z(x, y, depthval&0xffff, depthval>>16);
// else
// depth[XX] = a;
} */
} else {
/* pixel pipeline part 2 handles color combine, fog, alpha, and final output */
PIXEL_PIPELINE_MODIFY(v, dither, dither4, x, v->reg[fbzMode].u, v->reg[fbzColorPath].u, v->reg[alphaMode].u, v->reg[fogMode].u, iterz, iterw, v->reg[zaColor]);
/* pixel pipeline part 2 handles color combine, fog, alpha, and final output */
PIXEL_PIPELINE_MODIFY(v, dither, dither4, x, v->reg[fbzMode].u, v->reg[fbzColorPath].u, v->reg[alphaMode].u, v->reg[fogMode].u, iterz, iterw, v->reg[zaColor]);
PIXEL_PIPELINE_FINISH(v, dither_lookup, x, dest, depth, v->reg[fbzMode].u);
}
PIXEL_PIPELINE_FINISH(v, dither_lookup, x, dest, depth, v->reg[fbzMode].u);
PIXEL_PIPELINE_END(stats);
}
@ -2622,11 +2578,6 @@ INT32 texture_w(UINT32 offset, UINT32 data) {
dest[BYTE4_XOR_LE(tbaseaddr + 3)] = (data >> 24) & 0xff;
changed = true;
}
if (changed && v->ogl && v->active) {
voodoo_ogl_texture_clear(t->lodoffset[lod],tmunum);
voodoo_ogl_texture_clear(t->lodoffset[t->lodmin],tmunum);
}
}
/* 16-bit texture case */
@ -2666,11 +2617,6 @@ INT32 texture_w(UINT32 offset, UINT32 data) {
dest[BYTE_XOR_LE(tbaseaddr + 1)] = (data >> 16) & 0xffff;
changed = true;
}
if (changed && v->ogl && v->active) {
voodoo_ogl_texture_clear(t->lodoffset[lod],tmunum);
voodoo_ogl_texture_clear(t->lodoffset[t->lodmin],tmunum);
}
}
return 0;
@ -2845,17 +2791,13 @@ UINT32 lfb_r(UINT32 offset)
if (LFBMODE_Y_ORIGIN(v->reg[lfbMode].u))
scry = (v->fbi.yorigin - y) & 0x3ff;
if (v->ogl && v->active) {
data = voodoo_ogl_read_pixel(x, scry+1);
} else {
/* advance pointers to the proper row */
bufoffs = scry * v->fbi.rowpixels + x;
if (bufoffs >= bufmax)
return 0xffffffff;
/* advance pointers to the proper row */
bufoffs = scry * v->fbi.rowpixels + x;
if (bufoffs >= bufmax)
return 0xffffffff;
/* compute the data */
data = buffer[bufoffs + 0] | (buffer[bufoffs + 1] << 16);
}
/* compute the data */
data = buffer[bufoffs + 0] | (buffer[bufoffs + 1] << 16);
/* word swapping */
if (LFBMODE_WORD_SWAP_READS(v->reg[lfbMode].u))
@ -2925,7 +2867,6 @@ void voodoo_init(int type) {
v->output_on = false;
v->clock_enabled = false;
v->ogl_dimchange = true;
v->send_config = false;
memset(v->dac.reg, 0, sizeof(v->dac.reg));
@ -3068,9 +3009,6 @@ void voodoo_init(int type) {
}
void voodoo_shutdown() {
if (v->ogl)
voodoo_ogl_shutdown(v);
if (v!=NULL) {
free(v->fbi.ram);
if (v->tmu[0].ram != NULL) {
@ -3156,21 +3094,17 @@ void fastfill(voodoo_state *v)
poly_extra_data *extra = new poly_extra_data;
if (v->ogl && v->active) {
voodoo_ogl_fastfill();
} else {
/* iterate over blocks of extents */
for (y = sy; y < ey; y += ARRAY_LENGTH(extents))
{
int count = MIN(ey - y, ARRAY_LENGTH(extents));
/* iterate over blocks of extents */
for (y = sy; y < ey; y += ARRAY_LENGTH(extents))
{
int count = MIN(ey - y, ARRAY_LENGTH(extents));
extra->state = v;
memcpy(extra->dither, dithermatrix, sizeof(extra->dither));
extra->state = v;
memcpy(extra->dither, dithermatrix, sizeof(extra->dither));
poly_render_triangle_custom(drawbuf, y, count, extents, extra);
}
poly_render_triangle_custom(drawbuf, y, count, extents, extra);
}
delete extra;
}
@ -3211,8 +3145,7 @@ void triangle(voodoo_state *v)
/* perform subpixel adjustments */
// ????????
if (!v->ogl && FBZCP_CCA_SUBPIXEL_ADJUST(v->reg[fbzColorPath].u))
// if (FBZCP_CCA_SUBPIXEL_ADJUST(v->reg[fbzColorPath].u))
if (FBZCP_CCA_SUBPIXEL_ADJUST(v->reg[fbzColorPath].u))
{
INT32 dx = 8 - (v->fbi.ax & 15);
INT32 dy = 8 - (v->fbi.ay & 15);
@ -3544,20 +3477,7 @@ void triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int texcount)
info->polys++;
if (palette_changed && v->ogl && v->active) {
voodoo_ogl_invalidate_paltex();
palette_changed = false;
}
if (v->ogl && v->active) {
if (extra->info==NULL) {
delete extra;
return;
}
voodoo_ogl_draw_triangle(extra);
} else {
poly_render_triangle(drawbuf, info->callback, &vert[0], &vert[1], &vert[2], extra);
}
poly_render_triangle(drawbuf, info->callback, &vert[0], &vert[1], &vert[2], extra);
delete extra;
}
@ -3719,45 +3639,19 @@ static void raster_fastfill(void *destbase, INT32 y, const poly_extent *extent,
void voodoo_vblank_flush(void) {
if (v->ogl)
voodoo_ogl_vblank_flush();
v->fbi.vblank_flush_pending=false;
}
void voodoo_set_window(void) {
if (v->ogl && v->active) {
voodoo_ogl_set_window(v);
}
}
void voodoo_leave(void) {
if (v->ogl) {
#if 0/*FIXME*/
voodoo_ogl_leave(true);
#endif
}
v->active = false;
}
void voodoo_activate(void) {
v->active = true;
if (v->ogl) {
if (voodoo_ogl_init(v)) {
voodoo_ogl_clear();
} else {
v->ogl = false;
LOG_MSG("VOODOO: acceleration disabled");
}
}
}
void voodoo_update_dimensions(void) {
v->ogl_dimchange = false;
if (v->ogl) {
#if 0/*FIXME*/
voodoo_ogl_update_dimensions();
#endif
}
}

View File

@ -114,29 +114,24 @@ static void Voodoo_VerticalTimer(Bitu /*val*/) {
if (v->fbi.vblank_flush_pending) {
voodoo_vblank_flush();
if (GFX_LazyFullscreenRequested()) {
v->ogl_dimchange = true;
/* removed */
}
}
if (!v->ogl) {
if (!RENDER_StartUpdate()) return; // frameskip
if (!RENDER_StartUpdate()) return; // frameskip
rectangle r;
r.min_x = r.min_y = 0;
r.max_x = (int)v->fbi.width;
r.max_y = (int)v->fbi.height;
rectangle r;
r.min_x = r.min_y = 0;
r.max_x = (int)v->fbi.width;
r.max_y = (int)v->fbi.height;
// draw all lines at once
Bit16u *viewbuf = (Bit16u *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
for(Bitu i = 0; i < v->fbi.height; i++) {
RENDER_DrawLine((Bit8u*) viewbuf);
viewbuf += v->fbi.rowpixels;
}
RENDER_EndUpdate(false);
} else {
// ???
voodoo_set_window();
// draw all lines at once
Bit16u *viewbuf = (Bit16u *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
for(Bitu i = 0; i < v->fbi.height; i++) {
RENDER_DrawLine((Bit8u*) viewbuf);
viewbuf += v->fbi.rowpixels;
}
RENDER_EndUpdate(false);
}
bool Voodoo_GetRetrace() {
@ -210,18 +205,13 @@ static void Voodoo_UpdateScreen(void) {
voodoo_activate();
if (v->ogl) {
v->ogl_dimchange = false;
} else {
RENDER_SetSize(v->fbi.width, v->fbi.height, 16, vdraw.vfreq, 4.0/3.0);
}
RENDER_SetSize(v->fbi.width, v->fbi.height, 16, vdraw.vfreq, 4.0/3.0);
Voodoo_VerticalTimer(0);
}
if ((v->clock_enabled && v->output_on) && v->ogl_dimchange) {
if (v->clock_enabled && v->output_on)
voodoo_update_dimensions();
}
vdraw.screen_update_requested = false;
}
@ -273,10 +263,6 @@ void Voodoo_Initialize(Bits emulation_type, Bits card_type, bool max_voodoomem)
voodoo_pagehandler = new Voodoo_PageHandler(0);
v = new voodoo_state;
v->ogl = false;
extern bool OpenGL_using(void);
if (emulation_type == 2) v->ogl = OpenGL_using();
vdraw.vfreq = 1000.0f/60.0f;
voodoo_init(board);

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2002-2013 The DOSBox Team
*
* This program 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 program 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; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DOSBOX_VOODOO_OPENGL_H
#define DOSBOX_VOODOO_OPENGL_H
#include <stdlib.h>
#include <math.h>
#include <map>
#include "dosbox.h"
#include "cross.h"
#if C_OPENGL
#include "voodoo_vogl.h"
#include "voodoo_types.h"
/* texture data */
struct ogl_texture_data {
GLuint texID;
bool enable;
};
/* triangle vertex map data */
struct ogl_vertex_map_data {
float sw,tw,z,w;
float s,t;
float lodblend;
};
/* triangle vertex data */
struct ogl_vertex_data {
float x,y,d,w,z;
float r,g,b,a;
float fogblend;
ogl_vertex_map_data m[2];
};
struct ogl_texmap {
bool valid_data;
bool valid_pal;
UINT32 format;
UINT32 current_id;
std::map<const UINT32, GLuint>* ids;
};
#endif
bool voodoo_ogl_init(voodoo_state *v);
void voodoo_ogl_leave(bool leavemode);
void voodoo_ogl_shutdown(voodoo_state *v);
void voodoo_ogl_set_window(voodoo_state *v);
void voodoo_ogl_swap_buffer(void);
void voodoo_ogl_vblank_flush(void);
void voodoo_ogl_update_dimensions(void);
void voodoo_ogl_clear(void);
void voodoo_ogl_fastfill(void);
void voodoo_ogl_clip_window(voodoo_state *v);
void voodoo_ogl_texture_clear(UINT32 texbase, int TMU);
void voodoo_ogl_invalidate_paltex(void);
void voodoo_ogl_draw_pixel(int x, int y, bool has_rgb, bool has_alpha, int r, int g, int b, int a);
void voodoo_ogl_draw_z(int x, int y, int z);
void voodoo_ogl_draw_pixel_pipeline(int x, int y, int r, int g, int b);
UINT32 voodoo_ogl_read_pixel(int x, int y);
void voodoo_ogl_draw_triangle(poly_extra_data *extra);
#endif

View File

@ -1,454 +0,0 @@
/*
* Copyright (C) 2002-2013 The DOSBox Team
*
* This program 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 program 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; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define GL_GLEXT_PROTOTYPES
#include <stdlib.h>
#include <math.h>
#include <map>
#include "dosbox.h"
#include "dos_inc.h"
#if C_OPENGL
#include "voodoo_vogl.h"
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL;
PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL;
PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL;
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL;
PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;
PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;
PFNGLUNIFORM1IARBPROC glUniform1iARB = NULL;
PFNGLUNIFORM1FARBPROC glUniform1fARB = NULL;
PFNGLUNIFORM2FARBPROC glUniform2fARB = NULL;
PFNGLUNIFORM3FARBPROC glUniform3fARB = NULL;
PFNGLUNIFORM4FARBPROC glUniform4fARB = NULL;
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL;
PFNGLDETACHOBJECTARBPROC glDetachObjectARB = NULL;
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL;
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = NULL;
PFNGLGETINFOLOGARBPROC glGetInfoLogARB = NULL;
PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT = NULL;
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB = NULL;
PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB = NULL;
static Bit32s opengl_version = -1;
static bool has_shaders = false;
static bool has_stencil = false;
static bool has_alpha = false;
static INT32 current_begin_mode = -1;
static Bit32s current_depth_mode = -1;
static Bit32s current_depth_func = -1;
static Bit32s current_alpha_enabled = -1;
static Bit32s current_src_rgb_fac = -1;
static Bit32s current_dst_rgb_fac = -1;
static Bit32s current_src_alpha_fac = -1;
static Bit32s current_dst_alpha_fac = -1;
static bool depth_masked = false;
static bool color_masked = false;
static bool alpha_masked = false;
// buffer read/write defaults are back-buffer for double buffered contexts
static bool draw_to_front_buffer = false;
static bool read_from_front_buffer = false;
void VOGL_Reset(void) {
opengl_version = -1;
has_shaders = false;
has_stencil = false;
has_alpha = false;
current_depth_mode=-1;
current_depth_func=-1;
current_alpha_enabled=-1;
current_src_rgb_fac=-1;
current_dst_rgb_fac=-1;
current_src_alpha_fac=-1;
current_dst_alpha_fac=-1;
depth_masked = false;
color_masked = false;
alpha_masked = false;
draw_to_front_buffer = false;
read_from_front_buffer = false;
}
void VOGL_InitVersion(void) {
opengl_version = -1;
char gl_verstr[16];
const GLubyte* gl_verstr_ub = glGetString(GL_VERSION);
strncpy(gl_verstr, (const char*)gl_verstr_ub, 16);
gl_verstr[15] = 0;
char* gl_ver_minor = strchr(gl_verstr, '.');
if (gl_ver_minor != NULL) {
gl_ver_minor++;
char* skip = strchr(gl_ver_minor, '.');
if (skip != NULL) *skip = 0;
}
int ogl_ver = 100;
if (gl_verstr[0] != 0) {
int major = 1;
int minor = 0;
if (strchr(gl_verstr, '.') != NULL) {
if (sscanf(gl_verstr,"%d.%d", &major, &minor) != 2) major = 0;
} else {
if (sscanf(gl_verstr, "%d", &major) != 1) major = 0;
}
if (major > 0) {
ogl_ver = major*100;
if (minor >= 0) {
if (minor < 10) ogl_ver += minor*10;
else ogl_ver += minor;
}
}
}
if (ogl_ver > 0) opengl_version = ogl_ver;
}
void VOGL_ClearShaderFunctions(void) {
glShaderSourceARB = NULL;
glCompileShaderARB = NULL;
glCreateProgramObjectARB = NULL;
glAttachObjectARB = NULL;
glLinkProgramARB = NULL;
glUseProgramObjectARB = NULL;
glUniform1iARB = NULL;
glUniform1fARB = NULL;
glUniform2fARB = NULL;
glUniform3fARB = NULL;
glUniform4fARB = NULL;
glGetUniformLocationARB = NULL;
glDetachObjectARB = NULL;
glDeleteObjectARB = NULL;
glGetObjectParameterivARB = NULL;
glGetInfoLogARB = NULL;
}
bool VOGL_Initialize(void) {
VOGL_ClearShaderFunctions();
VOGL_InitVersion();
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB");
if (!glActiveTextureARB) {
LOG_MSG("opengl: glActiveTextureARB extension not supported");
return false;
}
glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)SDL_GL_GetProcAddress("glMultiTexCoord4fARB");
if (!glMultiTexCoord4fARB) {
LOG_MSG("opengl: glMultiTexCoord4fARB extension not supported");
return false;
}
glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)SDL_GL_GetProcAddress("glMultiTexCoord4fvARB");
if (!glMultiTexCoord4fvARB) {
LOG_MSG("opengl: glMultiTexCoord4fvARB extension not supported");
return false;
}
glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)SDL_GL_GetProcAddress("glBlendFuncSeparateEXT");
if (!glBlendFuncSeparateEXT) {
LOG_MSG("opengl: glBlendFuncSeparateEXT extension not supported");
return false;
}
glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT");
if (!glGenerateMipmapEXT) {
LOG_MSG("opengl: glGenerateMipmapEXT extension not supported");
return false;
}
if (VOGL_CheckFeature(VOGL_ATLEAST_V20)) {
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
if (strstr(extensions, "GL_ARB_shader_objects") && strstr(extensions, "GL_ARB_vertex_shader") &&
strstr(extensions, "GL_ARB_fragment_shader")) {
glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB");
if (!glCreateShaderObjectARB) {
LOG_MSG("opengl: shader extensions not supported. Using fixed pipeline");
} else {
glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB");
if (!glShaderSourceARB) LOG_MSG("opengl: glShaderSourceARB extension not supported");
glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB");
if (!glCompileShaderARB) LOG_MSG("opengl: glCompileShaderARB extension not supported");
glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB");
if (!glCreateProgramObjectARB) LOG_MSG("opengl: glCreateProgramObjectARB extension not supported");
glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB");
if (!glAttachObjectARB) LOG_MSG("opengl: glAttachObjectARB extension not supported");
glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB");
if (!glLinkProgramARB) LOG_MSG("opengl: glLinkProgramARB extension not supported");
glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB");
if (!glUseProgramObjectARB) LOG_MSG("opengl: glUseProgramObjectARB extension not supported");
glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB");
if (!glUniform1iARB) LOG_MSG("opengl: glUniform1iARB extension not supported");
glUniform1fARB = (PFNGLUNIFORM1FARBPROC)SDL_GL_GetProcAddress("glUniform1fARB");
if (!glUniform1fARB) LOG_MSG("opengl: glUniform1fARB extension not supported");
glUniform2fARB = (PFNGLUNIFORM2FARBPROC)SDL_GL_GetProcAddress("glUniform2fARB");
if (!glUniform2fARB) LOG_MSG("opengl: glUniform2fARB extension not supported");
glUniform3fARB = (PFNGLUNIFORM3FARBPROC)SDL_GL_GetProcAddress("glUniform3fARB");
if (!glUniform3fARB) LOG_MSG("opengl: glUniform3fARB extension not supported");
glUniform4fARB = (PFNGLUNIFORM4FARBPROC)SDL_GL_GetProcAddress("glUniform4fARB");
if (!glUniform4fARB) LOG_MSG("opengl: glUniform4fARB extension not supported");
glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB");
if (!glGetUniformLocationARB) LOG_MSG("opengl: glGetUniformLocationARB extension not supported");
glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC)SDL_GL_GetProcAddress("glDetachObjectARB");
if (!glDetachObjectARB) LOG_MSG("opengl: glDetachObjectARB extension not supported");
glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB");
if (!glDeleteObjectARB) LOG_MSG("opengl: glDeleteObjectARB extension not supported");
glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB");
if (!glGetObjectParameterivARB) LOG_MSG("opengl: glGetObjectParameterivARB extension not supported");
glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB");
if (!glGetInfoLogARB) LOG_MSG("opengl: glGetInfoLogARB extension not supported");
glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetAttribLocationARB");
if (!glGetAttribLocationARB) LOG_MSG("opengl: glGetAttribLocationARB extension not supported");
glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)SDL_GL_GetProcAddress("glVertexAttrib1fARB");
if (!glVertexAttrib1fARB) LOG_MSG("opengl: glVertexAttrib1fARB extension not supported");
if (glShaderSourceARB && glCompileShaderARB && glCreateProgramObjectARB &&
glAttachObjectARB && glLinkProgramARB && glUseProgramObjectARB &&
glUniform1iARB && glUniform1fARB && glUniform2fARB && glUniform3fARB &&
glUniform4fARB && glGetUniformLocationARB && glDetachObjectARB &&
glDeleteObjectARB && glGetObjectParameterivARB && glGetInfoLogARB) {
VOGL_FlagFeature(VOGL_HAS_SHADERS);
// LOG_MSG("opengl: shader functionality enabled");
} else {
VOGL_ClearShaderFunctions();
}
}
}
}
return true;
}
bool VOGL_CheckFeature(Bit32u feat) {
switch (feat) {
case VOGL_ATLEAST_V20:
if (opengl_version >= 200) return true;
break;
case VOGL_ATLEAST_V21:
if (opengl_version >= 210) return true;
break;
case VOGL_ATLEAST_V30:
if (opengl_version >= 300) return true;
break;
case VOGL_HAS_SHADERS:
if (has_shaders) return true;
break;
case VOGL_HAS_STENCIL_BUFFER:
if (has_stencil) return true;
break;
case VOGL_HAS_ALPHA_PLANE:
if (has_alpha) return true;
break;
default:
LOG_MSG("opengl: unknown feature queried: %x",feat);
break;
}
return false;
}
void VOGL_FlagFeature(Bit32u feat) {
switch (feat) {
case VOGL_HAS_SHADERS:
has_shaders = true;
break;
case VOGL_HAS_STENCIL_BUFFER:
has_stencil = true;
break;
case VOGL_HAS_ALPHA_PLANE:
has_alpha = true;
break;
default:
LOG_MSG("opengl: unknown feature: %x",feat);
break;
}
}
void VOGL_BeginMode(INT32 new_mode) {
if (current_begin_mode > -1) {
if (new_mode != current_begin_mode) {
glEnd();
if (new_mode > -1) glBegin(new_mode);
current_begin_mode = new_mode;
}
} else {
if (new_mode > -1) {
glBegin(new_mode);
current_begin_mode = new_mode;
}
}
}
void VOGL_ClearBeginMode(void) {
if (current_begin_mode > -1) {
glEnd();
current_begin_mode = -1;
}
}
void VOGL_SetDepthMode(Bit32s mode, Bit32s func) {
if (current_depth_mode!=mode) {
if (mode!=0) {
VOGL_ClearBeginMode();
glEnable(GL_DEPTH_TEST);
current_depth_mode=1;
if (current_depth_func!=func) {
glDepthFunc(GL_NEVER+func);
current_depth_func=func;
}
} else {
VOGL_ClearBeginMode();
glDisable(GL_DEPTH_TEST);
current_depth_mode=0;
}
} else {
if ((mode!=0) && (current_depth_func!=func)) {
VOGL_ClearBeginMode();
glDepthFunc(GL_NEVER+func);
current_depth_func=func;
}
}
}
void VOGL_SetAlphaMode(Bit32s enabled_mode,GLuint src_rgb_fac,GLuint dst_rgb_fac,
GLuint src_alpha_fac,GLuint dst_alpha_fac) {
if (current_alpha_enabled!=enabled_mode) {
VOGL_ClearBeginMode();
if (enabled_mode!=0) {
glEnable(GL_BLEND);
current_alpha_enabled=1;
if ((current_src_rgb_fac!=(Bit32s)src_rgb_fac) || (current_dst_rgb_fac!=(Bit32s)dst_rgb_fac) ||
(current_src_alpha_fac!=(Bit32s)src_alpha_fac) || (current_dst_alpha_fac!=(Bit32s)dst_alpha_fac)) {
glBlendFuncSeparateEXT(src_rgb_fac, dst_rgb_fac, src_alpha_fac, dst_alpha_fac);
current_src_rgb_fac=(Bit32s)src_rgb_fac;
current_dst_rgb_fac=(Bit32s)dst_rgb_fac;
current_src_alpha_fac=(Bit32s)src_alpha_fac;
current_dst_alpha_fac=(Bit32s)dst_alpha_fac;
}
} else {
glDisable(GL_BLEND);
current_alpha_enabled=0;
}
} else {
if (current_alpha_enabled!=0) {
if ((current_src_rgb_fac!=(Bit32s)src_rgb_fac) || (current_dst_rgb_fac!=(Bit32s)dst_rgb_fac) ||
(current_src_alpha_fac!=(Bit32s)src_alpha_fac) || (current_dst_alpha_fac!=(Bit32s)dst_alpha_fac)) {
VOGL_ClearBeginMode();
glBlendFuncSeparateEXT(src_rgb_fac, dst_rgb_fac, src_alpha_fac, dst_alpha_fac);
current_src_rgb_fac=(Bit32s)src_rgb_fac;
current_dst_rgb_fac=(Bit32s)dst_rgb_fac;
current_src_alpha_fac=(Bit32s)src_alpha_fac;
current_dst_alpha_fac=(Bit32s)dst_alpha_fac;
}
}
}
}
void VOGL_SetDepthMaskMode(bool masked) {
if (depth_masked!=masked) {
VOGL_ClearBeginMode();
if (masked) {
glDepthMask(GL_TRUE);
depth_masked=true;
} else {
glDepthMask(GL_FALSE);
depth_masked=false;
}
}
}
void VOGL_SetColorMaskMode(bool cmasked, bool amasked) {
if ((color_masked!=cmasked) || (alpha_masked!=amasked)) {
color_masked=cmasked;
alpha_masked=amasked;
GLboolean cm = (color_masked ? GL_TRUE : GL_FALSE);
GLboolean am = (alpha_masked ? GL_TRUE : GL_FALSE);
glColorMask(cm,cm,cm,am);
}
}
void VOGL_SetDrawMode(bool front_draw) {
if (draw_to_front_buffer!=front_draw) {
VOGL_ClearBeginMode();
if (front_draw) glDrawBuffer(GL_FRONT);
else glDrawBuffer(GL_BACK);
draw_to_front_buffer=front_draw;
}
}
void VOGL_SetReadMode(bool front_read) {
VOGL_ClearBeginMode();
if (read_from_front_buffer!=front_read) {
if (front_read) glReadBuffer(GL_FRONT);
else glReadBuffer(GL_BACK);
read_from_front_buffer=front_read;
}
}
#endif

View File

@ -1,126 +0,0 @@
/*
* Copyright (C) 2002-2013 The DOSBox Team
*
* This program 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 program 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; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DOSBOX_VOODOO_VOGL_H
#define DOSBOX_VOODOO_VOGL_H
#define GL_GLEXT_PROTOTYPES
#include "SDL.h"
#include "SDL_opengl.h"
/* opengl extensions */
#if 1
#include <GL/glext.h>
#else
extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
extern PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB;
extern PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB;
extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
extern PFNGLUNIFORM2FARBPROC glUniform2fARB;
extern PFNGLUNIFORM3FARBPROC glUniform3fARB;
extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
extern PFNGLDETACHOBJECTARBPROC glDetachObjectARB;
extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateExt;
extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapExt;
extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
extern PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB;
#endif
#define VOGL_ATLEAST_V20 0x00000001
#define VOGL_ATLEAST_V21 0x00000002
#define VOGL_ATLEAST_V30 0x00000004
#define VOGL_HAS_SHADERS 0x00000010
#define VOGL_HAS_STENCIL_BUFFER 0x00000100
#define VOGL_HAS_ALPHA_PLANE 0x00000200
static const GLuint ogl_sfactor[16] = {
GL_ZERO,
GL_SRC_ALPHA,
GL_DST_COLOR,
GL_DST_ALPHA,
GL_ONE,
GL_ONE_MINUS_SRC_ALPHA,
GL_ONE_MINUS_DST_COLOR,
GL_ONE_MINUS_DST_ALPHA,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_SRC_ALPHA_SATURATE
};
static const GLuint ogl_dfactor[16] = {
GL_ZERO,
GL_SRC_ALPHA,
GL_SRC_COLOR,
GL_DST_ALPHA,
GL_ONE,
GL_ONE_MINUS_SRC_ALPHA,
GL_ONE_MINUS_SRC_COLOR,
GL_ONE_MINUS_DST_ALPHA,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_ZERO,
GL_SRC_COLOR /* A_COLORBEFOREFOG */
};
void VOGL_Reset(void);
bool VOGL_Initialize(void);
bool VOGL_CheckFeature(Bit32u feat);
void VOGL_FlagFeature(Bit32u feat);
void VOGL_BeginMode(INT32 new_mode);
void VOGL_ClearBeginMode(void);
void VOGL_SetDepthMode(Bit32s mode, Bit32s func);
void VOGL_SetAlphaMode(Bit32s enabled_mode,GLuint src_rgb_fac,GLuint dst_rgb_fac,
GLuint src_alpha_fac,GLuint dst_alpha_fac);
void VOGL_SetDepthMaskMode(bool masked);
void VOGL_SetColorMaskMode(bool cmasked, bool amasked);
void VOGL_SetDrawMode(bool front_draw);
void VOGL_SetReadMode(bool front_read);
#endif