• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setUniform函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setUniform函数的典型用法代码示例。如果您正苦于以下问题:C++ setUniform函数的具体用法?C++ setUniform怎么用?C++ setUniform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setUniform函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: UpdateParameters

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;
}
开发者ID:FROL256,项目名称:msu-opengl4-sdk,代码行数:34,代码来源:FireParticleSystem.cpp


示例2: glGetIntegerv

void water::sim_step() {
  GLint old_viewport[4];
  glGetIntegerv(GL_VIEWPORT, old_viewport);

  glViewport(0, 0, grid_size_x_, grid_size_z_);
  glDisable(GL_DEPTH_TEST);

  int temp = a_;
  a_ = b_;
  b_ = c_;
  c_ = temp;
 
  pos_tex_[c_]->BeginRenderingToThisTexture();
  
  glUseProgram(sim_prog_.program);

  setUniform(sim_prog_.program, "gridSizeX", grid_size_x_);
  setUniform(sim_prog_.program, "gridSizeZ", grid_size_z_);

  bindTexture(sim_prog_.program, WATER_POSITIONS_PREV, "inPositionsPrev",  pos_tex_[a_]->GetColorTexId());
  bindTexture(sim_prog_.program, WATER_POSITIONS, "inPositions",      pos_tex_[b_]->GetColorTexId());

  full_screen_quad_->Draw();

  pos_tex_[c_]->EndRenderingToThisTexture();

  glEnable(GL_DEPTH_TEST);
  glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);
}
开发者ID:tanyatik,项目名称:pool-caustics,代码行数:29,代码来源:water.cpp


示例3: rs

ReflectorShader::ReflectorShader() {
    Utility::Resource rs("data");

    Shader vert(Version::GL330, Shader::Type::Vertex);
    vert.addSource(rs.get("ReflectorShader.vert"));
    CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
    attachShader(vert);

    Shader frag(Version::GL330, Shader::Type::Fragment);
    frag.addSource(rs.get("ReflectorShader.frag"));
    CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
    attachShader(frag);

    CORRADE_INTERNAL_ASSERT_OUTPUT(link());

    transformationMatrixUniform = uniformLocation("transformationMatrix");
    normalMatrixUniform = uniformLocation("normalMatrix");
    projectionMatrixUniform = uniformLocation("projectionMatrix");
    cameraMatrixUniform = uniformLocation("cameraMatrix");
    reflectivityUniform = uniformLocation("reflectivity");
    diffuseColorUniform = uniformLocation("diffuseColor");

    setUniform(uniformLocation("textureData"), TextureLayer);
    setUniform(uniformLocation("tarnishTextureData"), TarnishTextureLayer);
}
开发者ID:g2p,项目名称:magnum-examples,代码行数:25,代码来源:ReflectorShader.cpp


示例4: setUniform

void material::setup_shader(GLuint program) const {
	setUniform(program, "material.ambient",  ambient_);
	setUniform(program, "material.diffuse",  diffuse_);
	setUniform(program, "material.specular", specular_);
	float3 shininess;
	shininess.x = shininess_;
	setUniform(program, "material.shininess", shininess);
}
开发者ID:tanyatik,项目名称:pool-caustics,代码行数:8,代码来源:light.cpp


示例5: bind

void BasicShader::updateUniforms(const Matrix4f& projectedMatrix, const Material& material)
{
    bind();

    material.texture.bind();

    setUniform("transform", projectedMatrix);
    setUniform("color", material.color);
}
开发者ID:MORTAL2000,项目名称:Simple-3D-Engine,代码行数:9,代码来源:BasicShader.cpp


示例6: setUniform

  void NormalShader::updateUniforms()
  {

    setUniform(std::string("transform"), transform_);
    setUniform(std::string("perspective"), *perspective_);
    setUniform(std::string("camera"), *cameraTranslation_);
    setUniform(std::string("cameraRotation"), *cameraRotation_);

    setUniform(std::string("model_col"), eyePos_);

  }
开发者ID:rmuenste,项目名称:opengl-sdl,代码行数:11,代码来源:normallines.cpp


示例7: main

int main() {
  circe::SceneApp<> app(800, 800, "", false);
  app.init();
  app.addViewport(0, 0, 800, 800);
  ponos::RawMeshSPtr mesh(new ponos::RawMesh());
  // circe::loadOBJ("/mnt/windows/Users/fuiri/Desktop/dragon.obj", &mesh);
  circe::loadOBJ(
      "/mnt/windows/Projects/ponos/circe/examples/assets/torusknot.obj",
      mesh.get());
  mesh->apply(ponos::scale(0.1, 0.1, 0.1));
  mesh->computeBBox();
  mesh->splitIndexData();
  mesh->buildInterleavedData();
  auto texture = circe::ImageTexture::checkBoard(64, 64);
  ponos::RawMeshSPtr m(
      ponos::create_icosphere_mesh(ponos::Point3(), 1.f, 3, true, false));
  // create a vertex buffer for base mesh
  // circe::SceneMesh sm(*m.get());
  circe::SceneMesh smesh(mesh);
  auto s = circe::ShaderProgram(
      circe::ShaderManager::instance().loadFromTexts(vs, nullptr, fs));
  s.addVertexAttribute("position", 0);
  s.addVertexAttribute("normal", 1);
  s.addVertexAttribute("texcoord", 2);
  s.addUniform("proj", 3);
  s.addUniform("model", 4);
  s.addUniform("tex", 5);
  // create a buffer for particles positions + sizes
  app.viewports[0].renderCallback = [&](const circe::CameraInterface *camera) {
    smesh.bind();
    smesh.vertexBuffer()->locateAttributes(s);
    texture.bind(GL_TEXTURE0);
    s.begin();
    s.setUniform("proj",
                 ponos::transpose(camera->getProjectionTransform().matrix()));
    s.setUniform("model",
                 ponos::transpose(camera->getViewTransform().matrix()));
    circe::CHECK_GL_ERRORS;
    s.setUniform("tex", 0);
    //    s.setUniform("ldir", ponos::vec3(1,0,0));
    circe::CHECK_GL_ERRORS;
    auto ib = smesh.indexBuffer();
    glDrawElements(ib->bufferDescriptor.elementType,
                   ib->bufferDescriptor.elementCount *
                       ib->bufferDescriptor.elementSize,
                   ib->bufferDescriptor.dataType, 0);
    circe::CHECK_GL_ERRORS;
    s.end();
  };
  circe::SceneObjectSPtr grid(new circe::CartesianGrid(5));
  app.scene.add(grid.get());
  app.run();
  return 0;
}
开发者ID:filipecn,项目名称:Ponos,代码行数:54,代码来源:scene_mesh_example.cpp


示例8: setUniform

void UniformRegistry::performGlobalSync(const UniformRegistry & globalUniforms, bool forced){
	if(forced){
		// set all global uniforms
		for(auto it=globalUniforms.orderedList.begin();	it!=globalUniforms.orderedList.end() && (*it)->stepOfLastSet>stepOfLastGlobalSync; ++it )
			setUniform( (*it)->uniform,false,true);
	}else {
		// set all uniforms of the globalUniforms-Set that have been changed since the last call.
		for(auto it=globalUniforms.orderedList.begin();	it!=globalUniforms.orderedList.end() && (*it)->stepOfLastSet>stepOfLastGlobalSync; ++it )
			setUniform( (*it)->uniform,false,false);
	}
	stepOfLastGlobalSync = getNewGlobalStep();
}
开发者ID:MeisterYeti,项目名称:Rendering,代码行数:12,代码来源:UniformRegistry.cpp


示例9: rs

ColorCorrectionShader::ColorCorrectionShader() {
    Corrade::Utility::Resource rs("shader");
    attachShader(Shader::fromData(Version::GL330, Shader::Type::Vertex, rs.get("ColorCorrectionShader.vert")));
    attachShader(Shader::fromData(Version::GL330, Shader::Type::Fragment, rs.get("ColorCorrectionShader.frag")));

    link();

    transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");

    setUniform(uniformLocation("textureData"), TextureLayer);
    setUniform(uniformLocation("colorCorrectionTextureData"), ColorCorrectionTextureLayer);
}
开发者ID:JanDupal,项目名称:magnum-examples,代码行数:12,代码来源:ColorCorrectionShader.cpp


示例10: Texture

void BasicShader::updateUniforms(const Matrix4f& worldMatrix, const Matrix4f& projectedMatrix, Material& material)
{
	static Texture WHITE = Texture(1, 1, whitePixel);

	if (material.texture != NULL)
		material.texture->bind();
	else
		WHITE.bind();

	setUniform("transform", projectedMatrix);
	setUniform("color", material.color);
}
开发者ID:Ahmed310,项目名称:GameEngine3D,代码行数:12,代码来源:basicShader.cpp


示例11: COGLES2SLMaterialRenderer

	//! Constructor
	COGLES2ParallaxMapRenderer::COGLES2ParallaxMapRenderer( video::COGLES2Driver* driver,
															io::IFileSystem* fs, s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial )
			: COGLES2SLMaterialRenderer( driver, fs, 0, baseMaterial, sBuiltInShaderUniformNames, UNIFORM_COUNT ), CompiledShaders( true )
	{

#ifdef _DEBUG
		setDebugName( "COGLES2ParallaxMapRenderer" );
#endif

		// set this as callback. We could have done this in
		// the initialization list, but some compilers don't like it.

		CallBack = this;

		// basically, this simply compiles the hard coded shaders if the
		// hardware is able to do them, otherwise it maps to the base material

		// check if already compiled normal map shaders are there.

		video::IMaterialRenderer* renderer = driver->getMaterialRenderer( EMT_PARALLAX_MAP_SOLID );

		if ( renderer )
		{
			// use the already compiled shaders
			video::COGLES2ParallaxMapRenderer* pmr = reinterpret_cast<video::COGLES2ParallaxMapRenderer*>( renderer );
			CompiledShaders = false;

			Program = pmr->Program;

			UniformInfo = pmr->UniformInfo;
			AttributeInfo = pmr->AttributeInfo;

			outMaterialTypeNr = driver->addMaterialRenderer( this );
		}
		else
		{
			// compile shaders on our own
			if (initFromFiles( outMaterialTypeNr, VertexShaderFile, FragmentShaderFile))
			{
				useProgram();
				int dummy = 0;
				setUniform( TEXTURE_UNIT0, &dummy );
				dummy = 1;
				setUniform( TEXTURE_UNIT1, &dummy );
			}
		}

		// fallback if compilation has failed
		if ( -1 == outMaterialTypeNr )
			outMaterialTypeNr = driver->addMaterialRenderer( this );
	}
开发者ID:aronarts,项目名称:irrAndroid,代码行数:52,代码来源:COGLES2ParallaxMapRenderer.cpp


示例12: glUseProgram

void pool::update(const float4x4& view_projection, const camera& camera, const point_light& light, GLuint caustics_tex_id, int num_wall) {
    glUseProgram(render_prog_.program);

    setUniform(render_prog_.program, "cameraPosition", camera.get_pos());
    setUniform(render_prog_.program, "viewProjectionMatrix", view_projection);


    setUniform(render_prog_.program, "objectMatrix", object_matrix_[num_wall]);
    setUniform(render_prog_.program, "inversedObjectMatrix", inversed_object_matrix_[num_wall]);

    setUniform(render_prog_.program, "gridSizeX", 256);
    setUniform(render_prog_.program, "gridSizeZ", 256);
    setUniform(render_prog_.program, "sizeX", size_x_[num_wall]);
    setUniform(render_prog_.program, "sizeZ", size_z_[num_wall]);
    light.setup_shader(render_prog_.program);
    material_.setup_shader(render_prog_.program);

    bindTexture(render_prog_.program, CAUSTICS + num_wall, "caustics", caustics_tex_id);
    bindTexture(render_prog_.program, FLOOR_TILT, "floorTilt", floor_tex_->GetColorTexId());

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);

    pool_mesh_->Draw(GL_TRIANGLES);

    glDisable(GL_BLEND);
    glDisable(GL_CULL_FACE);
}
开发者ID:tanyatik,项目名称:pool-caustics,代码行数:30,代码来源:pool.cpp


示例13: textureSpaceOffset

void ForwardPass::onPrep(const DirectionalLight &dLight)
{
	glm::mat4 textureSpaceOffset(
		0.5f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.5f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.5f, 0.0f,
		0.5f, 0.5f, 0.5f, 1.0f
		);

	//lights
	setUniform("dLColor", nsfw::UNIFORM::FLO3, glm::value_ptr((dLight.color)));
	setUniform("dLDirection", nsfw::UNIFORM::FLO3, glm::value_ptr((dLight.direction)));
	setUniform("LightMatrix", nsfw::UNIFORM::MAT4, glm::value_ptr(textureSpaceOffset * dLight.getMatrix()));
	setUniform("dLCoefficient", nsfw::UNIFORM::FLO1, &dLight.dLCoefficient);
}
开发者ID:TheCapleGuy,项目名称:NSFWGL_Personal,代码行数:15,代码来源:ForwardPass.cpp


示例14: GL_CHECK

void Lightmap::render(const Falltergeist::Point &pos)
{
    if (_indexes<=0) return;

    GL_CHECK(glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR));
    auto shader = ResourceManager::getInstance()->shader("lightmap");

    GL_CHECK(shader->use());

    GL_CHECK(shader->setUniform(_uniformMVP, Game::getInstance()->renderer()->getMVP()));

    // set camera offset
    GL_CHECK(shader->setUniform(_uniformOffset, glm::vec2((float)pos.x(), (float)pos.y()) ));

    GL_CHECK(shader->setUniform(_uniformFade,Game::getInstance()->renderer()->fadeColor()));


    GL_CHECK(glBindVertexArray(_vao));


    GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, _coords));
    GL_CHECK(glVertexAttribPointer(_attribPos, 2, GL_FLOAT, GL_FALSE, 0, (void*)0 ));


    GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, _lights));

    GL_CHECK(glVertexAttribPointer(_attribLights, 1, GL_FLOAT, GL_FALSE, 0, (void*)0 ));

    GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo));


    GL_CHECK(glEnableVertexAttribArray(_attribPos));

    GL_CHECK(glEnableVertexAttribArray(_attribLights));

    GL_CHECK(glDrawElements(GL_TRIANGLES, _indexes, GL_UNSIGNED_INT, 0 ));

    GL_CHECK(glDisableVertexAttribArray(_attribPos));

    GL_CHECK(glDisableVertexAttribArray(_attribLights));

    GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
    GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0));
    GL_CHECK(glBindVertexArray(0));

    GL_CHECK(shader->unuse());
    GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
}
开发者ID:teepean,项目名称:falltergeist,代码行数:48,代码来源:Lightmap.cpp


示例15: setTimeStep

    void DynamicPartialLoudnessGM::loadParameterSet(ParameterSet set)
    {
        //common to all
        setTimeStep(0.001);
        setHpf(true);
        setDiffuseField(false);
        setGoertzel(false);
        setDiotic(true);
        setUniform(true);
        setInterpRoexBank(false);
        setFilterSpacing(0.25);
        setCompressionCriterion(0.0);
        setFastBank(false);
        setStereoToMono(true);

        switch(set){
            case GM02:
                break;
            case FASTER1:
                setFastBank(true);
                setInterpRoexBank(true);
                setCompressionCriterion(0.3);
                break;
            default:
                setFastBank(true);
                setCompressionCriterion(0.3);
        }
    }
开发者ID:jondavidford,项目名称:loudness,代码行数:28,代码来源:DynamicPartialLoudnessGM.cpp


示例16: Uniform

    void Element::setColor(const glm::vec4 color) noexcept {
      this->color = color;
      auto uniform = Uniform();
      uniform.setData("color", color);

      setUniform(uniform);
    }
开发者ID:sainteos,项目名称:project-spero,代码行数:7,代码来源:element.cpp


示例17: transformationProjectionMatrixUniform

template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): transformationProjectionMatrixUniform(0), colorUniform(1), _flags(flags) {
    #ifdef MAGNUM_BUILD_STATIC
    /* Import resources on static build, if not already */
    if(!Utility::Resource::hasGroup("MagnumShaders"))
        importShaderResources();
    #endif
    Utility::Resource rs("MagnumShaders");

    #ifndef MAGNUM_TARGET_GLES
    const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
    #else
    const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
    #endif

    Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
    Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);

    vert.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
        .addSource(rs.get("generic.glsl"))
        .addSource(rs.get(vertexShaderName<dimensions>()));
    frag.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
        .addSource(rs.get("Flat.frag"));

    CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));

    attachShaders({vert, frag});

    #ifndef MAGNUM_TARGET_GLES
    if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
    #else
    if(!Context::current().isVersionSupported(Version::GLES300))
    #endif
    {
        bindAttributeLocation(Position::Location, "position");
        if(flags & Flag::Textured) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates");
    }

    CORRADE_INTERNAL_ASSERT_OUTPUT(link());

    #ifndef MAGNUM_TARGET_GLES
    if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
    #endif
    {
        transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
        colorUniform = uniformLocation("color");
    }

    #ifndef MAGNUM_TARGET_GLES
    if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
    #endif
    {
        if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer);
    }

    /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
    #ifdef MAGNUM_TARGET_GLES
    /* Default to fully opaque white so we can see the texture */
    if(flags & Flag::Textured) setColor(Color4(1.0f));
    #endif
}
开发者ID:jkhoogland,项目名称:magnum,代码行数:60,代码来源:Flat.cpp


示例18: LWARNING

bool VolumeRenderer::bindVolumes(tgt::Shader* shader, const std::vector<VolumeStruct>& volumes,
                                 const tgt::Camera* camera, const tgt::vec4& lightPosition) {
    shader->setIgnoreUniformLocationError(true);

    bool success = true;
    for (size_t i=0; i < volumes.size(); ++i) {
        const VolumeStruct& volumeStruct = volumes[i];
        const VolumeGL* volumeGL = volumeStruct.volume_->getRepresentation<VolumeGL>();
        if (!volumeGL || !volumeGL->getTexture()) {
            LWARNING("No volume texture while binding volumes");
            continue;
        }

        const TextureUnit* texUnit = volumeStruct.texUnit_;
        if (!texUnit) {
            LERROR("No texture unit while binding volumes");
            continue;
        }

        success &= bindVolumeTexture(volumeStruct.volume_, texUnit, volumeStruct.filterMode_, volumeStruct.wrapMode_, volumeStruct.borderColor_);

        // set volume meta-data
        setUniform(shader, volumeStruct.volumeIdentifier_, volumeStruct.volumeStructIdentifier_, volumeStruct.volume_, texUnit, camera, lightPosition);

        LGL_ERROR;
    }

    shader->setIgnoreUniformLocationError(false);
    LGL_ERROR;

    return success;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:32,代码来源:volumerenderer.cpp


示例19: setUniform

void reShader::setTexture( int name, GLuint texture, int index )
{
	setUniform(name, varTable[name]->index, index);
	glActiveTexture(GL_TEXTURE0+varTable[name]->index);	
	glBindTexture(GL_TEXTURE_2D, texture);
	glEnable(GL_TEXTURE_2D);
}
开发者ID:ZhaoJie1987,项目名称:Radial-Engine,代码行数:7,代码来源:reShader.cpp


示例20: glfwGetMousePos

void Slider::update() {
	
	int newMouseX, newMouseY;
	glfwGetMousePos( &newMouseX, &newMouseY );			

	float relativeMouseX = convertXToRelative( newMouseX );
	float relativeMouseY = convertYToRelative( newMouseY );

	// Check if mouse press is on button
	if( !glfwGetMouseButton(0) ) {
		buttonPressed = false;
	}
	else if( ( relativeMouseX - buttonPosition.X ) * ( relativeMouseX - buttonPosition.X )
		+ (relativeMouseY - buttonPosition.Y ) * ( relativeMouseY - buttonPosition.Y )
		< slider_consts::buttonSize * slider_consts::buttonSize || buttonPressed ){
		buttonPressed = true;
		buttonPosition.X = relativeMouseX;
		float minPos = sliderPosition.X - slider_consts::sliderLength / 2;
		float maxPos = sliderPosition.X + slider_consts::sliderLength / 2;
		if( buttonPosition.X <  minPos )
			buttonPosition.X = minPos;
		if( buttonPosition.X > maxPos )
			buttonPosition.X = maxPos;
	
		currentPercentage = ( buttonPosition.X - minPos ) / ( maxPos - minPos );
		setUniform( shaderProperty, min + currentPercentage * (max - min) );
	}

}
开发者ID:linghushaoxia,项目名称:CloudRenderer,代码行数:29,代码来源:Slider.cpp



注:本文中的setUniform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setUniformRowHeights函数代码示例发布时间:2022-05-30
下一篇:
C++ setUnifiedTitleAndToolBarOnMac函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap