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

C++ Uniform类代码示例

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

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



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

示例1: randomMatrix

const Matrix<complex<double> > randomMatrix( Uniform<double>& generator, 
                                             const int dimension,
                                             const double upperBound ) {

    Matrix<complex<double> > tmp( dimension, dimension,
                                  complex<double>(0.0,0.0) );
    for ( int i=0; i<dimension; i++ ) {
        tmp[i][i] = generator.random();
        for ( int j=0; j<i; j++ ) {
            tmp[j][i] = complex<double>( generator.random() - 0.5,
                                         generator.random() - 0.5 );
            tmp[i][j] = conj( tmp[j][i] );
        }
    }

    double trace = 0.0;
    for ( int i=0; i<dimension; i++ ) {
        trace += tmp[i][i].real();
    }

    if ( trace < ZERO ) throw Fpe("trace too small");

    for ( int i=0; i<dimension; i++ ) {
        for ( int j=0; j<dimension; j++ ) {
            tmp[i][j] /= trace;
            tmp[i][j] *= upperBound;
        }
    }

    return tmp;

}
开发者ID:mmm,项目名称:byrd,代码行数:32,代码来源:Matrices.C


示例2: getProgramID

void Shader::extractShaderUniforms()
{
	GLuint pId = getProgramID();
	const int BUFF_SIZE = 255;
	int count;
	glGetProgramiv(pId, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &count);

	for (int i = 0; i < count; ++i)
	{
		char name[BUFF_SIZE]; // for holding the variable name
		GLint size = BUFF_SIZE;
		GLenum type;
		GLsizei length;
		GLsizei bufSize = BUFF_SIZE;
		glGetActiveUniform(pId, i, bufSize, &length, &size, &type, name);
		int location = glGetUniformLocation(pId, name);

		Uniform* uniform = UniformFactory::createUniform(name, type);
		uniform->addOwner(this,location);
		uniforms.insert(std::make_pair(uniform->getName(), uniform));

		//Borrar
		const char* uni_types[6] = { "Error", "FLOAT", "FLOAT_VEC3", "FLOAT_VEC4", "FLOAT_MAT3", "FLOAT_MAT4" };
		printf("Uniform name: %s. Type: %s.\n", uniform->getName().c_str(), uni_types[uniform->getType()]);	
	}
	printf("---------------\n");
}
开发者ID:belazaras,项目名称:teardrop,代码行数:27,代码来源:Shader.cpp


示例3: main

int main() {
  switch (2) {
    case 0: {
      // Sample uniform scalars.
      Uniform<> uniform;
      for (int i = 0; i < 100; i++) {
        cout << uniform.sample() << " ";
      }
      cout << endl;
      break;
    }
    case 1: {
      // Sample Gaussian.
      Vector2d mean;
      mean << -4, 10;
      Matrix<double, 2, 2> covariance;
      covariance << 3, -1.6, -1.6, 1;
      Gaussian<double, 2> gaussian(mean, covariance);
      Matrix2Xd samples(2, 1000);
      gaussian.sample(samples);
      // Output is where lots of mallocs and frees happen.
      cout << samples << endl;
      break;
    }
    case 2: {
      // Bag classification problem.
      testProblem(buildSqueezeProblem);
      break;
    }
  }
  return 0;
}
开发者ID:tjpalmer,项目名称:concuno,代码行数:32,代码来源:covary.cpp


示例4: foreach

void Squad::read_members() {
    m_members_addr = m_df->enumerate_vector(m_address + m_mem->squad_offset("members"));

    short carry_food = m_df->read_short(m_address+m_mem->squad_offset("carry_food"));
    short carry_water = m_df->read_short(m_address+m_mem->squad_offset("carry_water"));
    int carry_ammo = m_df->enumerate_vector(m_address+m_mem->squad_offset("ammunition")).count();

    //read the uniforms
    int position = 0;
    Uniform *u;
    foreach(VIRTADDR addr, m_members_addr){
        u = new Uniform(m_df,this);

        m_members.insert(position,m_df->read_int(addr));
        read_equip_category(addr+m_mem->squad_offset("armor_vector"),ARMOR,u);
        read_equip_category(addr+m_mem->squad_offset("helm_vector"),HELM,u);
        read_equip_category(addr+m_mem->squad_offset("pants_vector"),PANTS,u);
        read_equip_category(addr+m_mem->squad_offset("gloves_vector"),GLOVES,u);
        read_equip_category(addr+m_mem->squad_offset("shoes_vector"),SHOES,u);
        read_equip_category(addr+m_mem->squad_offset("shield_vector"),SHIELD,u);
        read_equip_category(addr+m_mem->squad_offset("weapon_vector"),WEAPON,u);

        //add other items
        if(carry_ammo){
            u->add_uniform_item(addr+m_mem->squad_offset("quiver"),QUIVER);
            u->add_uniform_item(AMMO,-1,-1);
        }
        if(carry_food)
            u->add_uniform_item(addr+m_mem->squad_offset("backpack"),BACKPACK);
        if(carry_water)
            u->add_uniform_item(addr+m_mem->squad_offset("flask"),FLASK);

        m_uniforms.insert(position,u);
        position++;
    }
开发者ID:His-name-is-Joof,项目名称:Dwarf-Therapist,代码行数:35,代码来源:squad.cpp


示例5: updateVSParameters

/***************************************************************
* Function: updateVSParameters()
***************************************************************/
void DSVirtualEarth::updateVSParameters(const Vec3 &viewDir, const Vec3 &viewPos)
{
    if (!mVirtualScenicHandler) return;

    /*  compute sun direction in world space: apply transforms resulted by viewer's orientation change, 
	guarantee that from the viewer's position, the virtual earth is always half illuminated. */
    Matrixd baserotMat;
    baserotMat.makeRotate(Vec3(0, 1, 0), gDesignStateFrontVect);
    Vec3 sunDirWorld = (CAVEAnimationModeler::ANIMVirtualEarthLightDir()) * baserotMat;
    StateSet *stateset = mEarthGeode->getStateSet();
    if (stateset)
    {
	Uniform *lightposUniform = stateset->getOrCreateUniform("LightPos", Uniform::FLOAT_VEC4);
	lightposUniform->set(Vec4(sunDirWorld, 0.0));
    }

    /* compute matrix combination that transforms a vector from shader space into world space */
    Matrixd latiMat;
    latiMat.makeRotate(mLati / 180.f * M_PI, Vec3(0, 1, 0));
    Matrixd equatorMat;   
    equatorMat.makeRotate((mTimeOffset / 12.f + mLongi / 180.f) * M_PI, Vec3(0, 0, 1));  
    Matrixd tiltaxisMat = mTiltAxisTrans->getMatrix();
    Matrixd eclipticMat = mEclipticTrans->getMatrix();
    Matrixd transMat = mUnitspaceMat * latiMat * equatorMat * tiltaxisMat * eclipticMat * baserotMat;

    /* updata environment rendering by passing parameters to VirtualScenicHandler */
    mVirtualScenicHandler->updateVSParameters(transMat, sunDirWorld, viewDir, viewPos);
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:31,代码来源:DSVirtualEarth.cpp


示例6: u

Uniform const& GLES_Shader::get_uniform_skin_matrix(void* data) const
{
    Command_Stream::Render_Context* ctx = (Command_Stream::Render_Context*)data;
    static Uniform u(Uniform::Type::VEC4, 1);
    if (u.get_count() == 1)
    {
        u = Uniform(Uniform::Type::VEC4, m_max_skin_nodes * 3);
    }
    if (ctx)
    {
        QASSERT(ctx->render_job_data->node_transform_count < m_max_skin_nodes);
        size_t count = math::min(ctx->render_job_data->node_transform_count, m_max_skin_nodes);
        if (u.get_count() == count * 3)
        {
            u = Uniform(Uniform::Type::VEC4, count * 3);
        }
        for (size_t i = 0; i < count; i++)
        {
            auto const& mat = ctx->render_job_data->node_transforms[i].mat;
            u.set(i*3 + 0, mat.get_row(0));
            u.set(i*3 + 1, mat.get_row(1));
            u.set(i*3 + 2, mat.get_row(2));
        }
    }
    return u;
}
开发者ID:ggggamer,项目名称:silkopter,代码行数:26,代码来源:GLES_Shader.cpp


示例7: pushUniform_sub

bool pushUniform_sub(const std::string& name, const Uniform& uniform, UniformStack& stack) {
    auto p = uniform.find(name);
    if (p != uniform.end()) {
        stack[name].push(p->second);
        return true;
    }
    return false;
}
开发者ID:kenshi84,项目名称:nanogui,代码行数:8,代码来源:glutil.cpp


示例8: DVASSERT

void Shader::SetUniformValueByIndex(int32 uniformIndex, const Matrix3 & matrix)
{
	DVASSERT(uniformIndex >= 0 && uniformIndex < activeUniforms);
	Uniform* currentUniform = GET_UNIFORM(uniformIndex);
	if(currentUniform->ValidateCache(matrix) == false)
	{
		RENDER_VERIFY(glUniformMatrix3fv(currentUniform->location, 1, GL_FALSE, matrix.data));
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:9,代码来源:Shader.cpp


示例9: popUniform_sub

bool popUniform_sub(const std::string& name, Uniform& uniform, UniformStack& stack) {
    auto p = uniform.find(name);
    if (p != uniform.end()) {
        p->second = stack[name].top();
        stack[name].pop();
        return true;
    }
    return false;
}
开发者ID:kenshi84,项目名称:nanogui,代码行数:9,代码来源:glutil.cpp


示例10: printRandoms

void printRandoms()
{
  Uniform<T> x;
  //x.seed((unsigned int)time(0));
  x.seed(5);
  int N=5;
  for (int i = 0; i < N; ++i) 
    cout << setprecision(digits10(T())) << LD_HACK(x.random()) << endl;

  cout << endl;
}
开发者ID:Albex,项目名称:Advanced_Architecture,代码行数:11,代码来源:random.cpp


示例11: hasUniformState

bool Pass::hasUniformState(const char* name) const
{
  if (!m_program)
    return false;

  Uniform* uniform = m_program->findUniform(name);
  if (!uniform)
    return false;

  return !uniform->isShared();
}
开发者ID:elmindreda,项目名称:Nori,代码行数:11,代码来源:Pass.cpp


示例12: getUniformNumbersAsArray

void getUniformNumbersAsArray(Array * targetArray,const Uniform & u){
	const value_t *v = reinterpret_cast<const value_t*>(u.getData());
	const size_t numSingleValues = u.getDataSize() / sizeof(value_t);
	ERef<Array> arr;
	for(size_t i=0;i<numSingleValues;++i){
		if( (i%bucketSize) == 0){
			arr=Array::create();
			targetArray->pushBack(arr.get());
		}
		arr->pushBack(Number::create(v[i]));
	}
}
开发者ID:PADrend,项目名称:E_Rendering,代码行数:12,代码来源:E_Uniform.cpp


示例13: sample

    Eigen::VectorXd sample(const Uniform &d, RNG &rng)
    {
      std::uniform_real_distribution<double> dist(0, 1);

      Eigen::ArrayXd sample(length(d));
      for (Eigen::ArrayXd::Index i = 0; i < sample.rows(); i++)
      {
        sample(i) = dist(rng);
      }

      // Transform the output to fit within the support of the distribution
      return d.min().array() + sample * (d.max() - d.min()).array();
    }
开发者ID:traitecoevo,项目名称:stateline,代码行数:13,代码来源:uniform.cpp


示例14: AddUniform

 void IEffect::UseCustomTexture(Texture* texture)
 {        
     Uniform CustomTexture;
     std::ostringstream toSTR; toSTR << "uTex" << TextureUnits;
     CustomTexture.Name = toSTR.str();
     CustomTexture.Type = DataType::Int;
     CustomTexture.Usage = PostEffects::Other;
     CustomTexture.SetValue(&TextureUnits);
     AddUniform(CustomTexture);
     
     // Set RTT Order
     RTTOrder.push_back(RTT::Info(texture, RTT::CustomTexture, TextureUnits));
     
     TextureUnits++;
 }
开发者ID:Fuatnow,项目名称:Pyros3D,代码行数:15,代码来源:IEffect.cpp


示例15: count_x_out_fn

int CFeasibilityMap::count_x_out_fn(CData &Data,int i_tau, int i_original,int n_simul, Uniform &randUnif) {
	
  // double case2_count_out = 0;
	int case2_count_out = 0; // Changed by Hang on 5/16/2015
	
  ColumnVector s_i = tau_to_s_fn( i_tau, Data.n_var );   
  ColumnVector item_by_joint = Data.copy_non_balance_edit(s_i);
  ColumnVector tilde_y_i = Data.log_D_Observed.row(i_original).t();
  
	for (int i_simul=1; i_simul<=n_simul; i_simul++){
			//Generate from uniform distribution
			ColumnVector y_q = tilde_y_i;
			for ( int temp_j=1; temp_j<=Data.n_var; temp_j++ ){
				if ( item_by_joint(temp_j)==1 ){
					y_q(temp_j) = Data.logB_L(temp_j)+Data.logB_U_L(temp_j)*randUnif.Next(); 
				} 
			} 
	
			ColumnVector x_q = exp_ColumnVector(y_q) ;
      Data.update_full_x_for_balance_edit(x_q);
			// if (!Data.PassEdits(x_q)) { case2_count_out += 1.0;}
      if (!Data.PassEdits(x_q)) { case2_count_out += 1;}  // Changed by Hang on 5/16/2015
	} 
  if (case2_count_out ==0) {
    case2_count_out = 1;
  }
	return case2_count_out; // ADDED by Hang on 5/16/2015
}
开发者ID:QuanliWang,项目名称:EditImputeCont,代码行数:28,代码来源:CFeasibilityMap.cpp


示例16: dbgPrint

void ShVarModel::setRecursiveUniformValues(ShVarItem *item, const Uniform& u)
{
	if (!item)
		return;

	if (item->getFullName() == u.name()) {
		dbgPrint(DBGLVL_INFO, "found uniform: %s\n", u.name().toAscii().data());
		item->setData(DF_DEBUG_UNIFORM_VALUE, u.toString());
		emit dataChanged(ShVarModel::getIndex(item, 0),
				ShVarModel::getIndex(item, DF_LAST - 1));
	} else {
		for (int i = 0; i < item->childCount(); ++i) {
			setRecursiveUniformValues(item->child(i), u);
		}
	}
}
开发者ID:10110111,项目名称:GLSL-Debugger,代码行数:16,代码来源:shVarModel.cpp


示例17: GetCachedUniform

/*
=============
OpenGLProgram::SetUniform

	Sets a uniform int value.
=============
*/
void OpenGLProgram::SetUniform( const char* name, const int* value, unsigned size ) {	
	Uniform* cachedUniform = GetCachedUniform( name );
    if ( cachedUniform ) {
        cachedUniform->Set( value );
    } else {
	    //Not found
        GLint location = glGetUniformLocation( m_programID, name );
	    if ( location > -1 ) {
		    Uniform* newUniform = new Uniform( location, name, size );
		    newUniform->Set( value );
        
            m_uniforms[StringUtils::Hash( name )] = ( newUniform );
	    } else {
			printf( "Could not find int uniform: %s\n", name );
        }
    }
}
开发者ID:Mertank,项目名称:ToneArm,代码行数:24,代码来源:OpenGLProgram.cpp


示例18: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		auto lightAzimuth = FullCircles(time * -0.5);
		light_pos.Set(
			Vec3f(
				Cos(lightAzimuth),
				1.0f,
				Sin(lightAzimuth)
			) * 2.0f
		);
		//
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.0f,
				Degrees(-45),
				Degrees(SineWave(time / 30.0) * 70)
			)
		);

		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationY(FullCircles(time * 0.05))
		);

		cube.Bind();
		gl.CullFace(Face::Back);
		cube_instr.Draw(cube_indices);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:31,代码来源:021_wooden_crate.cpp


示例19: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.0,
				Degrees(time * 25),
				Degrees(SineWave(time / 30.0) * 90)
			)
		);

		model_matrix.Set(
			ModelMatrixf::RotationA(
				Vec3f(1.0f, 1.0f, 1.0f),
				FullCircles(time * 0.5)
			)
		);

		shape.Draw();

		thread_ready.Signal();
		parent_ready.Wait();
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:25,代码来源:025_rendered_texture_mt.cpp


示例20: Render

	void Render(const PangoCairoLayout& layout)
	{
		_bitmap.Set(GLint(layout.Use()));
		_log_coords.Set(layout._log_coords);
		_tex_coords.Set(layout._tex_coords);
		_gl.DrawArrays(PrimitiveType::Points, 0, 1);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:7,代码来源:renderer.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ UniformParameterPtr类代码示例发布时间:2022-05-31
下一篇:
C++ UnicodeString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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