void ESVideoPlatform::SetMode (uint32_t aIndex) { if(VideoMode != aIndex) { //Kill old device psglMakeCurrent(0, 0); psglDestroyDevice(Device); //Create new device static const uint32_t width[] = {0, 1920, 1280, 0, 720, 720}; static const uint32_t height[] = {0, 1080, 720, 0, 480, 576}; PSGLdeviceParameters params; memset(¶ms, 0, sizeof(params)); params.enable = PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.depthFormat = GL_NONE; params.width = (aIndex == 0) ? DefaultWidth : width[aIndex]; params.height = (aIndex == 0) ? DefaultHeight : height[aIndex]; Device = psglCreateDeviceExtended(¶ms); psglMakeCurrent(Context, Device); //Get parameters uint32_t renderWidth, renderHeight; psglGetRenderBufferDimensions(Device, &renderWidth, &renderHeight); ESVideo::SetScreenSize(renderWidth, renderHeight); } VideoMode = aIndex; }
void ESVideo::Initialize () { //Init PSGL PSGLinitOptions initOpts = {PSGL_INIT_MAX_SPUS | PSGL_INIT_HOST_MEMORY_SIZE, 1, false, 0, 0, 0, 0, 32 * 1024 * 1024}; psglInit(&initOpts); Device = psglCreateDeviceAuto(GL_ARGB_SCE, GL_NONE, GL_MULTISAMPLING_NONE_SCE); Context = psglCreateContext(); psglMakeCurrent(Context, Device); psglResetCurrentContext(); //Get Screen Info psglGetRenderBufferDimensions(Device, &ScreenWidth, &ScreenHeight); WideScreen = psglGetDeviceAspectRatio(Device) > 1.5f; glViewport(0, 0, GetScreenWidth(), GetScreenHeight()); //Some settings OpenGLHelp::InitializeState(); glEnable(GL_VSYNC_SCE); // Setup vertex buffer VertexBuffer = (GLfloat*)memalign(128, VertexBufferCount * VertexSize * sizeof(GLfloat)); GLShader::ApplyVertexBuffer(VertexBuffer); //Texture for FillRectangle FillerTexture = new Texture(2, 2); FillerTexture->Clear(0xFFFFFFFF); }
void GraphicsManager::InitialisePSGL() { // Initialise the PSGL functions to use for the game psglInit(NULL); device = psglCreateDeviceAuto(GL_ARGB_SCE,GL_DEPTH_COMPONENT24,GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE); if (!device) { printf("!! Failed to init the device \n!! Exiting Program \n" ); exit(1); } context = psglCreateContext(); if (!context) { fprintf(stderr, "Error creating PSGL context\n"); exit(1); } psglMakeCurrent(context, device); psglResetCurrentContext(); psglLoadShaderLibrary(SYS_APP_HOME"/shaders.bin"); } // InitialisePSGL()
void ESVideoPlatform::Initialize (uint32_t& aWidth, uint32_t& aHeight) { //Init PSGL PSGLinitOptions initOpts = {PSGL_INIT_MAX_SPUS | PSGL_INIT_HOST_MEMORY_SIZE, 1, false, 0, 0, 0, 0, 32 * 1024 * 1024}; psglInit(&initOpts); Device = psglCreateDeviceAuto(GL_ARGB_SCE, GL_NONE, GL_MULTISAMPLING_NONE_SCE); Context = psglCreateContext(); psglMakeCurrent(Context, Device); psglResetCurrentContext(); //Get Screen Info psglGetRenderBufferDimensions(Device, &aWidth, &aHeight); psglGetDeviceDimensions(Device, &DefaultWidth, &DefaultHeight); // WideScreen = psglGetDeviceAspectRatio(Device) > 1.5f; //Some settings glEnable(GL_VSYNC_SCE); VSyncOn = true; //Init shaders cgRTCgcInit(); LibESGL::Presenter::Initialize(); }
bool CapApp::onInit(int argc, char* argv[]) { (void)argc; (void)argv; // ---------------------------------------------- // FTP cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellNetCtlInit(); cellSysmoduleLoadModule(CELL_SYSMODULE_HTTP); sys_net_initialize_network(); ftp_on(); // Load settings... if(!iniRead()) { iniWrite(); // create settings file... } cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); cellScreenShotEnable(); InputInit(); while(!videoOutIsReady()) { // ... } PSGLinitOptions options = { enable: PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS, maxSPUs: 1, initializeSPUs: GL_FALSE, persistentMemorySize: 0, transientMemorySize: 0, errorConsole: 0, fifoSize: 0, hostMemorySize: 128* 1024*1024, // 128 mbs for host memory }; #if CELL_SDK_VERSION < 0x340000 options.enable |= PSGL_INIT_HOST_MEMORY_SIZE; #endif // Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL sys_spu_initialize(6, 1); psglInit(&options); const unsigned int resolutions[] = { CELL_VIDEO_OUT_RESOLUTION_1080, CELL_VIDEO_OUT_RESOLUTION_960x1080, CELL_VIDEO_OUT_RESOLUTION_720, CELL_VIDEO_OUT_RESOLUTION_480 }; const int numResolutions = sizeof(resolutions) / sizeof(resolutions[0]); int bestResolution = chooseBestResolution(resolutions,numResolutions); getResolutionWidthHeight(bestResolution, deviceWidth, deviceHeight); if(bestResolution) { PSGLdeviceParameters params; params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; params.colorFormat = GL_ARGB_SCE; params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = deviceWidth; params.height = deviceHeight; device = psglCreateDeviceExtended(¶ms); context = psglCreateContext(); psglMakeCurrent(context, device); psglResetCurrentContext(); initGraphics(); if( cellSysutilRegisterCallback( 0, callback_sysutil_exit, NULL ) < 0 ) { //... } dbgFontInit(); fbaRL = new c_fbaRL(); while(bRun) { onRender(); onUpdate(); cellSysutilCheckCallback(); } } else { // resolution error... } ftp_off(); onShutdown(); return false; } void CapApp::onRender() { if(fbaRL) { fbaRL->DlgDisplayFrame(); } // get render target buffer dimensions and set viewport psglGetRenderBufferDimensions(device,&app.renderWidth,&app.renderHeight); glViewport(0, 0, app.renderWidth, app.renderHeight); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(fbaRL) { fbaRL->RenderBackground(); } if(fbaRL) { fbaRL->nFrameStep = 0; fbaRL->DisplayFrame(); } if(fbaRL) { fbaRL->nFrameStep = 1; fbaRL->DisplayFrame(); } dbgFontDraw(); psglSwap(); } bool CapApp::onUpdate() { if(!mFrame) mFrame = 0; mFrame++; InputFrameStart(); if(fbaRL) fbaRL->InputFrame(); InputFrameEnd(); return true; } void CapApp::onShutdown() { iniWrite(); // save settings if(context) psglDestroyContext(context); if(device) psglDestroyDevice(device); InputExit(); psglExit(); }
//----------------------------------------------------------------------------- // Purpose: Initialize the PSGL rendering interfaces and default state //----------------------------------------------------------------------------- bool CGameEnginePS3::BInitializePSGL() { // Clear any errors glGetError(); // First, initialize PSGL // Note that since we initialized the SPUs ourselves earlier we should // make sure that PSGL doesn't try to do so as well. PSGLinitOptions initOpts = { enable: PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS | PSGL_INIT_HOST_MEMORY_SIZE, maxSPUs: 1, initializeSPUs: false, // We're not specifying values for these options, the code is only here // to alleviate compiler warnings. persistentMemorySize: 0, transientMemorySize: 0, errorConsole: 0, fifoSize: 0, hostMemorySize: 128*1024*1024, // 128 mbs for host memory }; psglInit( &initOpts ); m_pPSGLDevice = psglCreateDeviceAuto( GL_ARGB_SCE, GL_DEPTH_COMPONENT24, GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE ); if ( !m_pPSGLDevice ) { OutputDebugString( "!! Failed to init the device \n" ); return false; } GLuint width, height; psglGetDeviceDimensions( m_pPSGLDevice, &width, &height ); m_nWindowHeight = height; m_nWindowWidth = width; // Now create a PSGL context m_pPSGLContext = psglCreateContext(); if ( !m_pPSGLContext ) { OutputDebugString( "Error creating PSGL context\n" ); return false; } // Make this context current for the device we initialized psglMakeCurrent( m_pPSGLContext, m_pPSGLDevice ); // Since we're using fixed function stuff (i.e. not using our own shader // yet), we need to load shaders.bin that contains the fixed function // shaders. psglLoadShaderLibrary( SYS_APP_HOME"/shaders.bin" ); // Reset the context psglResetCurrentContext(); glViewport( 0, 0, width, height ); glScissor( 0, 0, width, height ); glClearDepthf(1.0f); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glEnable( GL_VSYNC_SCE ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDisable( GL_CULL_FACE ); glDisable( GL_ALPHA_TEST ); glDisable( GL_STENCIL_TEST ); glDisable( GL_SCISSOR_TEST ); glDisable( GL_LIGHTING ); glDisable( GL_DEPTH_TEST ); glDisable( GL_FOG ); glDepthMask( GL_FALSE ); // We always need these two glEnableClientState( GL_COLOR_ARRAY ); glEnableClientState( GL_VERTEX_ARRAY ); // This we'll enable as needed glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrthof( 0, width, height, 0, -1.0f, 1.0f ); glTranslatef( 0, 0, 0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0, 0, 0 ); glMatrixMode( GL_TEXTURE ); glLoadIdentity(); glTranslatef( 0, 0, 0 ); glDepthRangef( 0.0f, 1.0f ); // PSGL doesn't clear the screen on startup, so let's do that here. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); psglSwap(); return true; } //----------------------------------------------------------------------------- // Purpose: Initialize the debug font library //----------------------------------------------------------------------------- bool CGameEnginePS3::BInitializeCellDbgFont() { // initialize debug font library, then open 2 consoles CellDbgFontConfig cfg; cfg.bufSize = 4096; cfg.screenWidth = m_nWindowWidth; cfg.screenHeight = m_nWindowHeight; if ( cellDbgFontInit( &cfg) != CELL_OK ) { OutputDebugString( "Failed initializing CellDbgFont\n" ); } CellDbgFontConsoleConfig ccfg0; ccfg0.posLeft = 0.18f; ccfg0.posTop = 0.82f; ccfg0.cnsWidth = 128; ccfg0.cnsHeight = 8; ccfg0.scale = 0.65f; ccfg0.color = 0xff0080ff; // ABGR -> orange g_DbgFontConsoleID = m_DbgFontConsoleID = cellDbgFontConsoleOpen( &ccfg0 ); if ( g_DbgFontConsoleID < 0 ) { OutputDebugString( "Failed creating CellDbgFontConsole\n" ); } return true; }
static bool gfx_ctx_init(void *data) { (void)data; #if defined(HAVE_PSGL) PSGLinitOptions options = { .enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS, .maxSPUs = 1, .initializeSPUs = GL_FALSE, }; // Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL sys_spu_initialize(6, 1); psglInit(&options); PSGLdeviceParameters params; params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; params.colorFormat = GL_ARGB_SCE; params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; if (g_extern.lifecycle_state & (1ULL << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) { RARCH_LOG("[PSGL Context]: Setting triple buffering.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_BUFFERING_MODE; params.bufferingMode = PSGL_BUFFERING_MODE_TRIPLE; } if (g_extern.console.screen.resolutions.current.id) { params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = gfx_ctx_get_resolution_width(g_extern.console.screen.resolutions.current.id); params.height = gfx_ctx_get_resolution_height(g_extern.console.screen.resolutions.current.id); if (params.width == 720 && params.height == 576) { RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n"); g_extern.lifecycle_state |= (1ULL << MODE_VIDEO_PAL_ENABLE); } else g_extern.lifecycle_state &= ~(1ULL << MODE_VIDEO_PAL_ENABLE); } if (g_extern.lifecycle_state & (1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE)) { RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE; params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE; params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE; params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN; } gl_device = psglCreateDeviceExtended(¶ms); gl_context = psglCreateContext(); psglMakeCurrent(gl_context, gl_device); psglResetCurrentContext(); #endif g_extern.console.screen.pal_enable = cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); gfx_ctx_get_available_resolutions(); return true; } static bool gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { (void)data; return true; }
static void *gfx_ctx_ps3_init(void *video_driver) { #ifdef HAVE_PSGL PSGLdeviceParameters params; PSGLinitOptions options; #endif global_t *global = global_get_ptr(); gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*) calloc(1, sizeof(gfx_ctx_ps3_data_t)); (void)video_driver; (void)global; if (!ps3) return NULL; #if defined(HAVE_PSGL) options.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS; options.maxSPUs = 1; options.initializeSPUs = GL_FALSE; /* Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL. */ sys_spu_initialize(6, 1); psglInit(&options); params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; params.colorFormat = GL_ARGB_SCE; params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; if (global->console.screen.resolutions.current.id) { params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; gfx_ctx_ps3_get_resolution( global->console.screen.resolutions.current.id, ¶ms.width, ¶ms.height); global->console.screen.pal_enable = false; if (params.width == 720 && params.height == 576) { RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n"); global->console.screen.pal_enable = true; } } if (global->console.screen.pal60_enable) { RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE; params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE; params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE; params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN; } ps3->gl_device = psglCreateDeviceExtended(¶ms); ps3->gl_context = psglCreateContext(); psglMakeCurrent(ps3->gl_context, ps3->gl_device); psglResetCurrentContext(); #endif global->console.screen.pal_enable = cellVideoOutGetResolutionAvailability( CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); gfx_ctx_ps3_get_available_resolutions(); return ps3; }
void PS3Graphics::PSGLInitDevice(uint32_t resolutionId, uint16_t pal60Hz/*, uint16_t tripleBuffering*/) { PSGLdeviceParameters params; PSGLinitOptions options; options.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS; #if CELL_SDK_VERSION == 0x340001 options.enable |= PSGL_INIT_TRANSIENT_MEMORY_SIZE; #else options.enable |= PSGL_INIT_HOST_MEMORY_SIZE; #endif options.maxSPUs = 1; options.initializeSPUs = GL_FALSE; options.persistentMemorySize = 0; options.transientMemorySize = 0; options.errorConsole = 0; options.fifoSize = 0; options.hostMemorySize = 0; psglInit(&options); params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | \ PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | \ PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; params.colorFormat = GL_ARGB_SCE; params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; /* if (tripleBuffering) { params.enable |= PSGL_DEVICE_PARAMETERS_BUFFERING_MODE; params.bufferingMode = PSGL_BUFFERING_MODE_TRIPLE; } */ if (pal60Hz) { params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE; params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE; params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE; params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN; } if (resolutionId) { //Resolution setting CellVideoOutResolution resolution; cellVideoOutGetResolution(resolutionId, &resolution); params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = resolution.width; params.height = resolution.height; m_currentResolutionId = resolutionId; } psgl_device = psglCreateDeviceExtended(¶ms); // Get the dimensions of the screen in question, and do stuff with it :) psglGetDeviceDimensions(psgl_device, &gl_width, &gl_height); // Create a context and bind it to the current display. psgl_context = psglCreateContext(); /* if(m_viewport_width == 0) m_viewport_width = gl_width; if(m_viewport_height == 0) m_viewport_height = gl_height; */ psglMakeCurrent(psgl_context, psgl_device); psglResetCurrentContext(); }