16
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
#include <SDL_opengl.h>
19
#include "osal_opengl.h"
21
21
#define M64P_PLUGIN_PROTOTYPES 1
22
22
#include "m64p_plugin.h"
23
23
#include "Config.h"
24
24
#include "Debugger.h"
25
26
#include "OGLExtensions.h"
26
28
#include "OGLDebug.h"
27
29
#include "OGLGraphicsContext.h"
28
30
#include "TextureManager.h"
30
32
#include "version.h"
32
#include "liblinux/BMGLibPNG.h"
34
34
COGLGraphicsContext::COGLGraphicsContext() :
35
35
m_bSupportMultiTexture(false),
36
36
m_bSupportTextureEnvCombine(false),
110
110
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16);
113
113
/* Set the video mode */
114
114
m64p_video_mode ScreenMode = bWindowed ? M64VIDEO_WINDOWED : M64VIDEO_FULLSCREEN;
115
if (CoreVideo_SetVideoMode(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, colorBufferDepth, ScreenMode) != M64ERR_SUCCESS)
115
m64p_video_flags flags = M64VIDEOFLAG_SUPPORT_RESIZING;
116
if (CoreVideo_SetVideoMode(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, colorBufferDepth, ScreenMode, flags) != M64ERR_SUCCESS)
117
118
DebugMessage(M64MSG_ERROR, "Failed to set %i-bit video mode: %ix%i", colorBufferDepth, (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight);
118
119
CoreVideo_Quit();
134
135
if (iActual != depthBufferDepth)
135
136
DebugMessage(M64MSG_WARNING, "Failed to set GL_DEPTH_SIZE to %i. (it's %i)", depthBufferDepth, iActual);
137
139
/* Get function pointers to OpenGL extensions (blame Microsoft Windows for this) */
138
140
OGLExtensions_Init();
140
143
char caption[500];
141
144
sprintf(caption, "%s v%i.%i.%i", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION));
167
bool COGLGraphicsContext::ResizeInitialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed )
171
CGraphicsContext::Initialize(dwWidth, dwHeight, bWindowed );
173
int depthBufferDepth = options.OpenglDepthBufferSetting;
174
int colorBufferDepth = 32;
175
int bVerticalSync = windowSetting.bVerticalSync;
176
if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) colorBufferDepth = 16;
178
/* hard-coded attribute values */
179
const int iDOUBLEBUFFER = 1;
181
/* set opengl attributes */
182
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, iDOUBLEBUFFER);
183
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, bVerticalSync);
184
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, colorBufferDepth);
185
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, depthBufferDepth);
187
/* set multisampling */
188
if (options.multiSampling > 0)
190
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLEBUFFERS, 1);
191
if (options.multiSampling <= 2)
192
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 2);
193
else if (options.multiSampling <= 4)
194
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 4);
195
else if (options.multiSampling <= 8)
196
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 8);
198
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16);
201
/* Call Mupen64plus core Video Extension to resize the window, which will create a new OpenGL Context under SDL */
202
if (CoreVideo_ResizeWindow(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight) != M64ERR_SUCCESS)
204
DebugMessage(M64MSG_ERROR, "Failed to set %i-bit video mode: %ix%i", colorBufferDepth, (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight);
212
Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); // Clear buffers
214
Clear(CLEAR_COLOR_AND_DEPTH_BUFFER);
164
220
void COGLGraphicsContext::InitState(void)
166
222
m_pRenderStr = glGetString(GL_RENDERER);
218
281
OPENGL_CHECK_ERRORS;
220
283
glDepthRange(-1, 1);
285
#elif SDL_VIDEO_OPENGL_ES2
286
glDepthRangef(0.0f, 1.0f);
221
288
OPENGL_CHECK_ERRORS;
224
291
void COGLGraphicsContext::InitOGLExtension(void)
226
293
// important extension features, it is very bad not to have these feature
227
m_bSupportMultiTexture = IsExtensionSupported("GL_ARB_multitexture");
294
m_bSupportMultiTexture = IsExtensionSupported(OSAL_GL_ARB_MULTITEXTURE);
228
295
m_bSupportTextureEnvCombine = IsExtensionSupported("GL_EXT_texture_env_combine");
230
297
m_bSupportSeparateSpecularColor = IsExtensionSupported("GL_EXT_separate_specular_color");