bool dlgConfigurationVarioShowModal(void) { changed = false; if (!is_simulator() && devVarioFindVega() == NULL) { MessageBoxX (_("No communication with Vega."), _("Vega error"), MB_OK); return false; } if (!Layout::landscape) wf = LoadDialog(CallBackTable, XCSoarInterface::main_window, _T("IDR_XML_VARIO_L")); else wf = LoadDialog(CallBackTable, XCSoarInterface::main_window, _T("IDR_XML_VARIO")); if (!wf) return false; wf->SetKeyDownNotify(FormKeyDown); ((WndButton *)wf->FindByName(_T("cmdClose")))->SetOnClickNotify(OnCloseClicked); tabbed = ((TabbedControl *)wf->FindByName(_T("tabbed"))); assert(tabbed != NULL); PageSwitched(); // populate enums FillEnums(); ProgressGlue::Create(_("Reading vario settings...")); // Need step size finer than default 10 ProgressGlue::SetStep(20); UpdateParameters(true); ProgressGlue::Close(); wf->ShowModal(); UpdateParameters(false); delete wf; wf = NULL; return changed; }
void FireParticleSystem::Process(float delta_t) { UpdateParameters(delta_t); glUseProgram(m_animateProgram.program); CHECK_GL_ERRORS; setUniform(m_animateProgram.program, "delta_t", delta_t); setUniform(m_animateProgram.program, "wind", m_wind); //setUniform(m_animateProgram.program, "epicenter", float3(0,1,0)); glBindBuffer(GL_TEXTURE_BUFFER, m_posAndSizeBuffers[1-m_currPinPongId]); CHECK_GL_ERRORS; bindTextureBuffer(m_animateProgram.program, 1, "vertPosBuffer", m_vertexPosTBO); CHECK_GL_ERRORS; glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, m_vertexPosTBO); CHECK_GL_ERRORS; glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_posAndSizeBuffers[m_currPinPongId]); CHECK_GL_ERRORS; glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, m_velAndHPBuffers[m_currPinPongId]); CHECK_GL_ERRORS; glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, m_randBuffers[m_currPinPongId]); CHECK_GL_ERRORS; glEnable(GL_RASTERIZER_DISCARD); glBeginTransformFeedback(GL_POINTS); CHECK_GL_ERRORS; glBindVertexArray(m_animVAOs[1-m_currPinPongId]); CHECK_GL_ERRORS; glDrawArrays(GL_POINTS, 0, m_particlesNum); CHECK_GL_ERRORS; glBindVertexArray(0); glEndTransformFeedback(); CHECK_GL_ERRORS; glDisable(GL_RASTERIZER_DISCARD); glBindBuffer(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, 0); m_currPinPongId = 1 - m_currPinPongId; m_lastDeltaTime = delta_t; }
void moPostEffectColorFilter::Draw( moTempo* tempogral,moEffectState* parentstate) { PreDraw( tempogral, parentstate); UpdateParameters(); filters.Apply(&state.tempo, FilterParams); glDisable(GL_DEPTH_TEST); glClear (GL_DEPTH_BUFFER_BIT); m_pResourceManager->GetGLMan()->SetOrthographicView(sWidth, sHeight); glColor4f(color[0] * state.tintr, color[1] * state.tintg, color[2] * state.tintb, color[3] * state.alpha); SetBlendMode(); glBindTexture(GL_TEXTURE_2D, tex_glid); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex2f(0.0, sHeight); glTexCoord2f(1.0, 1.0); glVertex2f(sWidth, sHeight); glTexCoord2f(1.0, 0.0); glVertex2f(sWidth, 0.0); glEnd(); }
Vector2 SegmentShape2D::GetRotatedDirection() { if (revision != GetSpatialRevision()) UpdateParameters(); return rotatedDirection; }
static void OnCloseClicked(gcc_unused WndButton &button) { UpdateParameters(false); // make sure changes are sent to device wf->SetModalResult(mrOK); }
void FSlateD3DVS::BindParameters() { UpdateParameters(); if( ShaderBindings.ResourceViews.Num() > 0 ) { ID3D11ShaderResourceView** const Views = new ID3D11ShaderResourceView*[ ShaderBindings.ResourceViews.Num() ]; for( int32 I = 0; I < ShaderBindings.ResourceViews.Num(); ++I ) { Views[I] = ShaderBindings.ResourceViews[I]->GetParameter().GetReference(); } GD3DDeviceContext->VSSetShaderResources(0, ShaderBindings.ResourceViews.Num(), Views); delete[] Views; } if( ShaderBindings.ConstantBuffers.Num() > 0 ) { const uint32 BufferCount = ShaderBindings.ConstantBuffers.Num(); ID3D11Buffer** const ConstantBuffers = new ID3D11Buffer*[ BufferCount ]; for( uint32 I = 0; I < BufferCount; ++I ) { ConstantBuffers[I] = ShaderBindings.ConstantBuffers[I]->GetParameter().GetReference(); } GD3DDeviceContext->VSSetConstantBuffers(0, ShaderBindings.ConstantBuffers.Num(), ConstantBuffers); delete[] ConstantBuffers; } }
Vector2 SegmentShape2D::GetEndPoint() { if (revision != GetSpatialRevision()) UpdateParameters(); return endPoint; }
static void PageSwitched() { wf->SetCaption(captions[tabbed->GetCurrentPage()]); UpdateParameters(false); }
void CMIDIMappingDialog::UpdateDialog(int selItem) //------------------------------------------------ { CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CHECK_PATRECORD, m_Setting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); m_ChannelCBox.SetCurSel(m_Setting.GetChannel()); m_EventCBox.SetCurSel(-1); for(int i = 0; i < m_EventCBox.GetCount(); i++) { if(m_EventCBox.GetItemData(i) == m_Setting.GetEvent()) { m_EventCBox.SetCurSel(i); break; } } m_ControllerCBox.SetCurSel(m_Setting.GetController()); m_PluginCBox.SetCurSel(m_Setting.GetPlugIndex() - 1); m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); UpdateEvent(); UpdateParameters(); const bool enableMover = selItem >= 0 && ( (selItem > 0 && m_rMIDIMapper.AreOrderEqual(selItem - 1, selItem)) || (selItem + 1 < m_List.GetItemCount() && m_rMIDIMapper.AreOrderEqual(selItem, selItem + 1))); m_SpinMoveMapping.EnableWindow(enableMover); }
static void OnDemoClicked(gcc_unused WndButton &Sender) { // retrieve changes from form UpdateParameters(false); dlgVegaDemoShowModal(); }
static void OnDemoClicked(WindowControl * Sender) { (void)Sender; // retrieve changes from form UpdateParameters(false); dlgVegaDemoShowModal(); }
void moSceneEffect::Update( moEventList* p_EventList ) { UpdateParameters(); moMoldeoObject::Update(p_EventList); }
void CMIDIMappingDialog::OnCbnSelchangeComboPlugin() //-------------------------------------------------- { int i = m_PluginCBox.GetCurSel(); if(i < 0 || i >= MAX_MIXPLUGINS) return; m_Setting.SetPlugIndex(i+1); UpdateParameters(); }
void ForceFeedbackDevice::TypedForce<P>::UpdateEffect(int magnitude) { if (UpdateParameters(magnitude)) { if (magnitude) PlayEffect(); else StopEffect(); } }
static void OnSaveClicked(gcc_unused WndButton &Sender) { UpdateParameters(false); // make sure changes are sent to device VarioWriteNMEA(_T("PDVSC,S,StoreToEeprom,2")); if (!is_simulator()) Sleep(500); }
static void OnSaveClicked(WindowControl * Sender) { (void)Sender; UpdateParameters(false); // make sure changes are sent to device VarioWriteNMEA(_T("PDVSC,S,StoreToEeprom,2")); if (!is_simulator()) Sleep(500); }
void CAESound::SoundHasFinished() { UpdateParameters(-1); m_isUsed = 0; if (m_physicalEntity) { m_physicalEntity->CleanUpOldReference(&m_physicalEntity); m_physicalEntity = NULL; } field_5E = 0; m_currentPlayPosition = 0; }
bool Texture3D::Create() { Release(); #ifdef GL_ES_VERSION_2_0 URHO3D_LOGERROR("Failed to create 3D texture, currently unsupported on OpenGL ES 2"); return false; #else if (!graphics_ || !width_ || !height_ || !depth_) return false; if (graphics_->IsDeviceLost()) { URHO3D_LOGWARNING("Texture creation while device is lost"); return true; } unsigned format = GetSRGB() ? GetSRGBFormat(format_) : format_; unsigned externalFormat = GetExternalFormat(format_); unsigned dataType = GetDataType(format_); glGenTextures(1, &object_.name_); // Ensure that our texture is bound to OpenGL texture unit 0 graphics_->SetTextureForUpdate(this); // If not compressed, create the initial level 0 texture with null data bool success = true; if (!IsCompressed()) { glGetError(); glTexImage3D(target_, 0, format, width_, height_, depth_, 0, externalFormat, dataType, 0); if (glGetError()) { URHO3D_LOGERROR("Failed to create texture"); success = false; } } // Set mipmapping levels_ = CheckMaxLevels(width_, height_, depth_, requestedLevels_); glTexParameteri(target_, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(target_, GL_TEXTURE_MAX_LEVEL, levels_ - 1); // Set initial parameters, then unbind the texture UpdateParameters(); graphics_->SetTexture(0, 0); return success; #endif }
void MyProject::OnNextEditPattern(const axButtonMsg& msg) { int num = _numberPanel->GetNumber(); ++num; if(num > 16) { num = 1; } _numberPanel->SetNumber(num); UpdateParameters(num - 1); }
void MyProject::OnBackEditPattern(const axButtonMsg& msg) { int num = _numberPanel->GetNumber(); --num; if(num < 1) { num = 16; } _numberPanel->SetNumber(num); UpdateParameters(num - 1); }
/* EstimateModel: top level of iterative estimation process */ void EstimateModel(void) { LogFloat totalP,newP,delta; Boolean converged = FALSE; int i,iter,numSegs,segLen; IntVec states; /* array[1..numSegs] of State */ IntVec *mixes; /* array[1..S][1..numSegs] of MixComp */ if (trace&T_TOP) printf("Starting Estimation Process\n"); if (newModel){ UniformSegment(); } totalP=LZERO; for (iter=1; !converged && iter<=maxIter; iter++){ ZeroAccs(&hset, uFlags); /* Clear all accumulators */ numSegs = NumSegs(segStore); /* Align on each training segment and accumulate stats */ for (newP=0.0,i=1;i<=numSegs;i++) { segLen = SegLength(segStore,i); states = CreateIntVec(&gstack,segLen); mixes = (hset.hsKind==DISCRETEHS)?NULL: CreateMixes(&gstack,segLen); newP += ViterbiAlign(i,segLen,states,mixes); if (trace&T_ALN) ShowAlignment(i,segLen,states,mixes); UpdateCounts(i,segLen,states,mixes); FreeIntVec(&gstack,states); /* disposes mixes too */ } /* Update parameters or quit */ newP /= (float)numSegs; delta = newP - totalP; converged = (iter>1) && (fabs(delta) < epsilon); if (!converged) UpdateParameters(); totalP = newP; if (trace & T_TOP){ printf("Iteration %d: Average LogP =%12.5f",iter,totalP); if (iter > 1) printf(" Change =%12.5f\n",delta); else printf("\n"); fflush(stdout); } } if (trace&T_TOP) { if (converged) printf("Estimation converged at iteration %d\n",iter); else printf("Estimation aborted at iteration %d\n",iter); fflush(stdout); } }
// Executed after Init, before game boot void Preset(bool _bNTSC) { m_VerticalTimingRegister.EQU = 6; m_DisplayControlRegister.ENB = 1; m_DisplayControlRegister.FMT = _bNTSC ? 0 : 1; m_HTiming0.HLW = 429; m_HTiming0.HCE = 105; m_HTiming0.HCS = 71; m_HTiming1.HSY = 64; m_HTiming1.HBE640 = 162; m_HTiming1.HBS640 = 373; m_VBlankTimingOdd.PRB = 502; m_VBlankTimingOdd.PSB = 5; m_VBlankTimingEven.PRB = 503; m_VBlankTimingEven.PSB = 4; m_BurstBlankingOdd.BS0 = 12; m_BurstBlankingOdd.BE0 = 520; m_BurstBlankingOdd.BS2 = 12; m_BurstBlankingOdd.BE2 = 520; m_BurstBlankingEven.BS0 = 13; m_BurstBlankingEven.BE0 = 519; m_BurstBlankingEven.BS2 = 13; m_BurstBlankingEven.BE2 = 519; m_InterruptRegister[0].HCT = 430; m_InterruptRegister[0].VCT = 263; m_InterruptRegister[0].IR_MASK = 1; m_InterruptRegister[0].IR_INT = 0; m_InterruptRegister[1].HCT = 1; m_InterruptRegister[1].VCT = 1; m_InterruptRegister[1].IR_MASK = 1; m_InterruptRegister[1].IR_INT = 0; m_HorizontalStepping.FbSteps = 40; m_HorizontalStepping.FieldSteps = 40; m_HBeamPos = -1; // NTSC-U N64 VC games check for a non-zero HBeamPos m_VBeamPos = 0; // RG4JC0 checks for a zero VBeamPos // 54MHz, capable of progressive scan m_Clock = Core::g_CoreStartupParameter.bProgressive; // Say component cable is plugged m_DTVStatus.component_plugged = Core::g_CoreStartupParameter.bProgressive; UpdateParameters(); }
void SGBM_cpu::Compute(Mat left,Mat right,Mat& disp) { UpdateParameters(); imgL = left; imgR = right; ScaleImages(); RectifyImages(); sgbm(imgL, imgR, disp); resize(disp,disp,Size(),SHOW_SCALE,SHOW_SCALE,INTER_AREA); if(STORE_RESULTS) StoreResults(disp,imgL,imgR); return; }
MOboolean moDeformationGrid::Init() { if (!PreInit()) return false; moDefineParamIndex( DEFORMATIONGRID_ALPHA, moText("alpha") ); moDefineParamIndex( DEFORMATIONGRID_COLOR, moText("color") ); moDefineParamIndex( DEFORMATIONGRID_SYNC, moText("syncro") ); moDefineParamIndex( DEFORMATIONGRID_PHASE, moText("phase") ); moDefineParamIndex( DEFORMATIONGRID_TEXTURE, moText("texture") ); moDefineParamIndex( DEFORMATIONGRID_WIDTH, moText("width") ); moDefineParamIndex( DEFORMATIONGRID_HEIGHT, moText("height") ); moDefineParamIndex( DEFORMATIONGRID_POINTS, moText("points") ); moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_X1, moText("texcoord_x1") ); moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_Y1, moText("texcoord_y1") ); moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_X2, moText("texcoord_x2") ); moDefineParamIndex( DEFORMATIONGRID_TEXCOORD_Y2, moText("texcoord_y2") ); moDefineParamIndex( DEFORMATIONGRID_TRANSLATEX, moText("translatex") ); moDefineParamIndex( DEFORMATIONGRID_TRANSLATEY, moText("translatey") ); moDefineParamIndex( DEFORMATIONGRID_TRANSLATEZ, moText("translatez") ); moDefineParamIndex( DEFORMATIONGRID_ROTATEX, moText("rotatex") ); moDefineParamIndex( DEFORMATIONGRID_ROTATEY, moText("rotatey") ); moDefineParamIndex( DEFORMATIONGRID_ROTATEZ, moText("rotatez") ); moDefineParamIndex( DEFORMATIONGRID_SCALEX, moText("scalex") ); moDefineParamIndex( DEFORMATIONGRID_SCALEY, moText("scaley") ); moDefineParamIndex( DEFORMATIONGRID_SCALEZ, moText("scalez") ); moDefineParamIndex( DEFORMATIONGRID_SHOWGRID, moText("showgrid") ); moDefineParamIndex( DEFORMATIONGRID_CLEAR, moText("clear") ); moDefineParamIndex( DEFORMATIONGRID_PRECISION, moText("precision") ); moDefineParamIndex( DEFORMATIONGRID_MODE, moText("mode") ); m_Width = 0; m_Height = 0; pImage = NULL; m_Points = NULL; m_TPoints = NULL; UpdateParameters(); m_Selector_I = 0; m_Selector_J = 0; m_Modo = (moDeformationGridMode)m_Config.Int( moR(DEFORMATIONGRID_MODE) ); return true; }
MOboolean moPostEffectColorFilter::Init() { if (!PreInit()) return false; moDefineParamIndex( COLORFILTER_COLOR, moText("color") ); moDefineParamIndex( COLORFILTER_BLENDING, moText("blending") ); moDefineParamIndex( COLORFILTER_SENSIBILITY, moText("sensibility") ); moDefineParamIndex( COLORFILTER_SYNCRO, moText("syncro") ); UpdateParameters(); moTextArray filter_str; filter_str.Init(1, moText("")); filter_str.Set(0, moText("effects_texture shaders/ColorMatrix.cfg colorfilter_texture")); bool res = filters.Init(&filter_str, m_pResourceManager->GetGLMan(), m_pResourceManager->GetFBMan(), m_pResourceManager->GetShaderMan(), m_pResourceManager->GetTextureMan(), m_pResourceManager->GetRenderMan()); int tex_moid = m_pResourceManager->GetTextureMan()->GetTextureMOId("colorfilter_texture", false); tex_glid = m_pResourceManager->GetTextureMan()->GetGLId(tex_moid); if (!res) { MODebug->Push("Error: cannot load shader in colorfilter"); return false; } FilterParams = MOEmptyTexFilterParam; ColorMatrix.Init(); HSIMatrix.Init(true, 0.0, 4.0, 0.0, 4.0); BCMatrix.Init(-1.0, 1.0, 0.0, 4.0); intensity0 = saturation0 = intensity = saturation = 0.25; hue0 = hue = 0.0; brightness0 = brightness = 0.5; contrast0 = contrast = 0.25; HSIMatrix.Update(intensity, saturation, hue); BCMatrix.Update(brightness, contrast); ColorMatrix.Copy(HSIMatrix); ColorMatrix.Multiply(BCMatrix); FilterParams.par_mat4 = ColorMatrix.GetMatrixPointer(); sWidth = m_pResourceManager->GetRenderMan()->RenderWidth(); sHeight = m_pResourceManager->GetRenderMan()->RenderHeight(); if(m_Config.GetPreConfCount() > 0) m_Config.PreConfFirst(); return true; }
void FSlateD3DGeometryShader::BindParameters() { UpdateParameters(); if( ShaderBindings.ConstantBuffers.Num() ) { const uint32 BufferCount = ShaderBindings.ConstantBuffers.Num(); ID3D11Buffer** const ConstantBuffers = new ID3D11Buffer*[ BufferCount ]; for( uint32 I = 0; I < BufferCount; ++I ) { ConstantBuffers[I] = ShaderBindings.ConstantBuffers[I]->GetParameter().GetReference(); } GD3DDeviceContext->GSSetConstantBuffers(0, ShaderBindings.ConstantBuffers.Num(), ConstantBuffers); delete[] ConstantBuffers; } }
template <class T> double GaussNewton<T>::Fit(DArray &c) { double sum = 0.; DArray res(x_.size(), 0.); DMatrix jac(x_.size(), t_.GetC()), dc(1, t_.GetC()); do { //break; ComputeResiduals(res); ComputeJacobian(jac); ComputeDeltas(jac, res, dc); cerr << "Deltas: " << endl; PrintMatrix(dc); } while(RoundToZero(UpdateParameters(dc, c)) != 0.); ComputeResiduals(res); for(int i = 0; i < res.size(); ++i) { sum += res[i] * res[i]; } return sqrt(sum); }
void Init() { m_VerticalTimingRegister.Hex = 0; m_DisplayControlRegister.Hex = 0; m_HTiming0.Hex = 0; m_HTiming1.Hex = 0; m_VBlankTimingOdd.Hex = 0; m_VBlankTimingEven.Hex = 0; m_BurstBlankingOdd.Hex = 0; m_BurstBlankingEven.Hex = 0; m_XFBInfoTop.Hex = 0; m_XFBInfoBottom.Hex = 0; m_3DFBInfoTop.Hex = 0; m_3DFBInfoBottom.Hex = 0; m_VBeamPos = 0; m_HBeamPos = 0; m_HorizontalStepping.Hex = 0; m_HorizontalScaling.Hex = 0; m_UnkAARegister = 0; m_Clock = 0; m_DTVStatus.Hex = 0; m_FBWidth = 0; m_BorderHBlank.Hex = 0; memset(&m_FilterCoefTables, 0, sizeof(m_FilterCoefTables)); fields = 1; m_DTVStatus.ntsc_j = Core::g_CoreStartupParameter.bForceNTSCJ; for (int i = 0; i < 4; i++) m_InterruptRegister[i].Hex = 0; for (int i = 0; i < 2; i++) m_LatchRegister[i].Hex = 0; m_DisplayControlRegister.Hex = 0; UpdateParameters(); }
bool Texture2D::Create() { Release(); if (!graphics_ || !width_ || !height_) return false; if (graphics_->IsDeviceLost()) { URHO3D_LOGWARNING("Texture creation while device is lost"); return true; } #ifdef GL_ES_VERSION_2_0 if (multiSample_ > 1) { URHO3D_LOGWARNING("Multisampled texture is not supported on OpenGL ES"); multiSample_ = 1; autoResolve_ = false; } #endif unsigned format = GetSRGB() ? GetSRGBFormat(format_) : format_; unsigned externalFormat = GetExternalFormat(format_); unsigned dataType = GetDataType(format_); // Create a renderbuffer instead of a texture if depth texture is not properly supported, or if this will be a packed // depth stencil texture #ifndef GL_ES_VERSION_2_0 if (format == Graphics::GetDepthStencilFormat()) #else if (format == GL_DEPTH_COMPONENT16 || format == GL_DEPTH_COMPONENT24_OES || format == GL_DEPTH24_STENCIL8_OES || (format == GL_DEPTH_COMPONENT && !graphics_->GetShadowMapFormat())) #endif { if (renderSurface_) { renderSurface_->CreateRenderBuffer(width_, height_, format, multiSample_); return true; } else return false; } else { if (multiSample_ > 1) { if (autoResolve_) { // Multisample with autoresolve: create a renderbuffer for rendering, but also a texture renderSurface_->CreateRenderBuffer(width_, height_, format, multiSample_); } else { // Multisample without autoresolve: create a texture only #ifndef GL_ES_VERSION_2_0 if (!Graphics::GetGL3Support() && !GLEW_ARB_texture_multisample) { URHO3D_LOGERROR("Multisampled texture extension not available"); return false; } target_ = GL_TEXTURE_2D_MULTISAMPLE; if (renderSurface_) renderSurface_->target_ = GL_TEXTURE_2D_MULTISAMPLE; #endif } } } glGenTextures(1, &object_.name_); // Ensure that our texture is bound to OpenGL texture unit 0 graphics_->SetTextureForUpdate(this); // If not compressed, create the initial level 0 texture with null data bool success = true; if (!IsCompressed()) { glGetError(); #ifndef GL_ES_VERSION_2_0 if (multiSample_ > 1 && !autoResolve_) glTexImage2DMultisample(target_, multiSample_, format, width_, height_, GL_TRUE); else #endif glTexImage2D(target_, 0, format, width_, height_, 0, externalFormat, dataType, 0); if (glGetError()) { URHO3D_LOGERROR("Failed to create texture"); success = false; } } // Set mipmapping if (usage_ == TEXTURE_DEPTHSTENCIL) requestedLevels_ = 1; else if (usage_ == TEXTURE_RENDERTARGET) { #ifdef __EMSCRIPTEN__ // glGenerateMipmap appears to not be working on WebGL, disable rendertarget mipmaps for now requestedLevels_ = 1; #else if (requestedLevels_ != 1) { // Generate levels for the first time now RegenerateLevels(); // Determine max. levels automatically requestedLevels_ = 0; } #endif } levels_ = CheckMaxLevels(width_, height_, requestedLevels_); #ifndef GL_ES_VERSION_2_0 glTexParameteri(target_, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(target_, GL_TEXTURE_MAX_LEVEL, levels_ - 1); #endif // Set initial parameters, then unbind the texture UpdateParameters(); graphics_->SetTexture(0, 0); return success; }
void moDeformationGrid::Draw( moTempo* tempogral, moEffectState* parentstate ) { MOint indeximage; int ancho,alto; int w = m_pResourceManager->GetRenderMan()->ScreenWidth(); int h = m_pResourceManager->GetRenderMan()->ScreenHeight(); UpdateParameters(); PreDraw( tempogral, parentstate); if (clear) { glClearColor(0.0,0.0,0.0,1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } glDisable(GL_DEPTH_TEST); // Disables Depth Testing glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(-0.5,0.5,-0.5*h/w,0.5*h/w,-1,1); // Set Up An Ortho Screen /* glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // glOrtho(0,w,0,h,-1,1); // Set Up An Ortho Screen m_pResourceManager->GetGLMan()->SetPerspectiveView( w, h ); glMatrixMode(GL_PROJECTION); gluLookAt( 0, 0, 10.0, 0, 0, 0, 0, 1, 0); */ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); // Reset The View glTranslatef( m_Config[moR(DEFORMATIONGRID_TRANSLATEX)].GetData()->Fun()->Eval(state.tempo.ang), m_Config[moR(DEFORMATIONGRID_TRANSLATEY)].GetData()->Fun()->Eval(state.tempo.ang), m_Config[moR(DEFORMATIONGRID_TRANSLATEZ)].GetData()->Fun()->Eval(state.tempo.ang)); glRotatef( m_Config[moR(DEFORMATIONGRID_ROTATEX)].GetData()->Fun()->Eval(state.tempo.ang), 1.0, 0.0, 0.0 ); glRotatef( m_Config[moR(DEFORMATIONGRID_ROTATEY)].GetData()->Fun()->Eval(state.tempo.ang), 0.0, 1.0, 0.0 ); glRotatef( m_Config[moR(DEFORMATIONGRID_ROTATEZ)].GetData()->Fun()->Eval(state.tempo.ang), 0.0, 0.0, 1.0 ); glScalef( m_Config[moR(DEFORMATIONGRID_SCALEX)].GetData()->Fun()->Eval(state.tempo.ang), m_Config[moR(DEFORMATIONGRID_SCALEY)].GetData()->Fun()->Eval(state.tempo.ang), m_Config[moR(DEFORMATIONGRID_SCALEZ)].GetData()->Fun()->Eval(state.tempo.ang)); SetColor( m_Config[moR(DEFORMATIONGRID_COLOR)][MO_SELECTED], m_Config[moR(DEFORMATIONGRID_ALPHA)][MO_SELECTED], state ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D,m_Config[moR(DEFORMATIONGRID_TEXTURE)].GetData()->GetGLId(&state.tempo) ); if (m_Points && m_TPoints) for(int j=0; j< (m_Height-1); j++) { glBegin(GL_QUAD_STRIP); for( int i=0; i < m_Width; i++ ) { glTexCoord2f( m_TPoints[i + j * m_Width].X(), m_TPoints[i + j * m_Width].Y() ); glVertex2f( m_Points[i + j * m_Width].X(), m_Points[i + j * m_Width].Y() ); glTexCoord2f( m_TPoints[i + (j+1) * m_Width].X(), m_TPoints[i + (j+1) * m_Width].Y() ); glVertex2f( m_Points[i + (j+1) * m_Width].X(), m_Points[i + (j+1) * m_Width].Y() ); } glEnd(); } if (showgrid>0) { glDisable( GL_TEXTURE_2D ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); for(int j=0; j< m_Height; j++) { for( int i=0; i < m_Width; i++ ) { glColor4f( 0.0, 1.0, 0.0, 1.0); glBegin(GL_QUADS); glVertex2f( m_Points[i + j * m_Width].X() -0.002, m_Points[i + j * m_Width].Y() +0.002); glVertex2f( m_Points[i + j * m_Width].X()+0.002, m_Points[i + j * m_Width].Y() +0.002); glVertex2f( m_Points[i + j * m_Width].X()+0.002, m_Points[i + j * m_Width].Y() -0.002 ); glVertex2f( m_Points[i + j * m_Width].X() -0.002, m_Points[i + j * m_Width].Y() -0.002 ); glEnd(); if ( m_Selector_I == i && m_Selector_J == j ) { glColor4f( 1.0, 1.0, 0.0, 1.0); glBegin(GL_QUADS); glVertex2f( m_Points[i + j * m_Width].X() -0.01, m_Points[i + j * m_Width].Y() +0.01); glVertex2f( m_Points[i + j * m_Width].X()+0.01, m_Points[i + j * m_Width].Y() +0.01); glVertex2f( m_Points[i + j * m_Width].X()+0.01, m_Points[i + j * m_Width].Y() -0.01 ); glVertex2f( m_Points[i + j * m_Width].X() -0.01, m_Points[i + j * m_Width].Y() -0.01 ); glEnd(); } } } glEnable( GL_TEXTURE_2D ); } /* glBegin (GL_QUADS); glTexCoord2f( PosTextX0, PosTextY1); glVertex3f (-7.69, 5.77, 0); glTexCoord2f( PosTextX1, PosTextY1); glVertex3f (7.69, 5.77, 0); glTexCoord2f( PosTextX1, PosTextY0); glVertex3f (7.69, -5.77, 0); glTexCoord2f( PosTextX0, PosTextY0); glVertex3f (-7.69, -5.77, 0); glEnd(); */ //MODebug2->Push(IntToStr(showgrid)); if (showgrid>0) { ///DRAW THE REFERENCE GRID TO SEE THE DEFORMATION RESULT /*** * for each vertex in the value index selected for the POINTS parameters * draw */ glColor4f(1.0,1.0,1.0,1.0); glDisable( GL_TEXTURE_2D ); glLineWidth( 1.0 ); glBegin (GL_LINES); glVertex3f (-0.25, h/w / 4, 0); glVertex3f (0.25, -h/w / 4, 0); glEnd (); glBegin (GL_LINES); glVertex3f (h/w / 4, h/w / 4, 0); glVertex3f (-h/w / 4, -h/w / 4, 0); glEnd (); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); glBegin (GL_QUADS); glVertex3f (-0.5, h/w / 2, 0); glVertex3f (0.5, h/w / 2, 0); glVertex3f (0.5, -h/w / 2, 0); glVertex3f (-0.5, -h/w / 2, 0); glEnd (); glScalef(1.2,1.2,0); glBegin (GL_QUADS); glVertex3f (-0.5, h/w / 2, 0); glVertex3f (0.5, h/w / 2, 0); glVertex3f (0.5, -h/w / 2, 0); glVertex3f (-0.5, -h/w / 2, 0); glEnd (); } glLineWidth( 1.0 ); glEnable( GL_TEXTURE_2D ); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); }