void CRenderer::Init() { s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE, ScreenSizeChangeCallback, NULL); UpdateDeviceParams(); mDefaultMaterial = new CIwMaterial; mDefaultMaterial->SetAlphaMode( CIwMaterial::ALPHA_BLEND ); mCurrMtl = mDefaultMaterial; //mCamera.pos.x = 0; //mCamera.pos.y = 0; //mCamera.pos = CIwFVec2(0, 0); //mCamera.scale = 1.f; mCamera.Reset(); AllocBuffers(); }
/** * Called to resize a window. This involves allocating new image buffers. */ static void binaryswapspu_ResizeWindow(WindowInfo * window, int newWidth, int newHeight) { CRASSERT(newWidth > 0); CRASSERT(newHeight > 0); window->width = newWidth; window->height = newHeight; if (binaryswap_spu.alpha_composite) window->bytesPerColor = 4 * sizeof(GLubyte); else window->bytesPerColor = 3 * sizeof(GLubyte); if (binaryswap_spu.depth_composite) window->bytesPerDepth = sizeof(GLuint); else window->bytesPerDepth = 0; if (binaryswap_spu.resizable) { /* update super/render SPU window size & viewport */ binaryswap_spu.super.WindowSize(window->renderWindow, newWidth, newHeight); binaryswap_spu.super.Viewport(0, 0, newWidth, newHeight); /* set child SPU's window size and viewport too */ binaryswap_spu.child.WindowSize(window->renderWindow, newWidth, newHeight); binaryswap_spu.child.Viewport(0, 0, newWidth, newHeight); /* clear the stencil buffer */ binaryswap_spu.super.Clear(GL_STENCIL_BUFFER_BIT); } AllocBuffers(window); BuildSwapLimits(window); }
// Generate all the optimzation and geometry data void morphChannel::buildFromNode( INode *node , BOOL resetTime, TimeValue t, BOOL picked ) { // fix for defect 1346773 - Crash deleting progressive morph target if (NULL == node ) { return; } if(resetTime) t = GetCOREInterface()->GetTime(); ObjectState os = node->EvalWorldState(t); int tPc = os.obj->NumPoints(); int x,id = 0; Point3 DeltP; double wtmp; Point3 tVert; if(tPc!=mp->MC_Local.Count) { mNumPoints = 0; mActive = FALSE; mInvalid = TRUE; goto CantLoadThis; } if(!mp->MC_Local.CacheValid) goto CantLoadThis; mInvalid = FALSE; // if the channel hasn't been edited yet, change the 'empty' // name to that of the chosen object. if( !mModded || picked) mName = node->GetName(); // Set the data into the morphChannel mActive = TRUE; mModded = TRUE; // Prepare the channel AllocBuffers(tPc, tPc); mSel.SetSize(tPc); mSel.ClearAll(); mNumPoints = 0; for(x=0;x<tPc;x++) { tVert = os.obj->GetPoint(x); wtmp = os.obj->GetWeight(x); // calculate the delta cache DeltP.x=(tVert.x-mp->MC_Local.oPoints[x].x)/100.0f; DeltP.y=(tVert.y-mp->MC_Local.oPoints[x].y)/100.0f; DeltP.z=(tVert.z-mp->MC_Local.oPoints[x].z)/100.0f; mDeltas[x] = DeltP; mWeights[x] = os.obj->GetWeight(x); mSel.Set( x, os.obj->IsPointSelected(x)?1:0); mPoints[x] = tVert; mNumPoints++; } // Update *everything* mp->NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); mp->NotifyDependents(FOREVER,PART_ALL,REFMSG_SUBANIM_STRUCTURE_CHANGED); mp->Update_channelFULL(); mp->Update_channelParams(); CantLoadThis: tPc=0; }
int CTransparencyRenderer::Add (tTranspItemType nType, void *itemData, int itemSize, int nDepth, int nIndex) { #if RENDER_TRANSPARENCY tTranspItem *ph, *pi, *pj, **pd; int nOffset; #if DBG if (nDepth < m_data.zMin) return m_data.nFreeItems; if (nDepth > m_data.zMax) { //if (nType != riParticle) return m_data.nFreeItems; nDepth = m_data.zMax; } #else if ((nDepth < m_data.zMin) || (nDepth > m_data.zMax)) return m_data.nFreeItems; #endif AllocBuffers (); if (!m_data.nFreeItems) return 0; #if 1 nOffset = (int) ((double) (nDepth - m_data.zMin) * m_data.zScale); #else if (nIndex < m_data.zMin) nOffset = 0; else nOffset = (int) ((double) (nIndex - m_data.zMin) * m_data.zScale); #endif if (nOffset >= ITEM_DEPTHBUFFER_SIZE) return 0; pd = m_data.depthBuffer + nOffset; // find the first particle to insert the new one *before* and place in pj; pi will be it's predecessor (NULL if to insert at list start) ph = m_data.itemLists + --m_data.nFreeItems; ph->nItem = m_data.nItems++; ph->nType = nType; ph->bRendered = 0; ph->parentP = NULL; ph->z = nDepth; ph->bValid = true; memcpy (&ph->item, itemData, itemSize); for (pi = NULL, pj = *pd; pj && ((pj->z < nDepth) || ((pj->z == nDepth) && (pj->nType < nType))); pj = pj->pNextItem) { #if DBG if (pj == pi) break; // loop #endif pi = pj; } if (pi) { ph->pNextItem = pi->pNextItem; pi->pNextItem = ph; } else { ph->pNextItem = *pd; *pd = ph; } if (m_data.nMinOffs > nOffset) m_data.nMinOffs = nOffset; if (m_data.nMaxOffs < nOffset) m_data.nMaxOffs = nOffset; return m_data.nFreeItems; #else return 0; #endif }
tbool CExportDSPTask::DoWork() { tbool bError = false; switch (miActionOrder) { case geExportDSP_Start: { if (miChannels < 1) { // The Channels drop-down was left at "unchanged" // This always means stereo for DSP exports, // since all channels are processed stereo miChannels = 2; } // Save position muiPosSaved = gpApplication->GetSongPos(); // Find end position + tail tint32 iTailFrames = Float2Int((miTailMS * gpApplication->GetSampleRate()) / 1000.0f); tint64 iLastSample = miFinalSample; if (iLastSample < 0) { if (IsOutMix()) { iLastSample = gpDSPEngine->Get_Session_End_Sample(); } else { tint64 iFirstSample_Ignored; if (!gpDSPEngine->CalcTrackDuration(miTrack, &iFirstSample_Ignored, &iLastSample)) { // Fal back to full length iLastSample = gpDSPEngine->Get_Session_End_Sample(); } } } muiEndPosPlusTail = iLastSample + iTailFrames; muiProgressTarget = 0; if (mfNormalizationFactor != 0.0f) { // We have a predefined normalization factor - don't do peak search miActionOrder = geExportDSP_Peak_After; miActionOrder++; } else { // Go to next task (peak search) miActionOrder++; } } break; case geExportDSP_Peak_Before: { gpApplication->Playback_InProgressTask(miFirstSample); if (IsOutMix()) gpApplication->Playback_ExportOutMix(miFirstSample); else gpApplication->Playback_ExportTrack(miTrack, miFirstSample, miFinalSample); msProgress = "Peak search '"; msProgress += msTrackName; msProgress += "'"; muiProgressIx = 0; muiProgressTarget = muiEndPosPlusTail - miFirstSample; AllocBuffers(kiPeakPortionSize); mfPeak = 0.001f; muiPortionSize = kiPeakPortionSize; uiWholePortions = (muiEndPosPlusTail - miFirstSample) / kiPeakPortionSize; uiLastPortionSize = muiEndPosPlusTail % kiPeakPortionSize; if (!mbSkipFileOutput) { // Prepare for intermediate buffer file msIntermediateFiles[0] = sDestFolder + sDestNameAndExt + ".raw0"; msIntermediateFiles[1] = sDestFolder + sDestNameAndExt + ".raw1"; mpfIntermediateFiles[0] = IFile::Create(); mpfIntermediateFiles[1] = IFile::Create(); if ((mpfIntermediateFiles[0] == NULL) || (mpfIntermediateFiles[1] == NULL)) { msIntermediateFiles[0] = ""; msIntermediateFiles[1] = ""; } else { if ( (!mpfIntermediateFiles[0]->Open(msIntermediateFiles[0].c_str(), IFile::FileCreate)) || (!mpfIntermediateFiles[1]->Open(msIntermediateFiles[1].c_str(), IFile::FileCreate)) ) { msIntermediateFiles[0] = ""; msIntermediateFiles[1] = ""; mpfIntermediateFiles[0]->Destroy(); mpfIntermediateFiles[0] = NULL; mpfIntermediateFiles[1]->Destroy(); mpfIntermediateFiles[1] = NULL; } else if ((miFirstSample > 0) && (!mbRemoveInitialSilence)) { // Dump silence into file const tint32 kiChunkSamples = 1024; tint64 iSilentChunks = (miFirstSample / kiChunkSamples); tint64 iAfterChunks_Samples = miFirstSample - (iSilentChunks * kiChunkSamples); // Initialize a memory portion with silence tfloat32 afSilentChunk[kiChunkSamples]; tchar* pacSilentChunk = (tchar*)afSilentChunk; memset(pacSilentChunk, '\0', kiChunkSamples * sizeof(tfloat32)); // Write whole chunks for ( ;iSilentChunks > 0; iSilentChunks--) { // Since these are temporary files we ignore MSB / LSB questions mpfIntermediateFiles[0]->Write(pacSilentChunk, kiChunkSamples * sizeof(tfloat32)); mpfIntermediateFiles[1]->Write(pacSilentChunk, kiChunkSamples * sizeof(tfloat32)); } // Write extra samples after whole chunks if (iAfterChunks_Samples > 0) { // Since these are temporary files we ignore MSB / LSB questions mpfIntermediateFiles[0]->Write(pacSilentChunk, iAfterChunks_Samples * sizeof(tfloat32)); mpfIntermediateFiles[1]->Write(pacSilentChunk, iAfterChunks_Samples * sizeof(tfloat32)); } } } } miActionOrder++; } break; case geExportDSP_Peak_Action: { bError = !DoEncode_InALoop(false); } break; case geExportDSP_Peak_After: { msProgress = "Peak search done"; muiProgressIx = muiProgressTarget = 1; mfNormalizationFactor = 1.0f; mfNormalizationFactor /= mfPeak; if (mpfIntermediateFiles[0]) { mpfIntermediateFiles[0]->Close(); } if (mpfIntermediateFiles[1]) { mpfIntermediateFiles[1]->Close(); } if (mbSkipFileOutput) { miActionOrder = geExportDSP_After; } miActionOrder++; } break; case geExportDSP_Before: { if (mbSkipFileOutput) { // Skip encoding gpApplication->Playback_InProgressTask(muiPosSaved); msProgress = ""; muiProgressIx = muiProgressTarget = 0; miActionOrder = geExportDSP_After; miActionOrder++; } else { // Prepare for encoding tint64 iPosToStart = (mbRemoveInitialSilence) ? miFirstSample : 0; if (msIntermediateFiles[0].length()) { // Load from intermediate files mpfIntermediateFiles[0]->Open(msIntermediateFiles[0].c_str(), IFile::FileRead); mpfIntermediateFiles[1]->Open(msIntermediateFiles[1].c_str(), IFile::FileRead); } else { if (IsOutMix()) gpApplication->Playback_ExportOutMix(iPosToStart); else gpApplication->Playback_ExportTrack(miTrack, iPosToStart, miFinalSample); } msProgress = "Exporting '"; msProgress += sDestNameAndExt; msProgress += "'"; muiProgressIx = 0; muiProgressTarget = (muiEndPosPlusTail - iPosToStart); AllocBuffers(miPortionSize); muiPortionSize = miPortionSize; uiWholePortions = (muiEndPosPlusTail - iPosToStart) / miPortionSize; uiLastPortionSize = muiEndPosPlusTail % miPortionSize; miActionOrder++; } } break; case geExportDSP_Action: { if (mpfOutput == NULL) { bError = !DoEncode_FirstTimeHere(); } if (!bError) { bError = !DoEncode_InALoop(true); } } break; case geExportDSP_After: { gpApplication->Playback_InProgressTask(muiPosSaved); msProgress = "Export done"; muiProgressIx = muiProgressTarget = 1; miActionOrder++; } break; default: // Why are we here? bError = true; break; } if (bError) { miActionOrder = geExportDSP_Done; } return !bError; } // DoWork
// // Constructor // DoubleBuffer::DoubleBuffer() { memset(&m_Buffers, 0, sizeof(m_Buffers)); AllocBuffers(); }