bool GuiFormCtrl::resize(const Point2I &newPosition, const Point2I &newExtent) { if( !Parent::resize(newPosition, newExtent) ) return false; if( !mAwake || !mProfile->mBitmapArrayRects.size() ) return false; // Should the caption be modified because the title bar is too small? S32 textWidth = mProfile->mFont->getStrWidth(mCaption); S32 newTextArea = getWidth() - mThumbSize.x - mProfile->mBitmapArrayRects[4].extent.x; if(newTextArea < textWidth) { static char buf[256]; mUseSmallCaption = true; mSmallCaption = StringTable->insert(""); S32 strlen = dStrlen((const char*)mCaption); for(S32 i=strlen; i>=0; --i) { dStrcpy(buf, ""); dStrncat(buf, (const char*)mCaption, i); dStrcat(buf, "..."); textWidth = mProfile->mFont->getStrWidth(buf); if(textWidth < newTextArea) { mSmallCaption = StringTable->insert(buf, true); break; } } } else { mUseSmallCaption = false; } onResize_callback(); return true; }
//----------------------------------------------------------------------------- // Enumerate D3D adapters //----------------------------------------------------------------------------- void GFXPCD3D9Device::enumerateAdapters( Vector<GFXAdapter*> &adapterList ) { // Grab a D3D9 handle here to first get the D3D9 devices LPDIRECT3D9 d3d9; LPDIRECT3D9EX d3d9ex; createDirect3D9( d3d9, d3d9ex); // If we could not create the d3d9 object then either the system // is corrupt or they need to update the directx runtime. if ( !d3d9 ) { Con::errorf( "Unsupported DirectX version!" ); Platform::messageBox( Con::getVariable( "$appName" ), "DirectX could not be started!\r\n" "Please be sure you have the latest version of DirectX installed.", MBOk, MIStop ); Platform::forceShutdown( -1 ); } for( U32 adapterIndex = 0; adapterIndex < d3d9->GetAdapterCount(); adapterIndex++ ) { GFXAdapter *toAdd = new GFXAdapter; toAdd->mType = Direct3D9; toAdd->mIndex = adapterIndex; toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance; // Grab the shader model. D3DCAPS9 caps; d3d9->GetDeviceCaps(adapterIndex, D3DDEVTYPE_HAL, &caps); U8 *pxPtr = (U8*) &caps.PixelShaderVersion; toAdd->mShaderModel = pxPtr[1] + pxPtr[0] * 0.1; // Get the device description string. D3DADAPTER_IDENTIFIER9 temp; d3d9->GetAdapterIdentifier( adapterIndex, NULL, &temp ); // The NULL is the flags which deal with WHQL dStrncpy(toAdd->mName, temp.Description, GFXAdapter::MaxAdapterNameLen); dStrncat(toAdd->mName, " (D3D9)", GFXAdapter::MaxAdapterNameLen); // And the output display device name dStrncpy(toAdd->mOutputName, temp.DeviceName, GFXAdapter::MaxAdapterNameLen); // Video mode enumeration. Vector<D3DFORMAT> formats( __FILE__, __LINE__ ); formats.push_back( D3DFMT_R5G6B5 ); // D3DFMT_R5G6B5 - 16bit format formats.push_back( D3DFMT_X8R8G8B8 ); // D3DFMT_X8R8G8B8 - 32bit format for( S32 i = 0; i < formats.size(); i++ ) { DWORD MaxSampleQualities; d3d9->CheckDeviceMultiSampleType(adapterIndex, D3DDEVTYPE_HAL, formats[i], FALSE, D3DMULTISAMPLE_NONMASKABLE, &MaxSampleQualities); for( U32 j = 0; j < d3d9->GetAdapterModeCount( adapterIndex, formats[i] ); j++ ) { D3DDISPLAYMODE mode; d3d9->EnumAdapterModes( adapterIndex, formats[i], j, &mode ); GFXVideoMode vmAdd; vmAdd.bitDepth = ( i == 0 ? 16 : 32 ); // This will need to be changed later vmAdd.fullScreen = true; vmAdd.refreshRate = mode.RefreshRate; vmAdd.resolution = Point2I( mode.Width, mode.Height ); vmAdd.antialiasLevel = MaxSampleQualities; toAdd->mAvailableModes.push_back( vmAdd ); } } adapterList.push_back( toAdd ); } d3d9->Release(); }
//----------------------------------------------------------------------------------------------------------------------------------------- // CreateMiniDump() //----------------------------------------------------------------------------------------------------------------------------------------- INT CreateMiniDump( LPEXCEPTION_POINTERS ExceptionInfo) { //Get any information we can from the user and store it in gUserInput try { while(ShowCursor(TRUE) < 0); DisplayMiniDumpDialog(winState.appInstance, winState.appWindow); } catch(...) { //dSprintf(gUserInput, 4096, "The user could not enter a description of what was occurring.\n\n\n"); } //Build a Game, Date and Time stamped MiniDump folder time_t theTime; time(&theTime); tm* pLocalTime = localtime(&theTime); char crashFolder[2048]; dSprintf(crashFolder, 2048, "%s_%02d.%02d_%02d.%02d.%02d", Platform::getExecutableName(), pLocalTime->tm_mon+1, pLocalTime->tm_mday, pLocalTime->tm_hour, pLocalTime->tm_min, pLocalTime->tm_sec); //Builed the fully qualified MiniDump path char crashPath[2048]; char fileName[2048]; if(gMiniDumpDir==NULL) { dSprintf(crashPath, 2048, "%s/MiniDump/%s", Platform::getCurrentDirectory(), crashFolder); } else { dSprintf(crashPath, 2048, "%s/%s", gMiniDumpDir, crashFolder); } dSprintf(fileName, 2048, "%s/Minidump.dmp",crashPath); if (!Platform::createPath (fileName))return false; //create the directory //Save the minidump File fileObject; if(fileObject.open(fileName, File::Write) == File::Ok) { MINIDUMP_EXCEPTION_INFORMATION DumpExceptionInfo; DumpExceptionInfo.ThreadId = GetCurrentThreadId(); DumpExceptionInfo.ExceptionPointers = ExceptionInfo; DumpExceptionInfo.ClientPointers = true; MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), (HANDLE)fileObject.getHandle(), MiniDumpNormal, &DumpExceptionInfo, NULL, NULL ); fileObject.close(); } //copy over the log file char fromFile[2048]; dSprintf(fromFile, 2048, "%s/%s", Platform::getCurrentDirectory(), "console.log" ); dSprintf(fileName, 2048, "%s/console.log", crashPath); Con::setLogMode(3); //ensure that the log file is closed (so it can be copied) dPathCopy(fromFile, fileName, true); //copy over the exe file char exeName[1024]; dSprintf(exeName, 1024, Platform::getExecutableName()); exeName[dStrlen(exeName)-4]=0; dSprintf(fromFile, 2048, "%s/%s.dll", Platform::getCurrentDirectory(), exeName ); dSprintf(fileName, 2048, "%s/%s.dll", crashPath, exeName ); dPathCopy(fromFile, fileName, true); //copy over the pdb file char pdbName[1024]; dStrcpy(pdbName, exeName); dStrncat(pdbName, ".pdb", 4); dSprintf(fromFile, 2048, "%s/%s", Platform::getCurrentDirectory(), pdbName ); dSprintf(fileName, 2048, "%s/%s", crashPath, pdbName ); dPathCopy(fromFile, fileName, true); //save the call stack char traceBuffer[65536]; traceBuffer[0] = 0; dGetStackTrace( traceBuffer, *static_cast<const CONTEXT *>(ExceptionInfo->ContextRecord) ); //save the user input and the call stack to a file char crashlogFile[2048]; dSprintf(crashlogFile, 2048, "%s/crash.log", crashPath); if(fileObject.open(crashlogFile, File::Write) == File::Ok) { fileObject.write(strlen(gUserInput), gUserInput); fileObject.write(strlen(traceBuffer), traceBuffer); fileObject.close(); } //call the external program indicated in script if(gMiniDumpExec!= NULL) { //replace special variables in gMiniDumpParams if(gMiniDumpParams) { char updateParams[4096]; char finalParams[4096]; dStrrstr(finalParams, gMiniDumpParams, "%crashpath%", crashPath); dStrrstr(updateParams, finalParams, "%crashfolder%", crashFolder); dStrrstr(finalParams, updateParams, "%crashlog%", crashlogFile); ShellExecuteA(NULL, "", gMiniDumpExec, finalParams, gMiniDumpExecDir ? gMiniDumpExecDir : "", SW_SHOWNORMAL); } else { ShellExecuteA(NULL, "", gMiniDumpExec, "", gMiniDumpExecDir ? gMiniDumpExecDir : "", SW_SHOWNORMAL); } } return EXCEPTION_EXECUTE_HANDLER; }
void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList ) { // GL_ERROR_CHECK(); WNDCLASS windowclass; dMemset( &windowclass, 0, sizeof( WNDCLASS ) ); windowclass.lpszClassName = L"GFX-OpenGL"; windowclass.style = CS_OWNDC; windowclass.lpfnWndProc = DefWindowProc; windowclass.hInstance = winState.appInstance; if( !RegisterClass( &windowclass ) ) AssertFatal( false, "Failed to register the window class for the GL test window." ); // Now create a window HWND hwnd = CreateWindow( L"GFX-OpenGL", L"", WS_POPUP, 0, 0, 640, 480, NULL, NULL, winState.appInstance, NULL ); AssertFatal( hwnd != NULL, "Failed to create the window for the GL test window." ); // Create a device context HDC tempDC = GetDC( hwnd ); AssertFatal( tempDC != NULL, "Failed to create device context" ); // Create pixel format descriptor... PIXELFORMATDESCRIPTOR pfd; CreatePixelFormat( &pfd, 32, 0, 0, false ); if( !SetPixelFormat( tempDC, ChoosePixelFormat( tempDC, &pfd ), &pfd ) ) AssertFatal( false, "I don't know who's responcible for this, but I want caught..." ); // Create a rendering context! HGLRC tempGLRC = wglCreateContext( tempDC ); if( !wglMakeCurrent( tempDC, tempGLRC ) ) AssertFatal( false, "I want them caught and killed." ); // Add the GL renderer loadGLCore(); loadGLExtensions(tempDC); GFXAdapter *toAdd = new GFXAdapter; toAdd->mIndex = 0; const char* renderer = (const char*) glGetString( GL_RENDERER ); AssertFatal( renderer != NULL, "GL_RENDERER returned NULL!" ); if (renderer) { dStrcpy(toAdd->mName, renderer); dStrncat(toAdd->mName, " OpenGL", GFXAdapter::MaxAdapterNameLen); } else dStrcpy(toAdd->mName, "OpenGL"); toAdd->mType = OpenGL; toAdd->mShaderModel = 0.f; toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance; // Enumerate all available resolutions: DEVMODE devMode; U32 modeNum = 0; U32 stillGoing = true; while ( stillGoing ) { dMemset( &devMode, 0, sizeof( devMode ) ); devMode.dmSize = sizeof( devMode ); stillGoing = EnumDisplaySettings( NULL, modeNum++, &devMode ); if (( devMode.dmPelsWidth >= 480) && (devMode.dmPelsHeight >= 360 ) && ( devMode.dmBitsPerPel == 16 || devMode.dmBitsPerPel == 32 )) { GFXVideoMode vmAdd; vmAdd.bitDepth = devMode.dmBitsPerPel; vmAdd.fullScreen = true; vmAdd.refreshRate = devMode.dmDisplayFrequency; vmAdd.resolution.x = devMode.dmPelsWidth; vmAdd.resolution.y = devMode.dmPelsHeight; // Only add this resolution if it is not already in the list: bool alreadyInList = false; for (Vector<GFXVideoMode>::iterator i = toAdd->mAvailableModes.begin(); i != toAdd->mAvailableModes.end(); i++) { if (vmAdd == *i) { alreadyInList = true; break; } } if(alreadyInList) continue; toAdd->mAvailableModes.push_back( vmAdd ); } } // Add to the list of available adapters. adapterList.push_back(toAdd); // Cleanup our window wglMakeCurrent(NULL, NULL); wglDeleteContext(tempGLRC); ReleaseDC(hwnd, tempDC); DestroyWindow(hwnd); UnregisterClass(L"GFX-OpenGL", winState.appInstance); }
void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList ) { AssertFatal( SDL_WasInit(SDL_INIT_VIDEO), ""); PlatformGL::init(); // for hints about context creation // Create a dummy window & openGL context so that gl functions can be used here SDL_Window* tempWindow = SDL_CreateWindow( "", // window title SDL_WINDOWPOS_UNDEFINED, // initial x position SDL_WINDOWPOS_UNDEFINED, // initial y position 640, // width, in pixels 480, // height, in pixels SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN // flags - see below ); SDL_ClearError(); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GLContext tempContext = SDL_GL_CreateContext( tempWindow ); if( !tempContext ) { const char *err = SDL_GetError(); Con::printf( err ); AssertFatal(0, err ); return; } SDL_ClearError(); SDL_GL_MakeCurrent( tempWindow, tempContext ); const char *err = SDL_GetError(); if( err && err[0] ) { Con::printf( err ); AssertFatal(0, err ); } // Init GL loadGLCore(); loadGLExtensions(tempContext); //check minimun Opengl 3.2 int major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); if( major < 3 || ( major == 3 && minor < 2 ) ) { return; } GFXAdapter *toAdd = new GFXAdapter; toAdd->mIndex = 0; const char* renderer = (const char*) glGetString( GL_RENDERER ); AssertFatal( renderer != NULL, "GL_RENDERER returned NULL!" ); if (renderer) { dStrcpy(toAdd->mName, renderer); dStrncat(toAdd->mName, " OpenGL", GFXAdapter::MaxAdapterNameLen); } else dStrcpy(toAdd->mName, "OpenGL"); toAdd->mType = OpenGL; toAdd->mShaderModel = 0.f; toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance; // Enumerate all available resolutions: EnumerateVideoModes(toAdd->mAvailableModes); // Add to the list of available adapters. adapterList.push_back(toAdd); // Cleanup window & open gl context SDL_DestroyWindow( tempWindow ); SDL_GL_DeleteContext( tempContext ); }