Heightfield::Heightfield(ID3D11DeviceContext *mDevcon, ID3D11Device *mDev, GeometryGenerator *geoGen) : mDevcon(mDevcon), mDev(mDev) { CreateGeometry(geoGen); SetupBuffer(); SetupPipeline(); }
void RenderViewport::SetViewport(FLevelLocals *Level, RenderThread *thread, int fullWidth, int fullHeight, float trueratio) { int virtheight, virtwidth, virtwidth2, virtheight2; if (!RenderingToCanvas) { // Set r_viewsize cvar to reflect the current view size UCVarValue value; char temp[16]; mysnprintf(temp, countof(temp), "%d x %d", viewwidth, viewheight); value.String = temp; r_viewsize.ForceSet(value, CVAR_String); } fuzzviewheight = viewheight - 2; // Maximum row the fuzzer can draw to CenterX = viewwindow.centerx; CenterY = viewwindow.centery; virtwidth = virtwidth2 = fullWidth; virtheight = virtheight2 = fullHeight; if (AspectTallerThanWide(trueratio)) { virtheight2 = virtheight2 * AspectMultiplier(trueratio) / 48; } else { virtwidth2 = virtwidth2 * AspectMultiplier(trueratio) / 48; } if (AspectTallerThanWide(viewwindow.WidescreenRatio)) { virtheight = virtheight * AspectMultiplier(viewwindow.WidescreenRatio) / 48; } else { virtwidth = virtwidth * AspectMultiplier(viewwindow.WidescreenRatio) / 48; } double ypixelstretch = (Level->info) ? Level->info->pixelstretch : 1.2; BaseYaspectMul = 320.0 * virtheight2 / (r_Yaspect * virtwidth2); YaspectMul = 320.0 * virtheight / (r_Yaspect * virtwidth) * ypixelstretch / 1.2; IYaspectMul = (double)virtwidth * r_Yaspect / 320.0 / virtheight; InvZtoScale = YaspectMul * CenterX; WallTMapScale2 = IYaspectMul / CenterX * 1.2 / ypixelstretch; // thing clipping fillshort(screenheightarray, viewwidth, (short)viewheight); InitTextureMapping(); // Reset r_*Visibility vars thread->Light->SetVisibility(this, r_visibility, !!(Level->flags3 & LEVEL3_NOLIGHTFADE)); SetupBuffer(); }
GroundPlane::GroundPlane(ID3D11DeviceContext *mDevcon, ID3D11Device *mDev, GeometryGenerator *geoGen, int planeSize, int increment) : mDevcon(mDevcon), mDev(mDev), size(planeSize), inc(increment) { cb = new PostPBuff(); cb->viewInvProj; cb->viewPrevProj; CreateGeometry(geoGen); SetupBuffer(); SetupPipeline(); SetupRenderTarget(); }
byte EHCIDevice::SetupAllocBuffer(EHCIQTransferDesc* pTD, unsigned uiSize) { static const unsigned MAX_LEN = PAGE_SIZE * 4 ; if(uiSize > MAX_LEN) { printf("\n EHCI QTD Buffer Size: %d greater than Limit (PAGE_SIZE * 4): %d", uiSize, MAX_LEN) ; return EHCIController_FAILURE ; } unsigned uiAddress = DMM_AllocateForKernel(uiSize) ; return SetupBuffer(pTD, uiAddress, uiSize) ; }
void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams ) { // intermission / finale rendering if ( pparams->intermission ) { V_CalcIntermissionRefdef ( pparams ); } else if ( pparams->spectator || g_iUser1 ) // g_iUser true if in spectator mode { V_CalcSpectatorRefdef ( pparams ); } else if ( !pparams->paused ) { V_CalcNormalRefdef ( pparams ); } // Fograin92 gSoundEngine.SetupFrame( pparams ); /* // Example of how to overlay the whole screen with red at 50 % alpha #define SF_TEST #if defined SF_TEST { screenfade_t sf; gEngfuncs.pfnGetScreenFade( &sf ); sf.fader = 255; sf.fadeg = 0; sf.fadeb = 0; sf.fadealpha = 128; sf.fadeFlags = FFADE_STAYOUT | FFADE_OUT; gEngfuncs.pfnSetScreenFade( &sf ); } #endif */ // BUzer if (g_cvShadows->value) SetupBuffer(); }
//////////////////////// /// Initialize( ) //////////////////////// /// Sets us up the device. /// /// Input: /// HWND hWnd Handle to the window /// LPDIRECTINPUT8 pDInput The DirectInput object // /// Returns: /// bool true if everything set up OK. //////////////////////// bool CInputKeyboard::Initialize(HWND hWnd, LPDIRECTINPUT8 pDInput) { // Our HRESULT we'll re-use. HRESULT hResult = NULL; // Tell the base class what kind of device it is. eDeviceType = DEVICE_KEYBOARD; // Create the device. hResult = pDInput->CreateDevice(GUID_SysKeyboard, &pDevice, NULL); if (FAILED(hResult)) return false; // Set data format so the device knows what it is. hResult = pDevice->SetDataFormat(&c_dfDIKeyboard); if (FAILED(hResult)) return false; // Kill windows key? bKillWindowsKey = false; // String input. //cStringInput = "\0"; //iStringInputMode = INPUT_STRING_NONE; // Set cooperative level. hResult = CooperativeLevel(hWnd, false, false); if (FAILED(hResult)) return false; // Null out the immediate input buffer. memset((void*)cKeyBuffer, 0, sizeof(cKeyBuffer)); // Prepare our buffer for buffered input. SetupBuffer(); // Acquire the device. hResult = pDevice->Acquire(); if (FAILED(hResult)) return false; // If we get here, everything went smoothly! return true; }
//////////////////////// /// Initialize( ) //////////////////////// /// Sets us up the device. /// For joysticks, make sure to call SetGuid() before Initialize, out of the EnumerateJoysticks function. /// /// Input: /// HWND hWnd Handle to the window /// LPDIRECTINPUT8 pDInput The DirectInput object // /// Returns: /// bool true if everything set up OK. //////////////////////// bool CInputJoystick::Initialize(HWND hWnd, LPDIRECTINPUT8 pDInput) { // Our HRESULT we'll re-use. HRESULT hResult = NULL; // Tell the base class what kind of device it is. eDeviceType = DEVICE_JOYSTICK; // Create the device. hResult = pDInput->CreateDevice(JoystickGUID, &pDevice, NULL); if (FAILED(hResult)) return false; // Null out feedack effects for now pFeedbackEffects = NULL; // Set data format so the device knows what it is. hResult = pDevice->SetDataFormat(&c_dfDIJoystick2); if (FAILED(hResult)) return false; // Set cooperative level. Joysticks will default to exclusive; how many games can you play at once? hResult = CooperativeLevel(hWnd, true, true); if (FAILED(hResult)) return false; // Null out the immediate input buffer. memset((void*)&JoystickState, 0, sizeof(JoystickState)); // Prepare our buffer for buffered input. SetupBuffer(); // Set up pointer nPointerX = 0; nPointerY = 0; fPointerSensitivity = DEFAULT_JOYSTICK_POINTER_SENSITIVITY; // Increment the counter of joysticks we have set up nJoystickCount++; // Check for force feedback capabilities. DIDEVCAPS DevCaps; ZeroMemory(&DevCaps, sizeof(DevCaps)); DevCaps.dwSize = sizeof(DevCaps); pDevice->GetCapabilities (&DevCaps); bSupportsForceFeedback = ((DevCaps.dwFlags & DIDC_FORCEFEEDBACK) == DIDC_FORCEFEEDBACK) ? true : false; ToggleForceFeedback(bSupportsForceFeedback); if (bSupportsForceFeedback) { // Kill auto-centering spring if using force feedback DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = FALSE; if( FAILED(pDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph ) ) ) return false; } // Acquire the device. hResult = pDevice->Acquire(); if (FAILED(hResult)) return false; // If we get here, everything went smoothly! return true; }
bool EHCIDevice::BulkWrite(USBulkDisk* pDisk, void* pDataBuf, unsigned uiLen) { if(uiLen == 0) return true ; unsigned uiMaxLen = pDisk->usOutMaxPacketSize * MAX_EHCI_TD_PER_BULK_RW ; if(uiLen > uiMaxLen) { printf("\n Max Bulk Transfer per Frame is %d bytes", uiMaxLen) ; return false ; } int iNoOfTDs = uiLen / EHCI_MAX_BYTES_PER_TD ; iNoOfTDs += ((uiLen % EHCI_MAX_BYTES_PER_TD) != 0) ; if(iNoOfTDs > MAX_EHCI_TD_PER_BULK_RW) { printf("\n No. of TDs per Bulk Read/Wrtie exceeded limit %d !!", MAX_EHCI_TD_PER_BULK_RW) ; return false ; } const unsigned uiMaxPacketSize = pDisk->usOutMaxPacketSize; if(_bFirstBulkWrite) { _bFirstBulkWrite = false ; for(int i = 0; i < MAX_EHCI_TD_PER_BULK_RW; i++) _ppBulkWriteTDs[ i ] = EHCIDataHandler_CreateAsyncQTransferDesc() ; _pBulkOutEndPt = _controller.CreateDeviceQueueHead(uiMaxPacketSize, pDisk->uiEndPointOut, _devAddr) ; } else { int i ; for(i = 0; i < MAX_EHCI_TD_PER_BULK_RW; i++) memset((void*)(_ppBulkWriteTDs[i]), 0, sizeof(EHCIQTransferDesc)) ; EHCIDataHandler_CleanAysncQueueHead(_pBulkOutEndPt) ; } int iIndex ; memcpy(pDisk->pRawAlignedBuffer, pDataBuf, uiLen) ; unsigned uiYetToWrite = uiLen ; unsigned uiCurWriteLen ; for(iIndex = 0; iIndex < iNoOfTDs; iIndex++) { uiCurWriteLen = (uiYetToWrite > EHCI_MAX_BYTES_PER_TD) ? EHCI_MAX_BYTES_PER_TD : uiYetToWrite ; uiYetToWrite -= uiCurWriteLen ; EHCIQTransferDesc* pTD = _ppBulkWriteTDs[ iIndex ] ; pTD->uiAltpTDPointer = 1 ; pTD->uipTDToken = (pDisk->bEndPointOutToggle << 31) | (uiCurWriteLen << 16) | (3 << 10) | (1 << 7) ; unsigned toggle = uiCurWriteLen / uiMaxPacketSize ; if(uiCurWriteLen % uiMaxPacketSize) toggle++ ; if(toggle % 2) pDisk->bEndPointOutToggle ^= 1 ; unsigned uiBufAddr = (unsigned)(pDisk->pRawAlignedBuffer + (iIndex * EHCI_MAX_BYTES_PER_TD)) ; if(SetupBuffer(pTD, uiBufAddr, uiCurWriteLen) != EHCIController_SUCCESS) { printf("\n EHCI Transfer Buffer setup failed") ; return false ; } if(iIndex > 0) _ppBulkWriteTDs[ iIndex - 1 ]->uiNextpTDPointer = KERNEL_REAL_ADDRESS((unsigned)pTD) ; } _ppBulkWriteTDs[ iIndex - 1 ]->uiNextpTDPointer = 1 ; EHCITransaction aTransaction(_pBulkOutEndPt, _ppBulkWriteTDs[ 0 ]); if(!aTransaction.PollWait()) { printf("\n Bulk Write Transaction Failed: ") ; DisplayTransactionState(_pBulkOutEndPt, _ppBulkWriteTDs[0]) ; _controller.DisplayStats() ; return false ; } EHCIDataHandler_CleanAysncQueueHead(_pBulkOutEndPt) ; return true; }