当前位置: 首页>>代码示例>>C++>>正文


C++ Texture::Bind方法代码示例

本文整理汇总了C++中Texture::Bind方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::Bind方法的具体用法?C++ Texture::Bind怎么用?C++ Texture::Bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture的用法示例。


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

示例1: RenderWater

void BaseApp::RenderWater()
{
	water.Bind(2);
	g_texFP162.Bind(1);
	g_texWaterReflect.Bind(0);

	Mat4 mBias = Mat4(	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	);

	Mat4 mModelViewProjection = mBias * projMat * modelViewMat;

	m_shdWater->enable();

	m_shdWater->sendUniform1i("g_texReflection", 0);
	m_shdWater->sendUniform1i("g_texRefraction", 1);
	m_shdWater->sendUniform1i("g_texNormalMap", 2);

	LARGE_INTEGER time;
	QueryPerformanceCounter(&time);
	m_shdWater->sendUniform1f("g_waterTranslation", float(time.QuadPart) * 0.00000000008f);
	m_shdWater->sendUniform3f("g_vEyePos", m_camera.m_vEye.x, m_camera.m_vEye.y, m_camera.m_vEye.z);
	m_shdWater->sendUniformMatrix4fv("g_mModelViewProjection", 1, 0, mModelViewProjection.m);

	glDisable(GL_CULL_FACE);
	RenderInfinitePlane(5000, 10, 0.0f, m_camera.m_vEye.x, m_camera.m_vEye.z);
	glEnable(GL_CULL_FACE);

	m_shdWater->disable();
}
开发者ID:pedroedrasousa,项目名称:opengl-stuff-cpp,代码行数:31,代码来源:Main.cpp

示例2: RenderSelection

void SpriteRenderer::RenderSelection(int selection_code, Texture &texture, glm::vec2 position, glm::vec2 size, GLfloat rotate) {
	assert(initialized);
	initRenderData();

	// Prepare transformations
	this->selectionShader->Use();
	glm::mat4 model;
	model = glm::translate(model, glm::vec3(position, 0.0f));  // First translate (transformations are: scale happens first, then rotation and then finall translation happens; reversed order)

	model = glm::translate(model, glm::vec3(0.5f * size.x, 0.5f * size.y, 0.0f)); // Move origin of rotation to center of quad
	model = glm::rotate(model, rotate, glm::vec3(0.0f, 0.0f, 1.0f)); // Then rotate
	model = glm::translate(model, glm::vec3(-0.5f * size.x, -0.5f * size.y, 0.0f)); // Move origin back

	model = glm::scale(model, glm::vec3(size, 1.0f)); // Last scale

	GLint model_loc = selectionShader->GetUniform("model");
	glUniformMatrix4fv(model_loc, 1, false, glm::value_ptr(model));

	glm::mat4 projection = glm::ortho(0.0f, static_cast<GLfloat>(Window::width),
		static_cast<GLfloat>(Window::height), 0.0f, -1.0f, 1.0f);
	GLint projection_loc = selectionShader->GetUniform("projection");
	glUniformMatrix4fv(projection_loc, 1, false, glm::value_ptr(projection));

	GLint code_loc = selectionShader->GetUniform("code");
	glUniform1i(code_loc, selection_code);

	texture.Bind(GL_TEXTURE0);

	glBindVertexArray(this->quadVAO);
	glDrawArrays(GL_TRIANGLES, 0, 6);
	glBindVertexArray(0);
}
开发者ID:bhn26,项目名称:CSE125,代码行数:32,代码来源:SpriteRenderer.cpp

示例3: Draw

void TerrainRenderer::Draw(const std::vector<Terrain*>& terrains, Vector4 clipPlane) {
    EnableCulling(true);

    shader->Bind();
    shader->SetUniformMatrix4fv("gCamera", camera->GetTransform()->GetMatrix());
    shader->SetUniform3f("eyeWorldPosition", camera->GetTransform()->GetPosition());
    shader->SetUniform4f("clipPlane", clipPlane);

    for (unsigned int i = 0; i < terrains.size(); ++i) {
        shader->SetUniformMatrix4fv("gWorld", terrains[i]->GetWorldMatrix());

        RawModel* model = terrains[i]->GetTexturedModel()->GetRawModel();
        Texture* texture = terrains[i]->GetTexturedModel()->GetTexture();
        texture->Bind();

        model->GetVertexArray()->Bind();
        model->GetIndexBuffer()->Bind();

        glDrawElements(GL_TRIANGLES, model->GetIndexBuffer()->GetCount(), GL_UNSIGNED_INT, 0);

        model->GetIndexBuffer()->Unbind();
        model->GetVertexArray()->Unbind();

        texture->Unbind();
    }

    shader->Unbind();
}
开发者ID:teodorplop,项目名称:OpenGL-Engine,代码行数:28,代码来源:TerrainRenderer.cpp

示例4: BuildList

void GUIbutton::BuildList()
{
	static Texture tex;
	if(!tex)
	{
		vector < paletteentry_s > vTransparentColors;
		paletteentry_s peBlack;
		peBlack.peBlue = peBlack.peGreen = peBlack.peRed = 0;
		peBlack.peFlags = 0;
		vTransparentColors.push_back( peBlack );
		tex=LoadTexture("bitmaps/button.bmp", &vTransparentColors);
	}

	glNewList(displayList, GL_COMPILE);

	tex.Bind();

	DrawThemeRect(10, 32, w, h);
	
	if(highlight)
		glColor4f(1.0,0.4f,0.4f,1.0f);
		
	if(centerText)
		guifont->output((w-guifont->GetWidth(caption.c_str()))/2.0, (h-guifont->GetHeight())/2.0, caption.c_str());
	else
		guifont->output(7, (h-guifont->GetHeight())/2.0, caption.c_str());

	glEndList();
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:29,代码来源:GUIbutton.cpp

示例5: BlurCurrentOutput

Texture* GraphicsEngine::BlurCurrentOutput(float radius, bool halfRes)
{
	Texture* texture = GaussianBlur(gBuffer->GetOutput(), radius, halfRes);
	texture->Bind();

	return texture;
}
开发者ID:Dopelust,项目名称:SP4-10,代码行数:7,代码来源:GraphicsEngine.cpp

示例6: ResizeLightMask

	void ResizeLightMask(GLuint width, GLuint height)
	{
		Texture::Active(light_tex_unit);
		Texture::Target tex_tgt = Texture::Target::Rectangle;
		light_mask.Bind(tex_tgt);
		Texture::Image2D(
			tex_tgt,
			0,
			PixelDataInternalFormat::Red,
			width, height,
			0,
			PixelDataFormat::Red,
			PixelDataType::UnsignedByte,
			nullptr
		);

		Renderbuffer::Target rbo_tgt = Renderbuffer::Target::Renderbuffer;
		light_rbo.Bind(rbo_tgt);
		Renderbuffer::Storage(
			rbo_tgt,
			PixelDataInternalFormat::DepthComponent,
			width,
			height
		);

	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:26,代码来源:030_light_rays.cpp

示例7: Render

void Skybox::Render (const Texture &envmap)
{
	// activate shader program
	program.Use ();
    // bind texture, vertex array and index buffer
    envmap.Bind (GL_TEXTURE_CUBE_MAP);
    glBindVertexArray (vertexarray);
    glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, indexbuffer);
    // render the framing
    glDrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
}
开发者ID:ericwolter,项目名称:pbf,代码行数:11,代码来源:Skybox.cpp

示例8: Render

	void Render() {
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		auto view = camera.GetViewMatrix();
		auto projection = glm::perspective(glm::radians(fov), 800.0f / 600.0f, 0.1f, 1000.0f);

		shaderProgram.Use();
		glUniformMatrix4fv(shaderProgram.UniformLocation("view"), 1, GL_FALSE, glm::value_ptr(view));
		glUniformMatrix4fv(shaderProgram.UniformLocation("projection"), 1, GL_FALSE, glm::value_ptr(projection));

		// Bind textures using texture units
		glActiveTexture(GL_TEXTURE0);
		texture1.Bind();
		glUniform1i(shaderProgram.UniformLocation("ourTexture1"), 0);

		glActiveTexture(GL_TEXTURE1);
		texture2.Bind();
		glUniform1i(shaderProgram.UniformLocation("ourTexture2"), 1);


		glBindVertexArray(VAO);
		for (GLuint i = 0; i < 10; i++) {
			glm::mat4 model;
			model = glm::translate(model, cubePositions[i]);
			GLfloat angle = 20.0f * i;
			if (i % 3 == 0)
				model = glm::rotate(model, glm::radians(angle + (GLfloat)SDL_GetTicks() * 0.05f), glm::vec3(0.5f, 1.0f, 0.0f));
			else
				model = glm::rotate(model, glm::radians(angle), glm::vec3(0.5f, 1.0f, 0.0f));
			glUniformMatrix4fv(shaderProgram.UniformLocation("model"), 1, GL_FALSE, glm::value_ptr(model));

			glDrawArrays(GL_TRIANGLES, 0, 36);
		}

		glBindVertexArray(0);
	}
开发者ID:dmarquant,项目名称:OpenGLTut,代码行数:36,代码来源:Camera.cpp

示例9: gl

	ObjMeshExample(void)
	 : gl()
	 , objects(load_objects())
	 , depth_prog()
	 , draw_prog()
	 , depth_vao(objects.VAOForProgram(depth_prog))
	 , draw_vao(objects.VAOForProgram(draw_prog))
	{
		UniformSampler(draw_prog, "DepthTex").Set(0);
		Texture::Active(0);
		depth_tex.Bind(Texture::Target::Rectangle);

		gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::CullFace);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:16,代码来源:021_translucent_arrow.cpp

示例10: Draw

void Planet::Draw(ShaderProgram &shaderProgram, Camera *camera, Texture moonTexture)
{
    // modelMatrix has to be set
    // moonModelMatrices have to be set
    shaderProgram.UseProgram();
    shaderProgram.SetUniform("mvpMatrix", camera->GetMVP(modelMatrix));
    modelData->Draw();

    for(GLint i = 0; i < moonModelMatrices.size(); i++)
    {
        moonTexture.Bind(0);
        shaderProgram.SetUniform("mvpMatrix", camera->GetMVP(moonModelMatrices[i]));
        modelData->Draw();
    }

    shaderProgram.DisUseProgram();
}
开发者ID:TheFrostlixen,项目名称:cs480Fredrickson,代码行数:17,代码来源:Planet.cpp

示例11: nme_gl_bind_bitmap_data_texture

value nme_gl_bind_bitmap_data_texture(value inBitmapData)
{
   Surface  *surface;
   if (AbstractToObject(inBitmapData,surface) )
   {
      HardwareContext *ctx = gDirectRenderContext;
      if (!ctx)
         ctx = nme::HardwareContext::current;
      if (ctx)
      {
         Texture *texture = surface->GetOrCreateTexture(*gDirectRenderContext);
         if (texture)
            texture->Bind(surface,-1);
      }
   }

   return alloc_null();
}
开发者ID:DjPale,项目名称:NME,代码行数:18,代码来源:OGLExport.cpp

示例12: gl

	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();
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:19,代码来源:026_nv_path_rendering.cpp

示例13: SetMinVelocity

FireEffect::FireEffect(const Vector3f& position) {

    constexpr float minV = 0.886f;
    constexpr float maxV = minV + 0.2f;

    constexpr float range = 1.305f;

    SetMinVelocity(Vector3f(-range,minV,-range) );
    SetMaxVelocity(Vector3f(+range,maxV,+range));

    SetBaseParticleLifetime(1.5f);
    SetParticleLifetimeVariance(1.5f);

    SetBaseStartSize(0.70f);
    SetBaseEndSize(0.38f);
    SetStartSizeVariance(0.22f);
    SetEndSizeVariance(0.16f);

    SetStartColor(Color(1.0f,0.2f,0.0f,0.6f));
    SetEndColor(Color(1.0f,0.2f,0.0f,0.0f));

    SetBlendingMode(ADDITIVE_BLENDING_MODE);

    SetEmitPosition(position);
    SetEmitPositionVariance(Vector3f(0.05f));

    Texture* texture = Texture2D::Load("img/particle_post2.png");

    if(!texture) {
	PrintErrorExit();
    }

    texture->Bind();
    texture->SetTextureRepeat();
    texture->GenerateMipmap();
    texture->SetMinFilter(GL_LINEAR_MIPMAP_LINEAR);
    texture->SetMagFilter(GL_LINEAR);
    texture->Unbind();

    SetTexture(texture);

}
开发者ID:Erkaman,项目名称:graphics-experiments,代码行数:42,代码来源:fire_effect.cpp

示例14: DrawSprite

void SpriteRenderer::DrawSprite(Texture &texture, glm::vec2 position, glm::vec2 size, GLfloat rotate, glm::vec3 color)
{
	if (!initialized) {
        //shader = new Shader("src/Graphics/Shaders/sprite.vert", "src/Graphics/Shaders/sprite.frag");
        //selectionShader = new Shader("src/Graphics/Shaders/selection.vert", "src/Graphics/Shaders/selection.frag");
        shader = ShaderManager::GetShader("Sprite");
        selectionShader = ShaderManager::GetShader("Selection");

		initRenderData();
		initialized = true;
	}

    // Prepare transformations
    this->shader->Use();
    glm::mat4 model;
    model = glm::translate(model, glm::vec3(position, 0.0f));  // First translate (transformations are: scale happens first, then rotation and then finall translation happens; reversed order)

    model = glm::translate(model, glm::vec3(0.5f * size.x, 0.5f * size.y, 0.0f)); // Move origin of rotation to center of quad
    model = glm::rotate(model, rotate, glm::vec3(0.0f, 0.0f, 1.0f)); // Then rotate
    model = glm::translate(model, glm::vec3(-0.5f * size.x, -0.5f * size.y, 0.0f)); // Move origin back

    model = glm::scale(model, glm::vec3(size, 1.0f)); // Last scale

	GLint model_loc = shader->GetUniform("model");
	glUniformMatrix4fv(model_loc, 1, false, glm::value_ptr(model));

    // Render textured quad
	GLint image_loc = shader->GetUniform("image");
	glUniform1i(image_loc, 0);

	glm::mat4 projection = glm::ortho(0.0f, static_cast<GLfloat>(Window::width),
		static_cast<GLfloat>(Window::height), 0.0f, -1.0f, 1.0f);
	GLint projection_loc = shader->GetUniform("projection");
	glUniformMatrix4fv(projection_loc, 1, false, glm::value_ptr(projection));

    //glActiveTexture(GL_TEXTURE0);
    texture.Bind(GL_TEXTURE0);

    glBindVertexArray(this->quadVAO);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glBindVertexArray(0);
}
开发者ID:bhn26,项目名称:CSE125,代码行数:42,代码来源:SpriteRenderer.cpp

示例15: Draw

void Object::Draw(ShaderProgram &prog) 
{
	Texture *tex = objectType.texture;

	int i = 0;
	for (std::vector<Bone *>::iterator it = bones.begin(); it != bones.end(); ++it, ++i)
	{
		char name[20];
		sprintf(name, "mat_model[%d]", i);
		prog.Set(name, (*it)->transformation);
	}
	bool bound = tex->Bind(prog, "modeltex");
	bool boundS = objectType.specularT->Bind(prog, "speculartex");
	bool boundN = objectType.normalT->Bind(prog, "normaltex");
	bool boundE = objectType.emissiveT->Bind(prog, "emissivetex");
	objectType.gfxModel->Draw(prog);

	if (bound) prog.curtex--;
	if (boundS) prog.curtex--;
	if (boundN) prog.curtex--;
	if (boundE) prog.curtex--;
}
开发者ID:,项目名称:,代码行数:22,代码来源:


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