bool Place(Content<_T> content) { Sort(); for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) { content.coord = *itor; if( Fits( content ) ) { Use( content ); topLefts.erase( itor ); return true; } } // EXPERIMENTAL - TRY ROTATED? content.Rotate(); for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) { content.coord = *itor; if( Fits( content ) ) { Use( content ); topLefts.erase( itor ); return true; } } //////////////////////////////// return false; }
void Level1Algo::reset() { m_boardData.assign(m_boardData.size(), 0); m_thisUse.assign(m_thisUse.size(), Use()); m_peerUse.assign(m_peerUse.size(), Use()); m_deadWinSet.clear(); m_peerDeadWinSet.clear(); m_isFirst = true; }
void Level1Algo::init(int sz) { m_sz = sz; m_boardData.resize(sz * sz, 0); WinSets_Level1::getSingletonPtr()->setEnvNxN(sz); int cnt = WinSets_Level1::getSingletonPtr()->getWinSetCount(); m_thisUse.resize(cnt, Use()); m_peerUse.resize(cnt, Use()); }
nResult n2dFontImpl::PrintFont(n2dGraphics2D* pGraphic, ncTStr str, nFloat x, nFloat y, nFloat scale, n2dTexture* pTexture) { if (!m_pFTLib) { return NatErr_IllegalState; } nBool shouldEnd; auto pUsingProgram = m_pRenderer->GetShaderWrapper()->GetCurrentProgram(); auto pFontProgram = m_pRenderer->GetShaderWrapper()->GetFontProgram(); if (pGraphic->IsRendering()) { shouldEnd = false; pGraphic->Flush(); } else { shouldEnd = true; pGraphic->Begin(); } m_pRenderer->PushMVPMat(); m_pRenderer->InitMVPMat(); auto window = m_pRenderer->GetEngine()->GetWindow(); m_pRenderer->SubmitProjMat(natTransform::ortho(0.0f, static_cast<nFloat>(window->GetWidth()), 0.0f, static_cast<nFloat>(window->GetHeight()))); auto scope = make_scope([shouldEnd, pGraphic, pUsingProgram, this] { if (shouldEnd) { pGraphic->End(); } else { pGraphic->Flush(); } m_pRenderer->PopMVPMat(); pUsingProgram->Use(); }); pFontProgram->Use(); GLint textureID = 0; pFontProgram->GetUniformReference(1)->SetValue(1, &textureID); textureID = 1; pFontProgram->GetUniformReference(2)->SetValue(1, &textureID); GLint useTexture = GL_TRUE; pFontProgram->GetUniformReference(3)->SetValue(1, &useTexture); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, pTexture->GetTextureID()); return PrintFontImpl(pGraphic, str, x, y, scale); }
nResult n2dFontImpl::PrintFont(n2dGraphics2D* pGraphic, ncTStr str, nFloat x, nFloat y, nFloat scale, natVec3<> const& color) { if (!m_pFTLib) { return NatErr_IllegalState; } nBool shouldEnd; auto pUsingProgram = m_pRenderer->GetShaderWrapper()->GetCurrentProgram(); auto pFontProgram = m_pRenderer->GetShaderWrapper()->GetFontProgram(); if (pGraphic->IsRendering()) { shouldEnd = false; pGraphic->Flush(); } else { shouldEnd = true; pGraphic->Begin(); } m_pRenderer->PushMVPMat(); m_pRenderer->InitMVPMat(); auto window = m_pRenderer->GetEngine()->GetWindow(); m_pRenderer->SubmitProjMat(natTransform::ortho(0.0f, static_cast<nFloat>(window->GetWidth()), 0.0f, static_cast<nFloat>(window->GetHeight()))); auto scope = make_scope([shouldEnd, pGraphic, pUsingProgram, this] { if (shouldEnd) { pGraphic->End(); } else { pGraphic->Flush(); } m_pRenderer->PopMVPMat(); pUsingProgram->Use(); }); pFontProgram->Use(); GLint textureID = 0; GLint useTexture = GL_FALSE; //auto p = static_cast<n2dShaderProgramImpl::UniformReferenceImpl*>(pFontProgram->GetUniformReference(_T("textColor"))); //m_pRenderer->GetEngine()->GetLogger().LogMsg(_T("textColor: {0}, type: {1}"), p->GetLocation(), static_cast<nuInt>(p->GetType())); pFontProgram->GetUniformReference(1)->SetValue(1, &textureID); pFontProgram->GetUniformReference(3)->SetValue(1, &useTexture); pFontProgram->GetUniformReference(4)->SetValue(1, &color); return PrintFontImpl(pGraphic, str, x, y, scale); }
void Program::Uniforms(const std::unordered_map<std::string, const glm::mat4 *> &&uniforms) { Use(); for (auto &uniform : uniforms) { glUniformMatrix4fv(GetUniformLocation(uniform.first), 1, false, &uniform.second->operator[](0)[0]); } }
void OGLSpotLight::Render(double time) { glClear(GL_DEPTH_BUFFER_BIT); glm::vec3 bgColor(0.2f); glClearBufferfv(GL_COLOR, 0, &bgColor[0]); camera.Update(); light.position = camera.GetPosition(); light.direction = camera.GetForwardDirection(); // Render container auto programMesh = programs[0]; programMesh->Use(); SendLightUniform(programMesh.get()); glm::mat4 model = glm::mat4(1); for (size_t i = 0; i < 10; i++) { float sign = (i % 2) * 2 - 1.0f; model = glm::mat4(1); model = glm::rotate(model, i * 0.2f * glm::two_pi<float>(), glm::vec3(0, 1, 0)) * glm::translate(model, glm::vec3(20, 0, 20)); model = glm::scale(glm::rotate(glm::translate(glm::mat4(1), cubePositions[i]), glm::radians(sign * 30.0f), cubePositions[i]), glm::vec3(10)); SendMatricesUniform(programMesh.get(), model); vaos[0]->BindVAO(); vbos[0]->BindVBO(); textures[0]->BindTexture(GL_TEXTURE0); textures[1]->BindTexture(GL_TEXTURE3); glUniform1f(programMesh->GetUniform("material.shininess"), 32.0f); glDrawArrays(GL_TRIANGLES, 0, 36); } }
void Gizmo3D::Update(Vector<Node *> &editNodes) { editNodes_ = &editNodes; Use(); Position(); }
void LabelElement::Render() { auto m = GetMetrics(); auto gui = GUI::Get(); auto textProgram = ShaderRegistry::GetProgram("text"); textProgram->Use(); gui->camera->SetUniforms(textProgram.get()); glUniform4f(textProgram->GetUniform("color"), 1,1,1, 1); auto size = m->topRight - m->bottomLeft; auto scalexy = size/textMesh->size; auto scale = std::min(scalexy.x, scalexy.y); auto tmbl = m->bottomLeft + vec2{0, textMesh->size.y * scalexy.y}; Debug::PointUI(m->topRight); Debug::PointUI(m->bottomLeft); Debug::PointUI(m->bottomLeft + vec2{0, textMesh->size.y * scale}, vec3{1,1,0}); Debug::PointUI(tmbl, vec3{1,0,0}); Debug::PointUI(tmbl + textMesh->size * vec2{1,-1} * scale, vec3{0,1,0}); Debug::PointUI(tmbl + textMesh->size * vec2{1,-1} * scale * .5f, vec3{0,0,1}); textMesh->modelMatrix = glm::translate(vec3{tmbl, 0}) * glm::scale(vec3{scale}); textMesh->Render(); }
bool Place(Content<_T> content) { Sort(); for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) { content.coord = *itor; if( Fits( content ) ) { Use( content ); topLefts.erase( itor ); return true; } } return false; // yvt: BitmapAtlasGenerator doesn't support rotated contents. // EXPERIMENTAL - TRY ROTATED? // content.Rotate(); // for(Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++) // { // content.coord = *itor; // if( Fits( content ) ) // { // Use( content ); // topLefts.erase( itor ); // return true; // } // } // //////////////////////////////// // return false; }
int main(int argc, char *argv[]) { int sock, x = 0; char *Path = argv[1], *Pro_Sea = argv[2], *Host = argv[3]; puts("[+] NsT-phpBBDoS v0.1 by HaCkZaTaN"); puts("[+] NeoSecurityTeam"); puts("[+] Dos has begun....[+]\n"); fflush(stdout); if(argc != 4) Use(argv[0]); while(1) { sock = Connection(Host,80); Write_In(sock, Path, Pro_Sea, Host, x); #ifndef WIN32 shutdown(sock, SHUT_WR); close(sock); #else closesocket(sock); WSACleanup(); #endif Pro_Sea = argv[2]; x++; } //I don't think that it will get here =) return 0; }
TOD_Turn_Data::TOD_Turn_Data (void) { Start (0); End (0); Use (0); Penalty (0); TOD_List (0); }
void Texture::OnDraw(int x, int y) const { glColor4f(1, 1, 1, 1); // Should be black? auto shader = _vid.GetShader(0); shader->Use(); // Update parameters glUniform1i(shader->grad_shift_id, 0); float recols[] = { 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, }; glUniform3fv(shader->recolour, 2, recols); int *pos_id = &shader->pos_id; int *texcoord_id = &shader->tex_coord; // If there's no mask, maskid is bound to the 0 texture, so ends up being a no-op. glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, this->maskid); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, this->texid); float left = x; float right = x + this->width; float top = y; float bottom = y + this->height; float vertices[] = { left, top, 0, 0, // top-left right, top, 1, 0, // top-right left, bottom, 0, 1, // bottom-left right, top, 1, 0, // top-right left, bottom, 0, 1, // bottom-left right, bottom, 1, 1, // bottom-right }; glBindBuffer(GL_ARRAY_BUFFER, this->vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW); glEnableVertexAttribArray(*pos_id); glEnableVertexAttribArray(*texcoord_id); glVertexAttribPointer(*pos_id, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(0)); glVertexAttribPointer(*texcoord_id, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(2 * sizeof(float))); glDrawArrays(GL_TRIANGLES, 0, 6); // 2 triangles /* Clean up */ glDisableVertexAttribArray(*pos_id); glDisableVertexAttribArray(*texcoord_id); glBindBuffer(GL_ARRAY_BUFFER, 0); shader->StopUsing(); }
void CTriggerHurt :: Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; UTIL_SetModel(ENT(pev), pev->model); UTIL_SetOrigin( this, pev->origin ); SetBits( pev->effects, EF_NODRAW ); m_iState = STATE_OFF; if (!FBitSet(pev->spawnflags, 2 )) Use( this, this, USE_ON, 0 ); }
bool OGLSpotLight::AddProgram(const std::string & vsFilename, const std::string & fsFilename) { bool res = true; auto program = std::make_shared<gs::Program>(); res &= program->CreateShader(GL_VERTEX_SHADER, vsFilename); res &= program->CreateShader(GL_FRAGMENT_SHADER, fsFilename); res &= program->Link(); program->Use(); programs.push_back(program); return res; }
Link_Data::Link_Data (int link) : Class_Index (link) { Anode (0); Bnode (0); Length (0); Aoffset (0); Boffset (0); Use (0); Type (0); AB_Dir (0); BA_Dir (0); Shape (0); }
Link_Detail_Data::Link_Detail_Data (int link_dir) : Class_Index (link_dir) { Type (0); Control (0); Left (0); Left_Thru (0); Thru (0); Right_Thru (0); Right (0); Use (0); Lanes (0); Period (NULL); }
void Terrain::DrawShadowMap() { auto shader = ShaderStock::GetInstance()->GetTerrainShadowShader(); auto renderState = Device::GetInstance()->GetRenderState(); auto shaderPrev = renderState->GetCurrentShader(); Matrix world; GetWorldMatrix(&world); Matrix mv = world * renderState->GetViewMatrix(); shader->Use(); shader->UsePass(0); shader->SetMatrix("g_mvMatrix", mv); shader->SetMatrix("g_projection", renderState->GetProjectionMatrix()); shader->SetFloat("g_zscale", this->zScale); shader->SetTexture("g_heightMap", this->heightMap.Get()); shader->CommitChanges(); DrawGeometry(); shaderPrev->Use(); }
void CFuncLight :: Spawn( void ) { m_Material = matGlass; CBreakable::Spawn(); SET_MODEL( edict(), GetModel() ); // probably map compiler haven't func_light support if( m_iStyle <= 0 || m_iStyle >= 256 ) { if( GetTargetname()[0] ) ALERT( at_error, "%s with name %s has bad lightstyle %i. Disabled\n", GetClassname(), GetTargetname(), m_iStyle ); else ALERT( at_error, "%s [%i] has bad lightstyle %i. Disabled\n", GetClassname(), entindex(), m_iStyle ); m_iState = STATE_DEAD; // lamp is dead } if( FBitSet( pev->spawnflags, SF_LIGHT_START_ON )) Use( this, this, USE_ON, 0 ); else Use( this, this, USE_OFF, 0 ); if( pev->health <= 0 ) pev->takedamage = DAMAGE_NO; else pev->takedamage = DAMAGE_YES; }
const wxString wxExVCS::GetName() const { if (!Use()) { return wxEmptyString; } else if (wxConfigBase::Get()->ReadLong("VCS", VCS_AUTO) == VCS_AUTO) { return "Auto"; } else { return m_Entry.GetName(); } }
bool wxExVCS::GetDir(wxWindow* parent) { if (!Use()) { return false; } const wxString message = _("Select VCS Folder"); std::vector<wxExConfigItem> v; // See also vcsentry, same item is used there. v.push_back(wxExConfigItem( _("Base folder"), CONFIG_COMBOBOXDIR, wxEmptyString, true, 1005)); if (wxExConfigFirstOf(_("Base folder")).empty()) { if ( parent != NULL && wxExConfigDialog(parent, v, message).ShowModal() == wxID_CANCEL) { return false; } } else { m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder"))); if (m_Entry.GetName().empty()) { if ( parent != NULL && wxExConfigDialog(parent, v, message).ShowModal() == wxID_CANCEL) { return false; } } } m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder"))); return !m_Entry.GetName().empty(); }
FBTexThread(FBTexExample& example) : gl() , prog(make_prog(example)) , projection_matrix(prog, "ProjectionMatrix") , camera_matrix(prog, "CameraMatrix") , model_matrix(prog, "ModelMatrix") , shape(List("Position")("Normal")("TexCoord").Get(), shapes::TwistedTorus(), prog) , tex_side(512) , parent_ready(example.parent_ready) { example.thread_ready = &thread_ready; Uniform<Vec3f>(prog, "LightPos").Set(20.0f, 30.0f, 40.0f); Texture::Active(0); { auto bound_tex = Bind(example.tex, Texture::Target::_2D); bound_tex.Image2D( 0, PixelDataInternalFormat::RGBA, tex_side, tex_side, 0, PixelDataFormat::RGBA, PixelDataType::UnsignedByte, nullptr ); bound_tex.MinFilter(TextureMinFilter::Linear); bound_tex.MagFilter(TextureMagFilter::Linear); bound_tex.WrapS(TextureWrap::Repeat); bound_tex.WrapT(TextureWrap::Repeat); } { auto bound_fbo = Bind(fbo, Framebuffer::Target::Draw); auto bound_rbo = Bind(rbo, Renderbuffer::Target::Renderbuffer); bound_rbo.Storage( PixelDataInternalFormat::DepthComponent, tex_side, tex_side ); bound_fbo.AttachTexture(FramebufferAttachment::Color, example.tex, 0); bound_fbo.AttachRenderbuffer(FramebufferAttachment::Depth, rbo); } Use(); }
DrawLineShader::DrawLineShader() : OpenGLShaderProgram("drawline") { GetLocations(); glGenBuffers(1, &_vbo); glGenVertexArrays(1, &_vao); GLuint vertices[] = { 0, 1 }; glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBindVertexArray(_vao); glEnableVertexAttribArray(vIndex); glVertexAttribIPointer(vIndex, 1, GL_INT, 0, nullptr); Use(); }
/** * Função que obtém o erro médio quadrático de um conjunto de amostras fornecido. */ int BKPNeuralNet::RMS_error( float**inMatrix, float **outMatrix, int inSize, int outSize, int nSamples, float* retRMS_Error ) { // Casos de retorno: if( (!inMatrix) || (!outMatrix) || (inSize!=_nLayers[0]) || (_nLayers[_layers-1]!=outSize) ) return -1; float thisOutput = 0; float RMS_Error_Acum = 0; // Executando os treinamentos obrigatórios: for( int thisSample=0 ; thisSample<nSamples ; thisSample++ ) { Use( inSize, inMatrix[thisSample] ); thisOutput += OutputError(outMatrix[thisSample], outSize); } *retRMS_Error = (thisOutput/nSamples); return 0; }
void Graphics::SetBuffers(bool solid, bool allowInstancing) { VertexBuffer* vBuffer = activeMesh_->GetVertexBuffer(); if (has_vertex_array_object_ext_ && !vBuffer->IsDynamic()) { auto vao = VertexArrayObj::GetOrCreate(VAOKey{allowInstancing, activeProgram_, activeMesh_, solid}); vao->Use(); } else { SetVertexBuffer(vBuffer); SetAttributes(nullptr); if (allowInstancing && activeProgram_->GetMaterial()->IsBatched() && !vBuffer->IsDynamic()) SetInstanceAttrPointers(activeProgram_); SetIndexBuffer(activeMesh_->GetIndexBuffer(solid)); } }
FillRectShader::FillRectShader() : OpenGLShaderProgram("fillrect") { GetLocations(); glGenBuffers(1, &_vbo); glGenVertexArrays(1, &_vao); GLuint vertices[] = { 0, 1, 2, 2, 1, 3 }; glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBindVertexArray(_vao); glEnableVertexAttribArray(vIndex); glVertexAttribIPointer(vIndex, 1, GL_INT, 0, 0); Use(); SetFlags(0); glUniform1i(uSourceFramebuffer, 0); }
bool wxExVCS::SetEntryFromBase(wxWindow* parent) { if (!Use()) { return false; } const wxString message = _("Select VCS Folder"); // See also vcsentry, same item is used there. const std::vector<wxExItem> v{{ _("Base folder"), ITEM_COMBOBOX_DIR, wxAny(), true, wxWindow::NewControlId()}}; if (wxExConfigFirstOf(_("Base folder")).empty()) { if ( parent != nullptr && wxExItemDialog(parent, v, message).ShowModal() == wxID_CANCEL) { return false; } m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder"))); } else { m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder"))); if (m_Entry.GetName().empty()) { if ( parent != nullptr && wxExItemDialog(parent, v, message).ShowModal() == wxID_CANCEL) { return false; } m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder"))); } } return !m_Entry.GetName().empty(); }
FBTexExample(void) : gl() , vertex_shader(ObjectDesc("Vertex")) , prog(make_prog()) , projection_matrix(prog, "ProjectionMatrix") , camera_matrix(prog, "CameraMatrix") , model_matrix(prog, "ModelMatrix") , cube(List("Position")("Normal")("TexCoord").Get(), shapes::Cube(), prog) , width(800) , height(600) { UniformSampler(prog, "TexUnit").Set(0); Uniform<Vec3f>(prog, "LightPos").Set(40.0f, 40.0f, -80.0f); Texture::Active(0); tex.Bind(Texture::Target::_2D); Use(); }
void CPickup::Callback_OnCollision ( CColShape& Shape, CElement& Element ) { if ( IS_PLAYER ( &Element ) ) { CPlayer& Player = static_cast < CPlayer& > ( Element ); // Is he alive? if ( !Player.IsDead () ) { // Matching interior if ( GetInterior () == Element.GetInterior () ) { // Matching dimension if ( GetDimension () == Element.GetDimension () ) { // Call the onPickupHit event CLuaArguments Arguments; Arguments.PushElement ( &Player ); bool bContinue1 = CallEvent ( "onPickupHit", Arguments ); CLuaArguments Arguments2; Arguments2.PushElement ( this ); // pickup bool bContinue2 = Element.CallEvent ( "onPlayerPickupHit", Arguments2 ); if ( bContinue1 && bContinue2 ) { // Does it still exist? if ( !IsBeingDeleted () ) { // Can we USE the pickup? if ( CanUse ( Player ) ) { // USE the pickup Use ( Player ); } } } } } } } }
//----------------------------------------------------------------------------- // Purpose: allows the crate to open up when hit by a crowbar //----------------------------------------------------------------------------- int CItem_AmmoCrate::OnTakeDamage( const CTakeDamageInfo &info ) { // if it's the player hitting us with a crowbar, open up CBasePlayer *player = ToBasePlayer(info.GetAttacker()); if (player) { CBaseCombatWeapon *weapon = player->GetActiveWeapon(); if (weapon && !stricmp(weapon->GetName(), "weapon_crowbar")) { // play the normal use sound player->EmitSound( "HL2Player.Use" ); // open the crate Use(info.GetAttacker(), info.GetAttacker(), USE_TOGGLE, 0.0f); } } // don't actually take any damage return 0; }