SiStripGenerator::SiStripGenerator(TTree* tree, TFile *file) : TSelectorInsert(), fNDets(4), fNStrips(16), fTree(tree), fFile(file), fGraphs(fNStrips*fNDets,(TGraph*)0), fNEntries(fNStrips*fNDets,0), fColors(fNStrips,0), fTheta(0), fPhi(0), fStripID(0), fDetID(0)//, // fBTheta(0), // fBPhi(0), // fBStripID(0), // fBDetID(0) { #ifdef DEBUG_SiStripGenerator std::cout << "SiStripGenerator constructed for TTree=" << fTree->GetName() << std::endl; #endif if (!fFile->IsOpen()) { fFile = new TFile("SiStripGenerator_out.root","UPDATE"); } fFile->ReOpen("UPDATE"); SetupPalette(); ConstructGraphs(); }
int CGLView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; m_hDC = ::GetDC(m_hWnd); if (!SetupPF()) return false; SetupPalette(); if (!CreateRC()) return false; return Init(); }
HRESULT STDMETHODCALLTYPE SetPalette(LPDIRECTDRAWSURFACE7 surface, LPDIRECTDRAWPALETTE lpDDPalette) { //logOutput << CurrentTimeString() << "Hooked SetPalette()" << endl; ddrawSurfaceSetPalette.Unhook(); HRESULT hr = surface->SetPalette(lpDDPalette); ddrawSurfaceSetPalette.Rehook(); if (getFrontSurface(surface)) { if (lpDDPalette) lpDDPalette->AddRef(); SetupPalette(lpDDPalette); } return hr; }
bool wxGLCanvas::Create(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const wxPalette& palette) { // Create the window first: we will either use it as is or use it to query // for multisampling support and recreate it later with another pixel format if ( !CreateWindow(parent, id, pos, size, style, name) ) return false; // Choose a matching pixel format. // Need a PIXELFORMATDESCRIPTOR for SetPixelFormat() PIXELFORMATDESCRIPTOR pfd; int pixelFormat = FindMatchingPixelFormat(dispAttrs, &pfd); if ( !pixelFormat ) { wxFAIL_MSG("Can't find a pixel format for the requested attributes"); return false; } // From SetPixelFormat() docs, relating pfd parameter: // https://msdn.microsoft.com/en-us/library/dd369049%28v=vs.85%29.aspx // "The system's metafile component uses this structure to record the // logical pixel format specification." // If anybody understands this sentence, please explain. // Pass pfd just in case it's somehow needed. Passing NULL also works here. if ( !::SetPixelFormat(m_hDC, pixelFormat, &pfd) ) { wxLogLastError("SetPixelFormat"); return false; } #if wxUSE_PALETTE if ( !SetupPalette(palette) ) return false; #else // !wxUSE_PALETTE wxUnusedVar(palette); #endif // wxUSE_PALETTE/!wxUSE_PALETTE return true; }
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const int *attribList, const wxPalette& palette) { // Create the window first: we will either use it as is or use it to query // for multisampling support and recreate it later with another pixel format if ( !CreateWindow(parent, id, pos, size, style, name) ) return false; PIXELFORMATDESCRIPTOR pfd; const int setupVal = DoSetup(pfd, attribList); if ( setupVal == 0 ) // PixelFormat error return false; if ( setupVal == -1 ) // FSAA requested { // now that we have a valid OpenGL window, query it for FSAA support int pixelFormat; { wxGLContext ctx(this); ctx.SetCurrent(*this); pixelFormat = ::ChoosePixelFormatARB(m_hDC, attribList); } if ( pixelFormat > 0 ) { // from http://msdn.microsoft.com/en-us/library/ms537559(VS.85).aspx: // // Setting the pixel format of a window more than once can // lead to significant complications for the Window Manager // and for multithread applications, so it is not allowed. An // application can only set the pixel format of a window one // time. Once a window's pixel format is set, it cannot be // changed. // // so we need to delete the old window and create the new one // destroy Window ::ReleaseDC(GetHwnd(), m_hDC); m_hDC = 0; parent->RemoveChild(this); const HWND hwnd = GetHwnd(); DissociateHandle(); // will do SetHWND(0); ::DestroyWindow(hwnd); // now recreate with FSAA pixelFormat if ( !CreateWindow(parent, id, pos, size, style, name) ) return false; if ( !::SetPixelFormat(m_hDC, pixelFormat, &pfd) ) { wxLogLastError(_T("SetPixelFormat")); return false; } } } #if wxUSE_PALETTE if ( !SetupPalette(palette) ) return false; #else // !wxUSE_PALETTE wxUnusedVar(palette); #endif // wxUSE_PALETTE/!wxUSE_PALETTE return true; }
// load animations, start sound void Projectile::Setup() { tint.r=128; tint.g=128; tint.b=128; tint.a=255; ieDword time = core->GetGame()->Ticks; timeStartStep = time; if(ExtFlags&PEF_TEXT) { Actor *act = area->GetActorByGlobalID(Caster); if(act) { displaymsg->DisplayStringName(StrRef, DMC_LIGHTGREY, act,0); } } //falling = vertical //incoming = right side //both = left side if(ExtFlags&(PEF_FALLING|PEF_INCOMING) ) { if (ExtFlags&PEF_INCOMING) { if (ExtFlags&PEF_FALLING) { Pos.x=Destination.x-200; } else { Pos.x=Destination.x+200; } } else { Pos.x=Destination.x; } Pos.y=Destination.y-200; NextTarget(Destination); } if(ExtFlags&PEF_WALL) { SetupWall(); } //cone area of effect always disables the travel flag //but also makes the caster immune to the effect if (Extension) { if (Extension->AFlags&PAF_CONE) { NewOrientation = Orientation = GetOrient(Destination, Pos); Destination=Pos; ExtFlags|=PEF_NO_TRAVEL; } //this flag says the first explosion is delayed //(works for delaying triggers too) //getting the explosion count here, so an absent caster won't cut short //on the explosion count if(Extension->AFlags&PAF_DELAY) { extension_delay=Extension->Delay; } else { extension_delay=0; } extension_explosioncount=CalculateExplosionCount(); } //set any static tint if(ExtFlags&PEF_TINT) { Color tmpColor[PALSIZE]; core->GetPalette( Gradients[0], PALSIZE, tmpColor ); StaticTint(tmpColor[PALSIZE/2]); } CreateAnimations(travel, BAMRes1, Seq1); if (TFlags&PTF_SHADOW) { CreateAnimations(shadow, BAMRes2, Seq2); } if (TFlags&PTF_SMOKE) { GetSmokeAnim(); } //there is no travel phase, create the projectile right at the target if (ExtFlags&PEF_NO_TRAVEL) { Pos = Destination; //the travel projectile should linger after explosion if(ExtFlags&PEF_POP) { //the explosion consists of a pop in/hold/pop out of the travel projectile (dimension door) if(travel[0] && shadow[0]) { extension_delay = travel[0]->GetFrameCount()*2+shadow[0]->GetFrameCount(); //SetDelay( travel[0]->GetFrameCount()*2+shadow[0]->GetFrameCount()); travel[0]->Flags|=A_ANI_PLAYONCE; shadow[0]->Flags|=A_ANI_PLAYONCE; } } else { if(travel[0]) { extension_delay = travel[0]->GetFrameCount(); travel[0]->Flags|=A_ANI_PLAYONCE; //SetDelay(travel[0]->GetFrameCount() ); } } } if (TFlags&PTF_COLOUR) { SetupPalette(travel, palette, Gradients); } else { gamedata->FreePalette(palette, PaletteRes); palette=gamedata->GetPalette(PaletteRes); } if (TFlags&PTF_LIGHT) { light = core->GetVideoDriver()->CreateLight(LightX, LightZ); } if (TFlags&PTF_BLEND) { SetBlend(TFlags&PTF_BRIGHTEN); } if (SFlags&PSF_FLYING) { ZPos = FLY_HEIGHT; } phase = P_TRAVEL; travel_handle = core->GetAudioDrv()->Play(SoundRes1, Pos.x, Pos.y, (SFlags & PSF_LOOPING ? GEM_SND_LOOPING : 0)); //create more projectiles if(ExtFlags&PEF_ITERATION) { CreateIteration(); } }
bool SetupDDraw() { logOutput << CurrentTimeString() << "called SetupDDraw()" << endl; if (!g_ddInterface) { logOutput << CurrentTimeString() << "SetupDDraw: DirectDraw interface not set, returning" << endl; return false; } bool bSuccess = true; bKillThread = false; if (hCopyThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CopyDDrawTextureThread, NULL, 0, NULL)) { if (!(hCopyEvent = CreateEvent(NULL, FALSE, FALSE, NULL))) { logOutput << CurrentTimeString() << "SetupDDraw: CreateEvent failed, GetLastError = " << GetLastError() << endl; bSuccess = false; } } else { logOutput << CurrentTimeString() << "SetupDDraw: CreateThread failed, GetLastError = " << GetLastError() << endl; bSuccess = false; } if (bSuccess) { if (!ddUnlockFctMutex) { ddUnlockFctMutex = CreateMutex(NULL, FALSE, mutexName); if (!ddUnlockFctMutex) { RUNEVERYRESET logOutput << CurrentTimeString() << "SetupDDraw: CreateMutex failed, GetLastError = " << GetLastError() << endl; bSuccess = false; } } } if (bSuccess && !g_frontSurface) { RUNEVERYRESET logOutput << "SetupDDraw: frontSurface and surface descriptor not set, returning" << endl; CleanUpDDraw(); return false; } else if (bSuccess) { LPDIRECTDRAWPALETTE palette = NULL; HRESULT err; if (SUCCEEDED(err = g_frontSurface->GetPalette(&palette))) { if (palette) SetupPalette(palette); } else if (err == DDERR_NOPALETTEATTACHED) { //logOutput << CurrentTimeString() << "No palette attached to primary surface" << endl; } else { logOutput << CurrentTimeString() << "Error retrieving palette" << endl; printDDrawError(err, "getFrontSurface"); } } if (bSuccess && !g_surfaceDesc) { logOutput << CurrentTimeString() << "SetupDDraw: no surface descriptor found, creating a new one (not an error)" << endl; g_surfaceDesc = new DDSURFACEDESC2; g_surfaceDesc->dwSize = sizeof(DDSURFACEDESC); HRESULT hr; if (FAILED(hr = ((LPDIRECTDRAWSURFACE)g_frontSurface)->GetSurfaceDesc((LPDDSURFACEDESC)g_surfaceDesc))) { g_surfaceDesc->dwSize = sizeof(DDSURFACEDESC2); if (FAILED(g_frontSurface->GetSurfaceDesc(g_surfaceDesc))) { logOutput << CurrentTimeString() << "SetupDDraw: error getting surface descriptor" << endl; printDDrawError(hr, "SetupDDraw"); bSuccess = false; } } } if (bSuccess && g_surfaceDesc) { const DDPIXELFORMAT& pf = g_surfaceDesc->ddpfPixelFormat; if (pf.dwFlags & DDPF_RGB) { if (pf.dwRGBBitCount == 16) { logOutput << CurrentTimeString() << "SetupDDraw: found 16bit format (using R5G6B5 conversion)" << endl; g_bConvert16to32 = true; } else if (pf.dwRGBBitCount == 32) { logOutput << CurrentTimeString() << "SetupDDraw: found 32bit format (using plain copy)" << endl; g_bUse32bitCapture = true; } } else if (pf.dwFlags & (DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED1)) { logOutput << CurrentTimeString() << "SetupDDraw: front surface uses palette indices" << endl; } } if (bSuccess) { logOutput << CurrentTimeString() << "SetupDDraw: primary surface width = " << g_surfaceDesc->dwWidth << ", height = " << g_surfaceDesc->dwHeight << endl; g_dwSize = g_surfaceDesc->lPitch*g_surfaceDesc->dwHeight; ddrawCaptureInfo.captureType = CAPTURETYPE_MEMORY; ddrawCaptureInfo.cx = g_surfaceDesc->dwWidth; ddrawCaptureInfo.cy = g_surfaceDesc->dwHeight; ddrawCaptureInfo.pitch = 4 * ddrawCaptureInfo.cx; ddrawCaptureInfo.hwndCapture = (DWORD)hwndSender; ddrawCaptureInfo.format = GS_BGRA; DWORD g_dwCaptureSize = ddrawCaptureInfo.pitch*ddrawCaptureInfo.cy; ddrawCaptureInfo.bFlip = FALSE; ddrawCaptureInfo.mapID = InitializeSharedMemoryCPUCapture(g_dwCaptureSize, &ddrawCaptureInfo.mapSize, ©Data, textureBuffers); memcpy(infoMem, &ddrawCaptureInfo, sizeof(CaptureInfo)); DDSURFACEDESC2 captureDesc; ZeroMemory(&captureDesc, sizeof(captureDesc)); captureDesc.dwSize = sizeof(DDSURFACEDESC2); captureDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_PITCH; captureDesc.dwWidth = g_surfaceDesc->dwWidth; captureDesc.dwHeight = g_surfaceDesc->dwHeight; captureDesc.lPitch = g_surfaceDesc->lPitch; captureDesc.ddpfPixelFormat = g_surfaceDesc->ddpfPixelFormat; captureDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; HRESULT err; ddrawSurfaceCreate.Unhook(); for (int i = 0; i < NUM_BUFFERS && bSuccess; i++) { if (FAILED(err = g_ddInterface->CreateSurface(&captureDesc, &ddCaptures[i], NULL))) { logOutput << CurrentTimeString() << "SetupDDraw: Could not create offscreen capture" << endl; printDDrawError(err, "SetupDDraw"); bSuccess = false; break; } } ddrawSurfaceCreate.Rehook(); if (bSuccess) { bHasTextures = true; SetEvent(hSignalReady); OSInitializeTimer(); } } if (bSuccess) { logOutput << CurrentTimeString() << "SetupDDraw successfull" << endl; HookAll(); return true; } else { logOutput << CurrentTimeString() << "SetupDDraw failed" << endl; CleanUpDDraw(); return false; } }
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const int *attribList, const wxPalette& palette) { // Create the window first: we will either use it as is or use it to query // for multisampling support and recreate it later with another pixel format if ( !CreateWindow(parent, id, pos, size, style, name) ) return false; // these will be used for the context creation attributes // if a core profile is requested bool useGLCoreProfile = false; // the minimum gl core version is 3.0 int glVersionMajor = 3, glVersionMinor = 0; // Check for a core profile request if ( attribList ) { for ( int i = 0; attribList[i]; ) { switch ( attribList[i++] ) { case WX_GL_CORE_PROFILE: useGLCoreProfile = true; break; case WX_GL_MAJOR_VERSION: glVersionMajor = attribList[i++]; break; case WX_GL_MINOR_VERSION: glVersionMinor = attribList[i++]; break; default: // ignore all other flags for now break; } } } if ( useGLCoreProfile ) { s_wglContextAttribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB; s_wglContextAttribs[1] = glVersionMajor; s_wglContextAttribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB; s_wglContextAttribs[3] = glVersionMinor; s_wglContextAttribs[4] = WGL_CONTEXT_FLAGS_ARB; s_wglContextAttribs[5] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; s_wglContextAttribs[6] = WGL_CONTEXT_PROFILE_MASK_ARB; s_wglContextAttribs[7] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; s_wglContextAttribs[8] = 0; // terminate } else // create legacy/compatibility context { s_wglContextAttribs[0] = 0; } PIXELFORMATDESCRIPTOR pfd; const int setupVal = DoSetup(pfd, attribList); if ( setupVal == 0 ) // PixelFormat error return false; if ( setupVal == -1 ) // FSAA requested { // now that we have a valid OpenGL window, query it for FSAA support int pixelFormat; { wxGLContext ctx(this); ctx.SetCurrent(*this); pixelFormat = ::ChoosePixelFormatARB(m_hDC, attribList); } if ( pixelFormat > 0 ) { // from http://msdn.microsoft.com/en-us/library/ms537559(VS.85).aspx: // // Setting the pixel format of a window more than once can // lead to significant complications for the Window Manager // and for multithread applications, so it is not allowed. An // application can only set the pixel format of a window one // time. Once a window's pixel format is set, it cannot be // changed. // // so we need to delete the old window and create the new one // destroy Window ::ReleaseDC(GetHwnd(), m_hDC); m_hDC = 0; parent->RemoveChild(this); const HWND hwnd = GetHwnd(); DissociateHandle(); // will do SetHWND(0); ::DestroyWindow(hwnd); // now recreate with FSAA pixelFormat if ( !CreateWindow(parent, id, pos, size, style, name) ) return false; if ( !::SetPixelFormat(m_hDC, pixelFormat, &pfd) ) { wxLogLastError(wxT("SetPixelFormat")); return false; } } } #if wxUSE_PALETTE if ( !SetupPalette(palette) ) return false; #else // !wxUSE_PALETTE wxUnusedVar(palette); #endif // wxUSE_PALETTE/!wxUSE_PALETTE return true; }