Path: blob/master/libmupen64plus/mupen64plus-video-z64/src/rgl_osdep.cpp
2 views
/*1* z642*3* Copyright (C) 2007 ziggy4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License along16* with this program; if not, write to the Free Software Foundation, Inc.,17* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.18*19**/2021#include "rdp.h"22#include "rgl.h"2324#include <SDL.h>2526SDL_Surface *sdl_Screen;27int viewportOffset;2829/* definitions of pointers to Core video extension functions */30extern ptr_VidExt_Init CoreVideo_Init;31extern ptr_VidExt_Quit CoreVideo_Quit;32extern ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes;33extern ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode;34extern ptr_VidExt_SetCaption CoreVideo_SetCaption;35extern ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen;36extern ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow;37extern ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress;38extern ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute;39extern ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers;4041//int screen_width = 640, screen_height = 480;42int screen_width = 1024, screen_height = 768;43//int screen_width = 320, screen_height = 240;4445int viewport_offset;4647void rglSwapBuffers()48{49//TODO: if screenshot capabilities are ever implemented, replace the50//hard-coded 1 with a value indicating whether the screen has been redrawn51if (render_callback != NULL)52render_callback(1);53CoreVideo_GL_SwapBuffers();54return;55}5657int rglOpenScreen()58{59if (CoreVideo_Init() != M64ERR_SUCCESS) {60rdp_log(M64MSG_ERROR, "Could not initialize video.");61return 0;62}63if (rglStatus == RGL_STATUS_WINDOWED) {64screen_width = rglSettings.resX;65screen_height = rglSettings.resY;66} else {67screen_width = rglSettings.fsResX;68screen_height = rglSettings.fsResY;69}7071m64p_video_mode screen_mode = M64VIDEO_WINDOWED;72if (rglSettings.fullscreen)73screen_mode = M64VIDEO_FULLSCREEN;7475viewportOffset = 0;7677if (CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1) != M64ERR_SUCCESS ||78CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32) != M64ERR_SUCCESS ||79CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 24) != M64ERR_SUCCESS)80{81rdp_log(M64MSG_ERROR, "Could not set video attributes.");82return 0;83}8485if (CoreVideo_SetVideoMode(screen_width, screen_height, 32, screen_mode, (m64p_video_flags) 0) != M64ERR_SUCCESS)86{87rdp_log(M64MSG_ERROR, "Could not set video mode.");88return 0;89}9091CoreVideo_SetCaption("Z64gl");9293rdp_init();94return 1;95}9697void rglCloseScreen()98{99rglClose();100CoreVideo_Quit();101}102103104