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


C++ CL_GraphicContext::set_texture方法代码示例

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


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

示例1: prim_array

void CL_RenderBatch3D::flush(CL_GraphicContext &gc)
{
	if (position > 0)
	{
		gc.set_modelview(CL_Mat4f::identity());
		gc.set_program_object(cl_program_sprite);

		if (use_glyph_program)
		{
			CL_BlendMode old_blend_mode = gc.get_blend_mode();
			CL_BlendMode blend_mode;
			blend_mode.set_blend_color(constant_color);
			blend_mode.set_blend_function(cl_blend_constant_color, cl_blend_one_minus_src_color, cl_blend_zero, cl_blend_one);
			gc.set_blend_mode(blend_mode);

			for (int i = 0; i < num_current_textures; i++)
				gc.set_texture(i, current_textures[i]);
			CL_PrimitivesArray prim_array(gc);
			prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
			prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
			prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
			prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
			gc.draw_primitives(cl_triangles, position, prim_array);
			for (int i = 0; i < num_current_textures; i++)
				gc.reset_texture(i);

			gc.set_blend_mode(old_blend_mode);
		}
		else
		{
			for (int i = 0; i < num_current_textures; i++)
				gc.set_texture(i, current_textures[i]);
			CL_PrimitivesArray prim_array(gc);
			prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
			prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
			prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
			prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
			gc.draw_primitives(cl_triangles, position, prim_array);
			for (int i = 0; i < num_current_textures; i++)
				gc.reset_texture(i);
		}

		gc.reset_program_object();
		gc.set_modelview(modelview);
		position = 0;
		for (int i = 0; i < num_current_textures; i++)
			current_textures[i] = CL_Texture();
		num_current_textures = 0;
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:50,代码来源:render_batch3d.cpp

示例2: Draw

void Model_Impl::Draw(CL_GraphicContext &gc, GraphicStore *gs, const CL_Mat4f &modelview_matrix)
{
	gc.set_modelview(modelview_matrix);

	CL_PrimitivesArray prim_array(gc);

	prim_array.set_attributes(0, vbo_positions, 3, cl_type_float, (void *) 0);
	prim_array.set_attributes(1, vbo_normals, 3, cl_type_float, (void *) 0);

	if (!vbo_texcoords.is_null())
	{
		prim_array.set_attributes(2, vbo_texcoords, 2, cl_type_float, (void *) 0);
		gc.set_texture(0, gs->texture_underwater);
		gc.set_texture(1, gs->texture_background);
		gs->shader_texture.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
		gs->shader_texture.Use(gc);
	}
	else
	{
		throw CL_Exception("What! no texure coordinates?");
	}

	gc.draw_primitives(cl_triangles, vbo_size, prim_array);

	gc.reset_texture(0);
	gc.reset_texture(0);

}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:28,代码来源:model.cpp

示例3: Draw

void Model_Impl::Draw(CL_GraphicContext &gc, GraphicStore *gs, const CL_Mat4f &modelview_matrix, bool is_draw_shadow)
{
	gc.set_modelview(modelview_matrix);

	CL_PrimitivesArray prim_array(gc);

	prim_array.set_attributes(0, vbo_positions, 3, cl_type_float, (void *) 0);
	prim_array.set_attributes(1, vbo_normals, 3, cl_type_float, (void *) 0);

	if (is_draw_shadow)
	{
		gs->shader_depth.Use(gc);
		gc.draw_primitives(cl_triangles, vbo_size, prim_array);
	}
	else
	{
		if (!vbo_texcoords.is_null())
		{
			prim_array.set_attributes(2, vbo_texcoords, 2, cl_type_float, (void *) 0);
			gs->shader_texture.SetShadowMatrix(gs->shadow_matrix);
			gc.set_texture(0, gs->texture_brick);
			gc.set_texture(1, gs->texture_shadow);
			gs->shader_texture.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
			gs->shader_texture.Use(gc);
		}
		else
		{
			gs->shader_color.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
			gs->shader_color.Use(gc);
		}

		gc.draw_primitives(cl_triangles, vbo_size, prim_array);

		gc.reset_texture(0);
		gc.reset_texture(1);
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:37,代码来源:model.cpp

示例4: draw_text

void ExampleText::draw_text(CL_GraphicContext &gc, CL_Texture &texture, CL_Angle angle)
{
	gc.set_texture(0, texture);

	gc.push_modelview();

	gc.mult_translate(gc.get_width()/2.0f, gc.get_height()/2.0f);
	gc.mult_rotate(angle, 0.0f, 0.0f, 1.0f);

	CL_Draw::texture(gc, CL_Rectf(-300.0f, -300.0f, 300.0f, 300.0f), CL_Colorf(1.0f, 1.0f, 1.0f, 0.7f));

	gc.pop_modelview();

	gc.reset_texture(0);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:15,代码来源:Text.cpp

示例5: render_night_vision

void App::render_night_vision(CL_GraphicContext &gc, CL_Texture &source_texture, CL_Texture &mask_texture, CL_Texture &noise_texture, CL_ProgramObject &program_object)
{
	program_object.set_uniform1i("sceneBuffer", 0);
	program_object.set_uniform1i("noiseTex", 1);
	program_object.set_uniform1i("maskTex", 2);

	program_object.set_uniform1f("elapsedTime", elapsedTime);
	program_object.set_uniform1f("luminanceThreshold", luminanceThreshold);
	program_object.set_uniform1f("colorAmplification", colorAmplification);
	program_object.set_uniform1f("effectCoverage", effectCoverage);

	gc.set_texture(0, source_texture);
	gc.set_texture(1, noise_texture);
	gc.set_texture(2, mask_texture);
	
	gc.set_program_object(program_object, cl_program_matrix_modelview_projection);

	draw_texture(gc, CL_Rectf(0,0,gc.get_width(),gc.get_height()), CL_Colorf::white, CL_Rectf(0.0f, 0.0f, 1.0f, 1.0f));

	gc.reset_program_object();
	gc.reset_texture(2);
	gc.reset_texture(1);
	gc.reset_texture(0);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:24,代码来源:app.cpp

示例6: Draw

void ObjectPolygon::Draw(CL_GraphicContext &gc, CL_Texture &texture_image)
{
	ObjectVertex *vptr = m_pVertex;
	CL_Vec3f positions[6];
	CL_Vec3f texture_positions[6];
	CL_Vec3f normals[6];

	// We convert quads into triangles. This is silly, and this entire example should be rewritten to just use triangles

	if (m_NumVertex!=4) throw CL_Exception("Ooops");

	positions[0] = m_pVertex[0].m_Point;
	texture_positions[0] = m_pVertex[0].m_TexturePoint;
	normals[0] = m_Normal;
	positions[1] = m_pVertex[1].m_Point;
	texture_positions[1] = m_pVertex[1].m_TexturePoint;
	normals[1] = m_Normal;
	positions[2] = m_pVertex[2].m_Point;
	texture_positions[2] = m_pVertex[2].m_TexturePoint;
	normals[2] = m_Normal;

	positions[3] = m_pVertex[2].m_Point;
	texture_positions[3] = m_pVertex[2].m_TexturePoint;
	normals[3] = m_Normal;
	positions[4] = m_pVertex[3].m_Point;
	texture_positions[4] = m_pVertex[3].m_TexturePoint;
	normals[4] = m_Normal;
	positions[5] = m_pVertex[0].m_Point;
	texture_positions[5] = m_pVertex[0].m_TexturePoint;
	normals[5] = m_Normal;


	CL_PrimitivesArray prim_array(gc);

	gc.set_texture(0, texture_image);

	prim_array.set_attributes(cl_attrib_position, positions);
	prim_array.set_attribute(cl_attrib_color, CL_Colorf(1.0f,1.0f,1.0f, 1.0f));
	prim_array.set_attributes(cl_attrib_texture_position, texture_positions);
	prim_array.set_attributes(cl_attrib_normal, normals);
	gc.set_primitives_array(prim_array);

	gc.draw_primitives_array(cl_triangles, 6);

	gc.reset_texture(0);

	gc.reset_primitives_array();
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:48,代码来源:object.cpp

示例7: render_gaussian_blur

void App::render_gaussian_blur(CL_GraphicContext &gc, float blur_amount, CL_Texture &source_texture, CL_ProgramObject &program_object, float dx, float dy)
{
	int sampleCount = 15;

	float *sampleWeights = new float[sampleCount];
	CL_Vec2f *sampleOffsets = new CL_Vec2f[sampleCount];

	sampleWeights[0] = compute_gaussian(0, blur_amount);
	sampleOffsets[0] = CL_Vec2f(0.0, 0.0);

	float totalWeights = sampleWeights[0];

	for (int i = 0; i < sampleCount / 2; i++)
	{
		float weight = compute_gaussian(i + 1.0f, blur_amount);

		sampleWeights[i * 2 + 1] = weight;
		sampleWeights[i * 2 + 2] = weight;

		totalWeights += weight * 2;

		float sampleOffset = i * 2 + 1.5f;

		CL_Vec2f delta = CL_Vec2f(dx * sampleOffset, dy * sampleOffset);

		sampleOffsets[i * 2 + 1] = delta;
		sampleOffsets[i * 2 + 2] = CL_Vec2f(-delta.x, -delta.y);
	}

	for (int i = 0; i < sampleCount; i++)
	{
		sampleWeights[i] /= totalWeights;
	}

	program_object.set_uniform1i("SourceTexture", 0);
	program_object.set_uniformfv("SampleOffsets", 2, sampleCount, (float *)sampleOffsets);
	program_object.set_uniformfv("SampleWeights", 1, sampleCount, sampleWeights);

	gc.set_texture(0, source_texture);
	gc.set_program_object(program_object, cl_program_matrix_modelview_projection);

	draw_texture(gc, CL_Rectf(0,0,gc.get_width(),gc.get_height()), CL_Colorf::white, CL_Rectf(0.0f, 0.0f, 1.0f, 1.0f));

	gc.reset_program_object();
	gc.reset_texture(0);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:46,代码来源:app.cpp

示例8: render

void Skybox::render(CL_GraphicContext &gc, const Camera &camera)
{
	Camera cam = camera;
	cam.get_position().set_position(0,0,0);
	cam.setup_gc(gc, 0.1f, 10.0f);

	gc.set_texture(0, skybox_texture);
	gc.set_program_object(program_object);
	program_object.set_uniform1i(("texture1"), 0);

	CL_PrimitivesArray prim_array(gc);
	prim_array.set_attributes(0, positions);
	gc.draw_primitives(cl_triangles, 6*6, prim_array);

	gc.reset_program_object();
	gc.reset_texture(0);

}
开发者ID:animehunter,项目名称:Space-Game-3D,代码行数:18,代码来源:skybox.cpp

示例9: flush

void HSVSpriteBatch::flush(CL_GraphicContext &gc)
{
	if (fill_position > 0)
	{
		CL_PrimitivesArray primarray(gc);
		primarray.set_attributes(0, positions);
		primarray.set_attributes(1, hue_offsets);
		primarray.set_attributes(2, tex1_coords);

		gc.set_texture(0, current_texture);
		gc.set_program_object(program, cl_program_matrix_modelview_projection);
		gc.draw_primitives(cl_triangles, fill_position, primarray);
		gc.reset_program_object();
		gc.reset_texture(0);

		fill_position = 0;
		current_texture = CL_Texture();
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:19,代码来源:hsv_sprite_batch.cpp

示例10: end

void ShaderImpl::end(CL_GraphicContext &p_gc)
{
	G_ASSERT(m_initialized);
	G_ASSERT(m_began);

	// detach frame buffer
	p_gc.reset_frame_buffer();
	m_frameBuffer.detach_color_buffer(0, m_texture);

	// prepare shader
	m_program.set_uniform1i("tex", 0);
	m_program.set_uniform1i("textureWidth", m_drawRect.get_width());
	m_program.set_uniform1i("textureHeight", m_drawRect.get_height());

	m_parent->setUniforms(m_program);

	// draw texture using shader
	p_gc.set_modelview(CL_Mat4f::identity());
	p_gc.mult_translate(m_drawRect.left, m_drawRect.top);
	p_gc.mult_scale(m_drawRect.get_width(), m_drawRect.get_height());

	p_gc.set_texture(0, m_texture);
	p_gc.set_program_object(m_program);

	p_gc.draw_primitives(cl_quads, 4, m_quad);

	p_gc.reset_program_object();
	p_gc.reset_texture(0);

#if defined(DRAW_WIREFRAME)
	CL_Draw::line(p_gc, 0, 0, 1, 0, CL_Colorf::red);
	CL_Draw::line(p_gc, 1, 0, 1, 1, CL_Colorf::red);
	CL_Draw::line(p_gc, 1, 1, 0, 1, CL_Colorf::red);
	CL_Draw::line(p_gc, 0, 1, 0, 0, CL_Colorf::red);
#endif // DRAW_WIREFRAME

	// reset modelview matrix
	p_gc.pop_modelview();

	m_began = false;
}
开发者ID:genail,项目名称:gear,代码行数:41,代码来源:Shader.cpp

示例11: texture

void CL_Draw::texture(
	CL_GraphicContext &gc,
	const CL_Texture &texture,
	const CL_Quadf &quad,
	const CL_Colorf &color,
	const CL_Rectf &texture_unit1_coords)
{
	CL_Vec2f positions[6] =
	{
		CL_Vec2f(quad.p),
		CL_Vec2f(quad.q),
		CL_Vec2f(quad.s),
		CL_Vec2f(quad.q),
		CL_Vec2f(quad.s),
		CL_Vec2f(quad.r)
	};

	CL_Vec2f tex1_coords[6] =
	{
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
	};

	CL_PrimitivesArray prim_array(gc);
	prim_array.set_attributes(0, positions);
	prim_array.set_attribute(1, color);
	prim_array.set_attributes(2, tex1_coords);
	gc.set_texture(0, texture);
	gc.set_program_object(cl_program_single_texture);
	gc.draw_primitives(cl_triangles, 6, prim_array);
	gc.reset_program_object();
	gc.reset_texture(0);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:37,代码来源:draw.cpp

示例12: draw

void Sandpit::draw(CL_GraphicContext &p_gc)
{
	assert(m_built);

	if (m_texture.is_null()) {
		// create texture
		m_texture = CL_SharedPtr<CL_Texture>(
				new CL_Texture(
						p_gc,
						m_pixelData->get_width(), m_pixelData->get_height()
				)
		);

		m_texture->set_image(*m_pixelData);
	}

	p_gc.set_texture(0, *m_texture);

	CL_Rectf drawRect(0, 0, m_pixelData->get_width(), m_pixelData->get_height());

	p_gc.push_translate(m_position.x, m_position.y);
	CL_Draw::texture(p_gc, drawRect, CL_Colorf::white);
	p_gc.pop_modelview();
}
开发者ID:genail,项目名称:gear,代码行数:24,代码来源:Sandpit.cpp

示例13: render_texture

void HSV::render_texture(CL_GraphicContext &gc, CL_ProgramObject &program, CL_Texture &texture, float hue_offset)
{
	CL_Rectf rect(0.0f, 0.0f, (float)gc.get_width(), (float)gc.get_height());
	CL_Rectf texture_unit1_coords(0.0f, 0.0f, 1.0f, 1.0f);

	CL_Vec2f positions[6] =
	{
		CL_Vec2f(rect.left, rect.top),
		CL_Vec2f(rect.right, rect.top),
		CL_Vec2f(rect.left, rect.bottom),
		CL_Vec2f(rect.right, rect.top),
		CL_Vec2f(rect.left, rect.bottom),
		CL_Vec2f(rect.right, rect.bottom)
	};

	CL_Vec2f tex1_coords[6] =
	{
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
	};

	CL_PrimitivesArray primarray(gc);
	primarray.set_attributes(0, positions);
	primarray.set_attribute(1, CL_Vec1f(hue_offset));
	primarray.set_attributes(2, tex1_coords);

	gc.set_texture(0, texture);
	gc.set_program_object(program, cl_program_matrix_modelview_projection);
	gc.draw_primitives(cl_triangles, 6, primarray);
	gc.reset_program_object();
	gc.reset_texture(0);
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:36,代码来源:hsv.cpp

示例14: start


//.........这里部分代码省略.........

	cl1Enable(GL_NORMALIZE);
#endif

#ifdef USE_OPENGL_2
    Shader shader(gc);
#endif

	// Create the objects

	aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,89.53f);

	const struct aiScene* scene_teapot = aiImportFile("../Clan3D/Resources/teapot.dae",aiProcessPreset_TargetRealtime_MaxQuality);
	if (!scene_teapot)
		throw CL_Exception("Cannot load the teapot model");

	const struct aiScene* scene_clanlib = aiImportFile("../Clan3D/Resources/clanlib.dae",aiProcessPreset_TargetRealtime_MaxQuality);
	if (!scene_clanlib)
		throw CL_Exception("Cannot load the clanlib model");

	const struct aiScene* scene_tuxball = aiImportFile("../Clan3D/Resources/tux_ball.dae",aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_FlipUVs);
	if (!scene_tuxball)
		throw CL_Exception("Cannot load the tux ball model");

	// Load the texture
	CL_Texture tux(gc, "../Clan3D/Resources/tux.png");

	float angle = 0.0f;
	// Run until someone presses escape
	while (!quit)
	{

		CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 1000.0f);
		gc.set_projection(perp);

		gc.clear(CL_Colorf::black);
		gc.clear_depth(1.0f);

		angle += 1.0f;
		if (angle >= 360.0f)
			angle -= 360.0f;


#ifdef USE_OPENGL_2
        shader.Set(gc);
        shader.Use(gc);
#else
        gc.set_program_object(cl_program_color_only);
#endif

		CL_PrimitivesArray prim_array(gc);

		gc.set_modelview(CL_Mat4f::identity());
		gc.mult_scale(1.0f,1.0f, -1.0f);	// So +'ve Z goes into the screen
		gc.mult_translate(0.0f, 0.0f, 2.0f);
		gc.mult_rotate(CL_Angle(angle, cl_degrees), 0.0f, 1.0f, 0.0f, false);

		gc.push_modelview();
		recursive_render(gc, scene_teapot, scene_teapot->mRootNode, false);
		gc.pop_modelview();

		gc.push_modelview();
		gc.mult_scale(0.5f, 0.5f, 0.5f);
		gc.mult_translate(0.0f, -0.5f, 0.0f);
		recursive_render(gc, scene_clanlib, scene_clanlib->mRootNode, false);
		gc.pop_modelview();

#ifdef USE_OPENGL_2
        shader.Set(gc, 0);
        shader.Use(gc);
#else
        gc.set_program_object(cl_program_single_texture);
#endif

		gc.set_texture(0, tux);
 		gc.set_modelview(CL_Mat4f::identity());
		gc.mult_scale(1.0f,1.0f, -1.0f);	// So +'ve Z goes into the screen
		gc.mult_translate(0.7f, 0.5f, 2.0f);
		gc.mult_scale(0.05f, 0.05f, 0.05f);
		gc.mult_rotate(CL_Angle(angle * 4.0f, cl_degrees), 0.0f, 1.0f, 0.0f, false);
		recursive_render(gc, scene_tuxball, scene_tuxball->mRootNode, true);
		gc.reset_texture(0);

		gc.reset_program_object();
		
		// Flip the display, showing on the screen what we have drawed
		// since last call to flip()
		window.flip(1);

		// This call processes user input and other events
		CL_KeepAlive::process();
	}

	aiReleaseImport(scene_tuxball);
	aiReleaseImport(scene_clanlib);
	aiReleaseImport(scene_teapot);
	aiDetachAllLogStreams();

	return 0;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:101,代码来源:example.cpp

示例15: render

void ContainerRenderer::render(CL_GraphicContext& gc) {
    renderQueue_->preRender();

    gc.clear(CL_Colorf(0.f, 0.f, 0.f, 0.f));

    boost::shared_ptr<CL_ProgramObject> shader = ui::Manager::getShaderManager()->getGumpShader();
    gc.set_program_object(*shader, cl_program_matrix_modelview_projection);

    CL_Texture huesTexture = data::Manager::getHuesLoader()->getHuesTexture();
    gc.set_texture(0, huesTexture);
    // set texture unit 1 active to avoid overriding the hue texture with newly loaded object textures
    gc.set_texture(1, huesTexture);

    shader->set_uniform1i("HueTexture", 0);
    shader->set_uniform1i("ObjectTexture", 1);

    RenderQueue::const_iterator igIter = renderQueue_->begin();
    RenderQueue::const_iterator igEnd = renderQueue_->end();

    CL_Vec2f vertexCoords[6];

    bool renderingComplete = true;

    // draw background container texture
    boost::shared_ptr<ui::Texture> bgTex = containerView_->getBackgroundTexture();
    if (bgTex && bgTex->isReadComplete()) {
        CL_Vec3f hueInfo(0, 0, 1);

        CL_Rectf rect(0, 0, CL_Sizef(bgTex->getWidth(), bgTex->getHeight()));

        vertexCoords[0] = CL_Vec2f(rect.left, rect.top);
        vertexCoords[1] = CL_Vec2f(rect.right, rect.top);
        vertexCoords[2] = CL_Vec2f(rect.left, rect.bottom);
        vertexCoords[3] = CL_Vec2f(rect.right, rect.top);
        vertexCoords[4] = CL_Vec2f(rect.left, rect.bottom);
        vertexCoords[5] = CL_Vec2f(rect.right, rect.bottom);

        CL_Rectf texCoordHelper = bgTex->getNormalizedTextureCoords();

        CL_Vec2f texCoords[6] = {
            CL_Vec2f(texCoordHelper.left, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.left, texCoordHelper.bottom),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.left, texCoordHelper.bottom),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.bottom)
        };

        CL_PrimitivesArray primarray(gc);
        primarray.set_attributes(0, vertexCoords);
        primarray.set_attributes(1, texCoords);

        primarray.set_attribute(2, hueInfo);

        gc.set_texture(1, bgTex->getTexture());
        gc.draw_primitives(cl_triangles, 6, primarray);
    } else {
        renderingComplete = false;
    }

    for (; igIter != igEnd; ++igIter) {
        boost::shared_ptr<world::IngameObject> curObj = *igIter;

        // just items in a container
        if (!curObj->isDynamicItem()) {
            continue;
        }

        // check if texture is ready to be drawn
        boost::shared_ptr<ui::Texture> tex = curObj->getIngameTexture();

        if (!tex) {
            continue;
        }

        if (!tex->isReadComplete()) {
            renderingComplete = false;
            continue;
        }

        CL_Rectf rect(curObj->getLocXDraw(), curObj->getLocYDraw(), CL_Sizef(tex->getWidth(), tex->getHeight()));

        vertexCoords[0] = CL_Vec2f(rect.left, rect.top);
        vertexCoords[1] = CL_Vec2f(rect.right, rect.top);
        vertexCoords[2] = CL_Vec2f(rect.left, rect.bottom);
        vertexCoords[3] = CL_Vec2f(rect.right, rect.top);
        vertexCoords[4] = CL_Vec2f(rect.left, rect.bottom);
        vertexCoords[5] = CL_Vec2f(rect.right, rect.bottom);

        CL_Rectf texCoordHelper = tex->getNormalizedTextureCoords();

        CL_Vec2f texCoords[6] = {
            CL_Vec2f(texCoordHelper.left, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.left, texCoordHelper.bottom),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.top),
            CL_Vec2f(texCoordHelper.left, texCoordHelper.bottom),
            CL_Vec2f(texCoordHelper.right, texCoordHelper.bottom)
        };

//.........这里部分代码省略.........
开发者ID:abnr,项目名称:fluorescence,代码行数:101,代码来源:containerrenderer.cpp


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