void CConfigDlg::OnBnClickedColor(UINT nId) { int nIndex; for (nIndex = 0; nIndex < CONFIG_DLG_NUM_COLORS; nIndex++) { if (nId == sColorMap[nIndex].nForeId) { m_sDComCfgTmp.m_crFore = sColorMap[nIndex].crColor; } else if (nId == sColorMap[nIndex].nBackId) { m_sDComCfgTmp.m_crBack = sColorMap[nIndex].crColor; } } RenderSample(); }
BOOL CConfigDlg::OnInitDialog() { CSizeDialog::OnInitDialog(); m_cNormalEdit.LimitText(sizeof(m_tmpKeyMap[m_nCurrentButton].m_szNormalKey)); m_cCtrlEdit.LimitText(sizeof(m_tmpKeyMap[m_nCurrentButton].m_szCtrlKey)); m_cShiftEdit.LimitText(sizeof(m_tmpKeyMap[m_nCurrentButton].m_szShiftKey)); SetupColors(&m_foreStatic, m_foreColors, true); SetupColors(&m_backStatic, m_backColors, false); GetConfig(); RenderSample(); PopulateControls(); return TRUE; }
void FXAASample::DrawScene() { SwapChainPtr->Begin(); ID3D11RenderTargetView* pRTV = SwapChainPtr->GetRenderTargetView(); ID3D11DepthStencilView* pDSV = SwapChainPtr->GetDepthStencilView(); pRTV = colorRT->GetRTView(); float ClearColor[4] = { sqrt(0.25f), sqrt(0.25f), sqrt(0.5f), 0.0f }; m_deviceContext->ClearRenderTargetView(pRTV, ClearColor); m_deviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1.0, 0); // Rebind to original back buffer and depth buffer ID3D11RenderTargetView * pRTVs[2] = { pRTV, NULL }; pRTVs[0] = colorRT->GetRTView(); m_deviceContext->OMSetRenderTargets(1, pRTVs, pDSV); RenderSample(); SwapChainPtr->Begin(); // apply FXAA if (m_fxaaEnabled) { MaterialPtr pFXAAShader = g_objMaterial.GetShader("HLSL\\FXAA.hlsl"); m_deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); float frameWidth = (float)mClientWidth; float frameHeight = (float)mClientHeight; Vector4 vFxaa = Vector4(1.0f / frameWidth, 1.0f / frameHeight, 0.0f, 0.0f); pFXAAShader->VSSetConstantBuffers("RCPFrame", &vFxaa); pFXAAShader->PSSetConstantBuffers("RCPFrame", &vFxaa); pFXAAShader->PSSetShaderResources(TU_DIFFUSE, colorRT->GetSRView()); pFXAAShader->Apply(); m_deviceContext->Draw(3, 0); } else { g_objSprite.ShowTexture(0, 0, mClientWidth, mClientHeight, colorRT->GetSRView()); } ShowRT(); SwapChainPtr->Flip(); }
void CConfigDlg::OnCbnSelchangeFontSize() { m_sDComCfgTmp.m_logfont.lfHeight = m_cFontSizeCombo.GetCurSel() + 6; RenderSample(); }
void Sample::DrawScene() { SwapChainPtr->Begin(); RenderSample(); SwapChainPtr->Flip(); }
void feed_buffer(void *udata, Uint8 *buffer, int len) { s16* stream = (s16*) buffer; u32 Samples = ReGBA_GetAudioSamplesAvailable() / OUTPUT_FREQUENCY_DIVISOR; u32 Requested = len / (2 * sizeof(s16)); u8 WasInUnderrun = Stats.InSoundBufferUnderrun; Stats.InSoundBufferUnderrun = Samples < Requested * 2; if (Stats.InSoundBufferUnderrun && !WasInUnderrun) Stats.SoundBufferUnderrunCount++; /* There must be AUDIO_OUTPUT_BUFFER_SIZE * 2 samples generated in order * for the first AUDIO_OUTPUT_BUFFER_SIZE to be valid. Some sound is * generated in the past from the future, and if the first * AUDIO_OUTPUT_BUFFER_SIZE is grabbed before the core has had time to * generate all of it (at AUDIO_OUTPUT_BUFFER_SIZE * 2), the end may * still be silence, causing crackling. */ if (Samples < Requested * 2) return; // Generate more sound first, please! else Stats.InSoundBufferUnderrun = 0; s16* Next = stream; // Take the first half of the sound. uint32_t i; for (i = 0; i < Requested / 2; i++) { s16 Left = 0, Right = 0; RenderSample(&Left, &Right); *Next++ = Left << 4; *Next++ = Right << 4; } Samples -= Requested / 2; // Discard as many samples as are generated in 1 frame, if fast-forwarding. bool Skipped = false; unsigned int VideoFastForwardedCopy = VideoFastForwarded; if (VideoFastForwardedCopy != AudioFastForwarded) { unsigned int FramesToSkip = (VideoFastForwardedCopy > AudioFastForwarded) ? /* no overflow */ VideoFastForwardedCopy - AudioFastForwarded : /* overflow */ 0x100 - (AudioFastForwarded - VideoFastForwardedCopy); uint32_t SamplesToSkip = (uint32_t) (FramesToSkip * (OUTPUT_SOUND_FREQUENCY / 59.73f)); if (SamplesToSkip > Samples - (Requested * 3 - Requested / 2)) SamplesToSkip = Samples - (Requested * 3 - Requested / 2); ReGBA_DiscardAudioSamples(SamplesToSkip * OUTPUT_FREQUENCY_DIVISOR); Samples -= SamplesToSkip; AudioFastForwarded = VideoFastForwardedCopy; Skipped = true; } // Take the second half of the sound now. for (i = 0; i < Requested - Requested / 2; i++) { s16 Left = 0, Right = 0; RenderSample(&Left, &Right); *Next++ = Left << 4; *Next++ = Right << 4; } Samples -= Requested - Requested / 2; // If we skipped sound, dampen the transition between the two halves. if (Skipped) { for (i = 0; i < DAMPEN_SAMPLE_COUNT; i++) { uint_fast8_t j; for (j = 0; j < 2; j++) { stream[Requested / 2 + i * 2 + j] = (int16_t) ( (int32_t) stream[Requested / 2 - i * 2 - 2 + j] * (DAMPEN_SAMPLE_COUNT - (int32_t) i) / (DAMPEN_SAMPLE_COUNT + 1) + (int32_t) stream[Requested / 2 + i * 2 + j] * ((int32_t) i + 1) / (DAMPEN_SAMPLE_COUNT + 1) ); } } } }