Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-z64/src/rgl_osdep.cpp
2 views
1
/*
2
* z64
3
*
4
* Copyright (C) 2007 ziggy
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
**/
21
22
#include "rdp.h"
23
#include "rgl.h"
24
25
#include <SDL.h>
26
27
SDL_Surface *sdl_Screen;
28
int viewportOffset;
29
30
/* definitions of pointers to Core video extension functions */
31
extern ptr_VidExt_Init CoreVideo_Init;
32
extern ptr_VidExt_Quit CoreVideo_Quit;
33
extern ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes;
34
extern ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode;
35
extern ptr_VidExt_SetCaption CoreVideo_SetCaption;
36
extern ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen;
37
extern ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow;
38
extern ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress;
39
extern ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute;
40
extern ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers;
41
42
//int screen_width = 640, screen_height = 480;
43
int screen_width = 1024, screen_height = 768;
44
//int screen_width = 320, screen_height = 240;
45
46
int viewport_offset;
47
48
void rglSwapBuffers()
49
{
50
//TODO: if screenshot capabilities are ever implemented, replace the
51
//hard-coded 1 with a value indicating whether the screen has been redrawn
52
if (render_callback != NULL)
53
render_callback(1);
54
CoreVideo_GL_SwapBuffers();
55
return;
56
}
57
58
int rglOpenScreen()
59
{
60
if (CoreVideo_Init() != M64ERR_SUCCESS) {
61
rdp_log(M64MSG_ERROR, "Could not initialize video.");
62
return 0;
63
}
64
if (rglStatus == RGL_STATUS_WINDOWED) {
65
screen_width = rglSettings.resX;
66
screen_height = rglSettings.resY;
67
} else {
68
screen_width = rglSettings.fsResX;
69
screen_height = rglSettings.fsResY;
70
}
71
72
m64p_video_mode screen_mode = M64VIDEO_WINDOWED;
73
if (rglSettings.fullscreen)
74
screen_mode = M64VIDEO_FULLSCREEN;
75
76
viewportOffset = 0;
77
78
if (CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1) != M64ERR_SUCCESS ||
79
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32) != M64ERR_SUCCESS ||
80
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 24) != M64ERR_SUCCESS)
81
{
82
rdp_log(M64MSG_ERROR, "Could not set video attributes.");
83
return 0;
84
}
85
86
if (CoreVideo_SetVideoMode(screen_width, screen_height, 32, screen_mode, (m64p_video_flags) 0) != M64ERR_SUCCESS)
87
{
88
rdp_log(M64MSG_ERROR, "Could not set video mode.");
89
return 0;
90
}
91
92
CoreVideo_SetCaption("Z64gl");
93
94
rdp_init();
95
return 1;
96
}
97
98
void rglCloseScreen()
99
{
100
rglClose();
101
CoreVideo_Quit();
102
}
103
104