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

C++ Texture类代码示例

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

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



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

示例1: drawRect

void NotPassableTerrain::HeihghtmapUpdated(const DAVA::Rect &forRect)
{
    EditorLandscape::HeihghtmapUpdated(forRect);
    
    AABBox3 boundingBox = nestedLandscape->GetBoundingBox();
    Vector3 landSize = boundingBox.max - boundingBox.min;

    float32 angleCellDistance = landSize.x / (float32)(heightmap->Size() - 1);
    float32 angleHeightDelta = landSize.z / (float32)(Heightmap::MAX_VALUE - 1);
    float32 tanCoef = angleHeightDelta / angleCellDistance;
 
    Texture *notPassableMap = notPassableMapSprite->GetTexture();
    float32 dx = (float32)notPassableMap->GetWidth() / (float32)(heightmap->Size() - 1);
    
    RenderManager::Instance()->LockNonMain();
    RenderManager::Instance()->SetRenderTarget(notPassableMapSprite);

    Rect drawRect(forRect.x * dx, forRect.y * dx, (forRect.dx - 1)* dx, (forRect.dy - 1) * dx);
    RenderManager::Instance()->ClipPush();
    RenderManager::Instance()->ClipRect(drawRect);

    DrawFullTiledTexture(notPassableMap, drawRect);
    
    int32 lastY = (int32)(forRect.y + forRect.dy);
    int32 lastX = (int32)(forRect.x + forRect.dx);
    for (int32 y = (int32)forRect.y; y < lastY; ++y)
    {
        int32 yOffset = y * heightmap->Size();
        for (int32 x = (int32)forRect.x; x < lastX; ++x)
        {
            uint16 currentPoint = heightmap->Data()[yOffset + x];
            uint16 rightPoint = heightmap->Data()[yOffset + x + 1];
            uint16 bottomPoint = heightmap->Data()[yOffset + x + heightmap->Size()];
            
            uint16 deltaRight = (uint16)abs((int32)currentPoint - (int32)rightPoint);
            uint16 deltaBottom = (uint16)abs((int32)currentPoint - (int32)bottomPoint);
            
            float32 tanRight = (float32)deltaRight * tanCoef;
            float32 tanBottom = (float32)deltaBottom * tanCoef;
            
            float32 ydx = y * dx;
            float32 xdx = x * dx;

            RenderManager* renderManager = RenderManager::Instance();
            RenderHelper* renderHelper = RenderHelper::Instance();
            
            Color color;

            if(PickColor(tanRight, color))
            {
                renderManager->SetColor(color);
                renderHelper->DrawLine(Vector2(xdx, ydx), Vector2((xdx + dx), ydx));
            }
            
            if(PickColor(tanBottom, color))
            {
                renderManager->SetColor(color);
                renderHelper->DrawLine(Vector2(xdx, ydx), Vector2(xdx, (ydx + dx)));
            }
            
        }
    }

    RenderManager::Instance()->ResetColor();
    
    RenderManager::Instance()->ClipPop();
    
    RenderManager::Instance()->RestoreRenderTarget();
    RenderManager::Instance()->UnlockNonMain();
}
开发者ID:boyjimeking,项目名称:dava.framework,代码行数:70,代码来源:NotPassableTerrain.cpp


示例2: destroyTexture

//----------------------------------------------------------------------------//
void OgreRenderer::destroyTexture(Texture& texture)
{
    destroyTexture(texture.getName());
}
开发者ID:Toby91,项目名称:DDEngine,代码行数:5,代码来源:Renderer.cpp


示例3: glBindFramebuffer

void RenderTextureTarget::addColorAttachment(const Texture& texture)
{
	glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
	glFramebufferTexture(GL_FRAMEBUFFER, toGlFrameBufferAttachment(FrameBufferAttachment_Color) + m_colorAttachmentCount, texture._getGlTextureId(), 0);
	++m_colorAttachmentCount;

	std::vector<GLenum> buffers;
	for (int i = 0; i < m_colorAttachmentCount; ++i)
	{
		buffers.push_back(GL_COLOR_ATTACHMENT0_EXT + i);
	}
	assert(!buffers.empty());
	glDrawBuffers(m_colorAttachmentCount, &buffers[0]);
}
开发者ID:fohr,项目名称:Graphtane,代码行数:14,代码来源:RenderTextureTarget.cpp


示例4: texture

void wgd::Font::bind() {
	if (m_needsbuild) buildFont();
	m_needsbuild = false;
	Texture *tex = texture();
	if (tex != 0) tex->bind();
}
开发者ID:knicos,项目名称:Cadence,代码行数:6,代码来源:font.cpp


示例5: Texture

void wgd::Font::buildFont() {

	//Delete any existing font display lists
	//if (m_base != 0xFFFFFFFF)
	//	destroyFont();

	//Create new GL display lists for this font
	//m_base = glGenLists(96);

	Texture *tex;
		//Make a texture for it
	if (get(ix::texture) == Null) {
		tex = new Texture();
		tex->compress(false);
		tex->nearest(true);
		if (size() < 32) {
			tex->width(256);
			tex->height(256);
		} else {
			tex->width(512);
			tex->height(512);
		}
		texture(tex);
		//Processor::processAll();
		tex->make(RGBA);
		//Processor::processAll();
	} else {
		tex = texture();
		if (!tex->isLoaded()) {
			tex->compress(false);
			tex->nearest(true);
			if (size() < 32) {
				tex->width(256);
				tex->height(256);
			} else {
				tex->width(512);
				tex->height(512);
			}
			tex->make(RGBA);
		}
	}
	
	if (tex == 0) return;
	
	#ifdef WIN32
	HFONT font;
	HFONT oldfont;
	
	#ifdef UNICODE
	int wLen = name().size() + 1;
	wchar_t *wFont = new wchar_t[wLen];
	mbstowcs(wFont, name(), wLen);
	#else
	char *wFont = strdup(name());
	#endif
	
	
	//Ask windows for a font
	font = CreateFont(	-size(),//Height
				0,	//Width
				0,	//Angle
				0,	//Orientation
				(bold()) ? FW_BOLD : FW_REGULAR,//Weight
				FALSE,	//Italic
				FALSE,	//UNDERLINE
				FALSE,	//Strikeout
				ANSI_CHARSET,
				OUT_TT_PRECIS,
				CLIP_DEFAULT_PRECIS,
				ANTIALIASED_QUALITY,
				FF_DONTCARE | DEFAULT_PITCH,
				wFont);	//Font name

	HDC memDC = CreateCompatibleDC(wgd::window->getHDC());
	//Select this new font and save the current one.
	oldfont = (HFONT)SelectObject(memDC, font);
	//Get windows to generate display lists for this font
	//wglUseFontBitmaps(memDC, 32, 96, m_base);

	HBITMAP bmp = CreateCompatibleBitmap(memDC, tex->width(),tex->height());
	HBITMAP oldbmp = (HBITMAP)SelectObject(memDC, bmp);
	
	char letter = '@';
	int x = 0;
	int y = 0;// size();
	int w;
	int h;
	//GetCharWidth(memDC, letter, letter, &w);
	TEXTMETRIC tmet;
	GetTextMetrics(memDC, &tmet);
	SetTextColor(memDC, 0x00FFFFFF);
	SetBkColor(memDC, 0x00000000);

	w = tmet.tmAveCharWidth;
	h = tmet.tmHeight;
	//width(w);
	//height(h);

	for (int i=32; i<128; i++) {
		//if (i >= 65 && i <= 90)
//.........这里部分代码省略.........
开发者ID:knicos,项目名称:Cadence,代码行数:101,代码来源:font.cpp


示例6: KFL_UNUSED

	void OGLESTexture3D::CopyToSubTexture3D(Texture& target,
			uint32_t dst_array_index, uint32_t dst_level, uint32_t dst_x_offset, uint32_t dst_y_offset, uint32_t dst_z_offset, uint32_t dst_width, uint32_t dst_height, uint32_t dst_depth,
			uint32_t src_array_index, uint32_t src_level, uint32_t src_x_offset, uint32_t src_y_offset, uint32_t src_z_offset, uint32_t src_width, uint32_t src_height, uint32_t src_depth)
	{
		KFL_UNUSED(dst_depth);

		BOOST_ASSERT(type_ == target.Type());
		BOOST_ASSERT(0 == src_array_index);
		BOOST_ASSERT(0 == dst_array_index);

		if ((src_width == dst_width) && (src_height == dst_height) && (src_depth == dst_depth) && (format_ == target.Format()))
		{
			if (IsCompressedFormat(format_))
			{
				BOOST_ASSERT((0 == (src_x_offset & 0x3)) && (0 == (src_y_offset & 0x3)));
				BOOST_ASSERT((0 == (dst_x_offset & 0x3)) && (0 == (dst_y_offset & 0x3)));
				BOOST_ASSERT((0 == (src_width & 0x3)) && (0 == (src_height & 0x3)));
				BOOST_ASSERT((0 == (dst_width & 0x3)) && (0 == (dst_height & 0x3)));

				for (uint32_t z = 0; z < src_depth; ++ z)
				{
					Texture::Mapper mapper_src(*this, src_array_index, src_level, TMA_Read_Only,
						src_x_offset, src_y_offset, src_z_offset + z, src_width, src_height, 1);
					Texture::Mapper mapper_dst(target, dst_array_index, dst_level, TMA_Write_Only,
						dst_x_offset, dst_y_offset, dst_z_offset + z, dst_width, dst_height, 1);

					uint32_t const block_size = NumFormatBytes(format_) * 4;
					uint8_t const * s = mapper_src.Pointer<uint8_t>();
					uint8_t* d = mapper_dst.Pointer<uint8_t>();
					for (uint32_t y = 0; y < src_height; y += 4)
					{
						std::memcpy(d, s, src_width / 4 * block_size);

						s += mapper_src.RowPitch();
						d += mapper_dst.RowPitch();
					}
				}
			}
			else
			{
				for (uint32_t z = 0; z < src_depth; ++ z)
				{
					size_t const format_size = NumFormatBytes(format_);

					Texture::Mapper mapper_src(*this, src_array_index, src_level, TMA_Read_Only,
						src_x_offset, src_y_offset, src_z_offset + z, src_width, src_height, 1);
					Texture::Mapper mapper_dst(target, dst_array_index, dst_level, TMA_Write_Only,
						dst_x_offset, dst_y_offset, dst_z_offset + z, dst_width, dst_height, 1);
					uint8_t const * s = mapper_src.Pointer<uint8_t>();
					uint8_t* d = mapper_dst.Pointer<uint8_t>();
					for (uint32_t y = 0; y < src_height; ++ y)
					{
						std::memcpy(d, s, src_width * format_size);

						s += mapper_src.RowPitch();
						d += mapper_dst.RowPitch();
					}
				}
			}
		}
		else
		{
			this->ResizeTexture3D(target, dst_array_index, dst_level, dst_x_offset, dst_y_offset, dst_z_offset, dst_width, dst_height, dst_depth,
				src_array_index, src_level, src_x_offset, src_y_offset, src_z_offset, src_width, src_height, src_depth, true);
		}
	}
开发者ID:BitYorkie,项目名称:KlayGE,代码行数:66,代码来源:OGLESTexture3D.cpp


示例7: glGenFramebuffers

void FrameBuffer::Init()
{
	glGenFramebuffers(1, &id);
	glBindFramebuffer(GL_FRAMEBUFFER, id);

//	GetGame()->Log(glGetError());

	drawBuffers.clear();
	Texture* tex = nullptr;
	if(textures.size() > 0)
	{
		for(uint i = 0; i < textures.size(); ++i)
		{
			tex = textures[i];
		//	tex->scaleFilter = Texture::ScaleFilter::Linear;
			tex->wrapMode = Texture::WrapMode::Clamp;
		//	tex->mode = GL_TEXTURE_2D_MULTISAMPLE;
			tex->size = uvec2(rect.width, rect.height);
			tex->SetIndex(startIndex+i);
			tex->InitData(0);

			uint32 attachment = startIndex+GL_COLOR_ATTACHMENT0+i;
			GetGame()->Log("Setting up textures for FrameBuffer, tex ", i, " gets attachment ", attachment, ". GL_COLOR_ATTACHMENT0 = ", GL_COLOR_ATTACHMENT0);

			tex->Bind();
			glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, tex->GetMode(), tex->GetId(), 0);

			drawBuffers.push_back(attachment);
		}
	}

	if(hasDepth)
	{
	/*	glGenRenderbuffers(1, &depthBuffer);
		glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
		glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, rect.width, rect.height);
		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthBuffer);
	*/
		if(depthTexture)
		{
		//	depthTexture->SetFormat(Texture::Format::Depth32F_Stencil8, Texture::Format::Depth);
			depthTexture->SetFormat(Texture::Format::Depth32F, Texture::Format::Depth);
			depthTexture->wrapMode = Texture::WrapMode::Clamp;
			depthTexture->dataType = Texture::DataType::Float;
			depthTexture->size = uvec2(rect.width, rect.height);
			depthTexture->SetIndex(startIndex+textures.size());
			depthTexture->InitData(0);

			depthTexture->Bind();
			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, depthTexture->GetMode(), depthTexture->GetId(), 0);

			GetGame()->Log(glGetError());
		}
	}

	DrawBuffers();

	BeginRender();

	Unbind();
}
开发者ID:jjiezheng,项目名称:lfant,代码行数:61,代码来源:FrameBuffer.cpp


示例8: destroyTexture

//----------------------------------------------------------------------------//
void OpenGLRendererBase::destroyTexture(Texture& texture)
{
    destroyTexture(texture.getName());
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:5,代码来源:RendererBase.cpp


示例9: toTexture

bool Image::toTexture(Texture& texture) const
{
    return texture.load((byte*)&_pixels.front(), _width, _height);
}
开发者ID:Cpasjuste,项目名称:Kairy,代码行数:4,代码来源:Image.cpp


示例10: mainLevel

void mainLevel(RenderWindow &window)
{
	//>>>>>>>>>>>>>>>---Level---<<<<<<<<<<<<<<<<<<<<<<<<<<<
	 Level lvl;
	 lvl.LoadFromFile("map.tmx");

	//>>>>>>>>>>>>>>>>---Load basic image for level1----<<<<<<<<<<<<<<<<<
	Texture texture;
	texture.loadFromFile("images/level1empty.jpg");
	Sprite level(texture);

	Texture texture2; 
	texture2.loadFromFile("images/levelShad.png");
	Sprite level2(texture2);

	Texture texture3;
	texture3.loadFromFile("images/level12.png");
	Sprite level3(texture3);
	//>>>>>>>>>>>>>>>>---Music---<<<<<<<<<<<<<<<<<<<<<<<<<<
	 Music mainSong;
	 Music skyrim, muse, bathMus;
	 bathMus.openFromFile("music/bath.ogg");
	 Object mus = lvl.GetObject("muse");
	 muse.openFromFile("music/synd.ogg"); muse.setVolume(100);
	 skyrim.openFromFile("music/skyrim.ogg"); skyrim.setVolume(100);
	 mainSong.openFromFile("music/level1.ogg");
	 mainSong.play();
	 mainSong.setLoop(true);
	 mainSong.setVolume(75);

	 //>>>>>>>>>>>>>>>>---Create a cat---<<<<<<<<<<<<<<<<<<<
	 Object player = lvl.GetObject("cat");
	 Object fish = lvl.GetObject("fish");
	 Object mo = lvl.GetObject("mouse");
	 Object ob = lvl.GetObject("catPlace");


	 Player cat("cat.png", lvl, 68, 429, 60, 120, player.rect.left,  player.rect.top, ELSE);
	 
	 Clock clock;
	 Clock gameTimeClock;
	 int sinkCnt = 0;

	 //>>>>>>>>>>>>>>>>---Sounds----<<<<<<<<<<<<<<<<<<<
	SoundBuffer buf1, buf2;
	buf1.loadFromFile("music/meow1.ogg");
	buf2.loadFromFile("music/meow2.ogg");
	Sound meow1, meow2;
	meow1.setBuffer(buf1);
	meow2.setBuffer(buf2);

	SoundBuffer buf, buf3;
	buf.loadFromFile("music/steklo.ogg");
	buf3.loadFromFile("music/mouse.ogg");
	Sound glass; Sound mouseS;
	glass.setBuffer(buf); glass.setVolume(100);
	mouseS.setBuffer(buf3);
	
	 //Objects
	 Furniture posters("tayles1.png",  160, 660, 210, 250, 280, 215, POSTERS);
	 Furniture bed("tayles1.png", 420, 80, 280, 310, 250, 440, ELSE); 
	 Furniture toys("tayles1.png", 120, 470, 180, 150, 220, 545, TOYS);
	 Furniture upShelf("tayles1.png", 700, 652.5, 120, 97.5, 350, 83, SHELF);
	 Furniture cabinet("tayles1.png", 75, 40, 250, 350, 605, 305, CABINET); 
	 Furniture mop("tayles1.png", 515, 785, 165, 241, 587, 385, MOP); 
	 Furniture flower("tayles1.png",780, 65, 170, 330, 147, 285, ELSE);
	 Furniture ball("tayles1.png", 905, 615, 40, 55, 357, 190, BALL); 
	 Furniture books("tayles1.png", 860, 735, 125, 80, 290, 187, BOOKS); 
	 Furniture brokenBall("tayles1.png",920, 540, 90, 42, 430, 430, ELSE); 
	 Furniture key("tayles1.png", 1, 1, 25, 25, 430, 425, KEY);
	 Furniture cabinetEnd("cabinet.png", 20, 50, 270, 350, 590, 290, ELSE); 
	 Furniture girl("girlHair.png", 1,1, 96, 45, 1075, 350, ELSE);
	 
	 Furniture door("tayles2.png", 0, 560, 80, 340, 870, 350, ELSE);
	 Furniture puddle("tayles1.png",789, 1000, 204, 75, 1057, 559, ELSE);
	 Furniture brokenLight("tayles2.png", 10, 110, 50, 70, 795, 430, ELSE);
	 Furniture light("tayles2.png", 20, 20, 35, 70, 220, 565, ELSE);
	 Furniture bath("tayles2.png", 80, 50, 320, 380, 1010, 330, BATH);
	 Furniture openBath("bathr.png", 264, 79, 339, 369, 1015, 315, ELSE);
	 Furniture carpet("tayles2.png", 100, 500, 100, 140, 870, 530, ELSE);
	 Furniture mirror("tayles2.png", 90, 700, 110, 290, 1200, 300, ELSE);
	 Furniture sink("tayles2.png", 290, 440, 150, 240, 1190, 450, SINK);
	 Furniture sinkWater("bathr.png", 22, 180, 197, 427, 1200, 540, ELSE);
	 Furniture mou("mouse.png",  2, 21, 32, 25, mo.rect.left, mo.rect.top, ELSE);
	 
	 
	 std::list<Furniture> fList;
	 std::list<Furniture>::iterator it;
	 fList.push_back(posters);
	 fList.push_back(toys);
	 fList.push_back(upShelf);
	 fList.push_back(cabinet);
	 fList.push_back(mop);
	 fList.push_back(ball);
	 fList.push_back(books);
	 fList.push_back(key);
	 fList.push_back(puddle);
	 fList.push_back(brokenLight);
	 fList.push_back(bath);
	 fList.push_back(sink);
//.........这里部分代码省略.........
开发者ID:DariaDar,项目名称:Reposit,代码行数:101,代码来源:functions.cpp


示例11: UniqueID

void TextureStore::TileSwapper::load(const TileKey& key, TileRecord& record)
{
    // Fetch the texture container.
    const TextureContainer& textures =
        key.m_assembly_uid == UniqueID(~0)
            ? m_scene.textures()
            : m_assemblies[key.m_assembly_uid]->textures();

    // Fetch the texture.
    Texture* texture = textures.get_by_uid(key.m_texture_uid);

    if (m_params.m_track_tile_loading)
    {
        RENDERER_LOG_DEBUG(
            "loading tile (" FMT_SIZE_T ", " FMT_SIZE_T ") "
            "from texture \"%s\"...",
            key.get_tile_x(),
            key.get_tile_y(),
            texture->get_name());
    }

    // Load the tile.
    record.m_tile = texture->load_tile(key.get_tile_x(), key.get_tile_y());
    record.m_owners = 0;

    // Convert the tile to the linear RGB color space.
    switch (texture->get_color_space())
    {
      case ColorSpaceLinearRGB:
        break;

      case ColorSpaceSRGB:
        convert_tile_srgb_to_linear_rgb(*record.m_tile);
        break;

      case ColorSpaceCIEXYZ:
        convert_tile_ciexyz_to_linear_rgb(*record.m_tile);
        break;

      assert_otherwise;
    }

    // Track the amount of memory used by the tile cache.
    m_memory_size += record.m_tile->get_memory_size();
    m_peak_memory_size = max(m_peak_memory_size, m_memory_size);

    if (m_params.m_track_store_size)
    {
        if (m_memory_size > m_params.m_memory_limit)
        {
            RENDERER_LOG_DEBUG(
                "texture store size is %s, exceeding capacity %s by %s",
                pretty_size(m_memory_size).c_str(),
                pretty_size(m_params.m_memory_limit).c_str(),
                pretty_size(m_memory_size - m_params.m_memory_limit).c_str());
        }
        else
        {
            RENDERER_LOG_DEBUG(
                "texture store size is %s, below capacity %s by %s",
                pretty_size(m_memory_size).c_str(),
                pretty_size(m_params.m_memory_limit).c_str(),
                pretty_size(m_params.m_memory_limit - m_memory_size).c_str());
        }
    }
}
开发者ID:johnhaddon,项目名称:appleseed,代码行数:66,代码来源:texturestore.cpp


示例12: MainLoop

UINT MainLoop(WindowManager *winmgr)
{
	//window setting
	Window window;
	winmgr->RegisterWindow(&window);
	ARSG g(window.hWnd, WINDOW_WIDTH, WINDOW_HEIGHT, true);
	ARSI *keyIn = window.GetInputHandler();
	ARSS s;
	Sound bgm, badend, atk;
	s.CreateSoundBuffer(&atk, L"../sound/atk.wav");
	s.CreateSoundBuffer(&bgm, L"../sound/bgm.wav");
	s.CreateSoundBuffer(&badend, L"../sound/fadein.wav");

	//Texture
	Texture board;
	Texture bg;
	Texture mask;
	Texture gameover;
	Texture clear;

	//BitPlane
	BitPlane source;
	BitPlane stored;
	BitPlane hitArea;
	BitPlane bitmask;

	//Light
	Light light;
	g.CreateLight(&light);
	light.SetLightIntensity(10);

	//Camera
	ARSD d;
	d.Init();
	d.AttachCam(0);
	d.BindBitPlane(&source);
	d.StartGraph();
	while (!source.GetPointer());
	source.GetSize(&sizex, &sizey, &depth);
	source.CopyTo(&stored);

	//background
	g.CreateTexture(&bg, L"../img/bgbg.jpg");
	bg.SetDrawMode(true);
	g.CreateTexture(&mask, L"../img/mask.jpg");
	mask.SetDrawMode(true);
	mask.GetBitData(&bitmask);
	g.CreateTexture(&board, sizex, sizey);
	board.SetDrawMode(true);
	Mesh f;
	g.CreateMesh(&f, L"../model/f4.x");
	float scale=25.0f;
	f.SetScale(scale, scale, scale, GL_ABSOLUTE);
	f.SetPosition(45.0f, -4.0f, 65.0f, GL_ABSOLUTE);
	f.SetRotationY(1.57f);
	g.CreateTexture(&gameover, L"../img/gameover.jpg");
	gameover.SetDrawMode(true);
	g.CreateTexture(&clear, L"../img/clear.PNG");
	gameover.SetDrawMode(true);

	//gun
	Gun gun(&g, &s, L"gun2.x", L"../sound/gun2.wav");
	gun.DefaultPosition(0.0f, -1.2f, -17.0f);
	gun.SetRotation(-0.1f, 3.14f, 0.0f, GL_ROTXYZ, GL_ABSOLUTE);

	//enemy
	int i, j;
	Batman bats[BAT];
	for(i=0,j=-1; i<BAT; ++i,j*=-1){
		new(bats+i)Batman(j*3.0f, 5.0f, 25.0f, j*-1*0.02f, -0.03f, -0.25f, j*-1*0.04f);
		bats[i].setting(&g, L"../model/bat.x");
	}
	Bone bons[BONE];
	for(i=0; i<BONE; ++i){
		new(bons+i)Bone(i*2, -4.8f, 20.0f, 0.0f, 0.01f, -0.25f);
		bons[i].setting(&g, L"../model/bone.x");
	}
	Boss boss(0.0f, -8.0f, 5.0f);
	boss.setSize(3.0f);
	boss.setting(&g, L"../model/teki.x");

	//add
	g.RegisterLight(&light);
	g.RegisterShape(&bg);
	g.RegisterShape(&f);
	for(i=0; i<BAT; ++i)
		g.RegisterShape(&bats[i]);
	g.RegisterShape(&board);
	g.RegisterShape(&gun);
	Effect e(&g);
	Player p(&g);

	enum {START, BAD, SCARLE, ARMER, BOSS, GAMEOVER, END};
	int state = START;
	unsigned int cnt=0;
	j=0;
	bgm.Play(true);
	while (!winmgr->WaitingForTermination()){
		if (keyIn->GetKeyTrig('A'))
			source.CopyTo(&stored);
//.........这里部分代码省略.........
开发者ID:Ladicle,项目名称:FPS,代码行数:101,代码来源:main.cpp


示例13: assert

void GameWorldPanel::render(Renderer &renderer)
{
	assert(this->getGameState()->gameDataIsActive());

	// Clear full screen.
	renderer.clearNative();
	renderer.clearOriginal();

	// Draw game world onto the native frame buffer. The game world buffer
	// might not completely fill up the native buffer (bottom corners), so 
	// clearing the native buffer beforehand is still necessary.
	renderer.renderWorld();

	// Set screen palette.
	auto &textureManager = this->getGameState()->getTextureManager();
	textureManager.setPalette(PaletteFile::fromName(PaletteName::Default));

	// Set original frame buffer blending to true.
	renderer.useTransparencyBlending(true);

	// Draw game world interface.
	const auto &gameInterface = textureManager.getTexture(
		TextureFile::fromName(TextureName::GameWorldInterface));
	renderer.drawToOriginal(gameInterface.get(), 0, 
		Renderer::ORIGINAL_HEIGHT - gameInterface.getHeight());

	// Draw player portrait.
	const auto &player = this->getGameState()->getGameData()->getPlayer();
	const auto &headsFilename = PortraitFile::getHeads(
		player.getGenderName(), player.getRaceName(), true);
	const auto &portrait = textureManager.getTextures(headsFilename)
		.at(player.getPortraitID());
	const auto &status = textureManager.getTextures(
		TextureFile::fromName(TextureName::StatusGradients)).at(0);
	renderer.drawToOriginal(status.get(), 14, 166);
	renderer.drawToOriginal(portrait.get(), 14, 166);

	// Draw compass slider (the actual headings). +X is north, +Z is east.
	// Should do some sin() and cos() functions to get the pixel offset.
	auto *compassSlider = textureManager.getSurface(
		TextureFile::fromName(TextureName::CompassSlider));

	Texture compassSliderSegment = [&renderer, &compassSlider]()
	{
		SDL_Surface *segmentTemp = Surface::createSurfaceWithFormat(32, 7,
			Renderer::DEFAULT_BPP, Renderer::DEFAULT_PIXELFORMAT);

		SDL_Rect clipRect;
		clipRect.x = 60; // Arbitrary offset until compass rotation works.
		clipRect.y = 0;
		clipRect.w = segmentTemp->w;
		clipRect.h = segmentTemp->h;

		SDL_BlitSurface(compassSlider, &clipRect, segmentTemp, nullptr);

		SDL_Texture *segment = renderer.createTextureFromSurface(segmentTemp);
		SDL_FreeSurface(segmentTemp);

		return Texture(segment);
	}();

	renderer.drawToOriginal(compassSliderSegment.get(),
		(Renderer::ORIGINAL_WIDTH / 2) - (compassSliderSegment.getWidth() / 2),
		compassSliderSegment.getHeight());

	// Draw compass frame over the headings.
	const auto &compassFrame = textureManager.getTexture(
		TextureFile::fromName(TextureName::CompassFrame));
	renderer.drawToOriginal(compassFrame.get(),
		(Renderer::ORIGINAL_WIDTH / 2) - (compassFrame.getWidth() / 2), 0);

	// If the player's class can't use magic, show the darkened spell icon.
	if (!player.getCharacterClass().canCastMagic())
	{
		const auto &nonMagicIcon = textureManager.getTexture(
			TextureFile::fromName(TextureName::NoSpell));
		renderer.drawToOriginal(nonMagicIcon.get(), 91, 177);
	}

	// Draw text: player name.
	renderer.drawToOriginal(this->playerNameTextBox->getTexture(),
		this->playerNameTextBox->getX(), this->playerNameTextBox->getY());

	// Scale the original frame buffer onto the native one.
	// This shouldn't be done for the game world interface because it needs to
	// clamp to the screen edges, not the letterbox edges. 
	// Fix this eventually... again.
	renderer.drawOriginalToNative();

	// Draw cursor, depending on its position on the screen.
	const Int2 mousePosition = this->getMousePosition();

	const Texture &cursor = [this, &mousePosition, &textureManager]()
		-> const Texture& // Interesting how this return type isn't deduced in MSVC.
	{
		// See which arrow cursor region the native mouse is in.
		for (int i = 0; i < this->nativeCursorRegions.size(); ++i)
		{
			if (this->nativeCursorRegions.at(i)->contains(mousePosition))
			{
//.........这里部分代码省略.........
开发者ID:afritz1,项目名称:OpenTESArena,代码行数:101,代码来源:GameWorldPanel.cpp


示例14: switch

void SceneManagerDungeon::SpawnEnemy(MapEventEnemy* event, Enums::EnemyTypes type, float x, float y)
{
    sf::Sprite sprite;
    Texture* tex;
    switch(type)
    {
    case Enums::EnemyDefault:
    case Enums::EnemyChest:
        tex = TextureList::getTexture(TextureList::EnemySpriteSheet);
        break;
    case Enums::EnemyBoss:
        tex = TextureList::getTexture(TextureList::BossSpriteSheet);
    }
    sprite.setTexture(*tex);
    sprite.setTextureRect(sf::IntRect(0,0,32,32));
    Node* enemy = new AnimatedNode(&sprite, tex->GetNumberAnimationSteps());
    switch(type)
    {
    case Enums::EnemyDefault:
    case Enums::EnemyChest:
        enemy->setBoundingBox(sf::FloatRect(4.0f,16.0f,20.0f,16.0f));
        break;
    case Enums::EnemyBoss:
        enemy->setBoundingBox(sf::FloatRect(0.0f,0.0f,32.0f,32.0f));
    }
    m_eventLayer->addChild(enemy);

    sf::Transform enemyTransform;
    //Place Enemy at Position
    enemyTransform.translate(x, y);
    enemy->setTransform(enemyTransform);

    std::vector<Entity*>* enemies = new std::vector<Entity*>();

    Entity* e;
    switch(type)
    {
    case Enums::EnemyDefault:
        for(int i = 0; i < m_dungeonConfig->GetNrEnemies(); i++)
        {
            e = m_dungeonConfig->GetDungeonEnemy(m_lvlId);
            e->SetTeamId(1);
            enemies->push_back(e);
        }
        break;
    case Enums::EnemyBoss:
        {
            int nrAdds = 0;
            for(; nrAdds < m_dungeonConfig->GetNrBossAdds() / 2; nrAdds++)
            {
                e = m_dungeonConfig->GetDungeonEnemy(m_lvlId);
                e->SetTeamId(1);
                enemies->push_back(e);
            }
            e = m_dungeonConfig->GetDungeonBoss(m_lvlId);
            e->SetTeamId(1);
            enemies->push_back(e);
            for(; nrAdds < m_dungeonConfig->GetNrBossAdds(); nrAdds++)
            {
                e = m_dungeonConfig->GetDungeonEnemy(m_lvlId);
                e->SetTeamId(1);
                enemies->push_back(e);
            }
        }
        break;
    case Enums::EnemyChest:
        for(int i = 0; i < m_dungeonConfig->GetNrEnemies() + 1; i++)
        {
            e = m_dungeonConfig->GetDungeonEnemy(m_lvlId + 2);
            e->SetTeamId(1);
            enemies->push_back(e);
        }
        break;
    }

    event->Init(&m_map, enemy, enemies);
}
开发者ID:Panzareon,项目名称:RoguePG,代码行数:77,代码来源:SceneManagerDungeon.cpp


示例15: create_texture_from_image

Texture create_texture_from_image(const ImagePtr& the_img, bool mipmap,
                                  bool compress, GLfloat anisotropic_filter_lvl)
{
    Texture ret;
    
    if(!the_img){ return ret; }
    GLenum format = 0, internal_format = 0;
    
    switch(the_img->bytes_per_pixel)
    {
#ifdef KINSKI_GLES
        case 1:
            internal_format = format = GL_LUMINANCE;
            break;
        case 2:
            internal_format = format = GL_LUMINANCE_ALPHA;
            break;
        case 3:
            internal_format = format = GL_RGB;
            // needs precompressed image and call to glCompressedTexImage2D
            //                internal_format = compress ? GL_ETC1_RGB8_OES : GL_RGB;
            break;
        case 4:
            internal_format = format = GL_RGBA;
        default:
            break;
#else
        case 1:
            format = GL_RED;
            internal_format = compress? GL_COMPRESSED_RED_RGTC1 : GL_RGBA;
            break;
        case 2:
            format = GL_RG;
            internal_format = compress? GL_COMPRESSED_RG_RGTC2 : GL_RGBA;
            break;
        case 3:
            format = GL_RGB;
            internal_format = compress? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_RGBA;
            break;
        case 4:
            format = GL_RGBA;
            internal_format = compress? GL_COMPRESSED_RGBA_S3TC_DXT5_EXT : GL_RGBA;
        default:
            break;
#endif
    }
    Texture::Format fmt;
    fmt.set_internal_format(internal_format);
    
    if(mipmap)
    {
        fmt.set_mipmapping();
        fmt.set_min_filter(GL_LINEAR_MIPMAP_NEAREST);
    }
    uint8_t *data = the_img->data;
    
#if !defined(KINSKI_GLES)
    gl::Buffer pixel_buf;
    pixel_buf.set_data(the_img->data, the_img->num_bytes());
    pixel_buf.bind(GL_PIXEL_UNPACK_BUFFER);
    data = nullptr;
#endif
    ret = Texture(data, format, the_img->width, the_img->height, fmt);
    ret.set_flipped();
    KINSKI_CHECK_GL_ERRORS();
    
    ret.set_anisotropic_filter(anisotropic_filter_lvl);
    return ret;
}
开发者ID:,项目名称:,代码行数:69,代码来源:


示例16: BindTexture

void DXShader::BindTexture( Texture& text ) const 
{
	// set the texture in the shader
	AdapterController::Get()->GetDeviceContext().dx->PSSetShaderResources( 0, 1, &text.GetTextureId().dx );
}
开发者ID:ColdenCullen,项目名称:Project-192,代码行数:5,代码来源:DXShader.cpp


示例17: destroyTexture

//----------------------------------------------------------------------------//
void Direct3D10Renderer::destroyTexture(Texture& texture)
{
    destroyTexture(texture.getName());
}
开发者ID:respu,项目名称:xsilium-engine,代码行数:5,代码来源:Renderer.cpp


示例18: setup_and_render

void setup_and_render()
{

	Image img(WIDTH, HEIGHT);
	img.addRef();

	//Set up the scene
	GeometryGroup scene;

	// load scene
	LWObject objects;
	objects.read("models/cube.obj", true);
	objects.addReferencesToScene(scene.primitives);	
	scene.rebuildIndex();
	
	//apply custom shaders
	BumpTexturePhongShader as;
	as.addRef();
	Image  grass;
	grass.addRef();
	grass.readPNG("models/mat.png");
	Texture textureGrass;
	textureGrass.addRef();
	textureGrass.image = &grass;
	as.diffTexture = &textureGrass;
	as.amibientTexture = &textureGrass;
	as.specularCoef = float4::rep(0);
	as.specularExponent = 10000.f;
	as.transparency = float4::rep(0.9);
	FractalLandscape f(Point(-4419,-8000,-569), Point(3581,0, -569),9, 0.1, &as, 5.0f);
	f.addReferencesToScene(scene.primitives);
	scene.rebuildIndex();
	
	// my phong
	RRPhongShader glass;
	glass.n1 = 1.0f;
	glass.n2 = 1.5f;
	glass.diffuseCoef = float4(0.1, 0.1, 0.1, 0);
	glass.ambientCoef = glass.diffuseCoef;
	glass.specularCoef = float4::rep(0.9);
	glass.specularExponent = 10000;
	glass.transparency = float4::rep(0.9);
	glass.addRef();
	Sphere sphere(Point(-78,1318,40), 25, &glass);;
	scene.primitives.push_back(&sphere);
	scene.rebuildIndex();	
	objects.materials[objects.materialMap["Glass"]].shader = &glass;

	
	//sample shader for noise
	ProceduralPhongShader skyShader;
	skyShader.addRef();
	CloudTexture nt;
	nt.addRef();
	skyShader.amibientNoiseTexture = &nt;
	skyShader.diffuseCoef = float4::rep(0.0f);
	skyShader.specularCoef = float4::rep(0.0f);

// 	float w = skyShader.amibientNoiseTexture->perlin->width;
 objects.materials[objects.materialMap["Sky"]].shader = &skyShader;

	//Set up the cameras
	PerspectiveCamera cam1(Point(-23, 1483, 30 ), forwardForCamera((0.0)*PI/180.0), Vector(0, 0, 1), 45,
		std::make_pair(img.width(), img.height()));
	
	cam1.addRef();

	//Set up the integrator
	IntegratorImpl integrator;
	integrator.addRef();
	integrator.scene = &scene;

	PointLightSource pls3;

	pls3.falloff = float4(0, 0, 1, 0);

	pls3.intensity  = float4::rep(0.9f);
	pls3.position = Point(299.5, 99, 518);
	integrator.lightSources.push_back(pls3);

// 	PointLightSource pls4;
// 
// 	pls4.falloff = float4(0, 0, 1, 0);
// 
// 	pls4.intensity  = float4::rep(0.9f);
// 	pls4.position = Point(1289.5, 99, 518);
// 	integrator.lightSources.push_back(pls4);
	
	areaLightSource(integrator, 0.9, 2, Point(-1180, -3860, -1718), 1000);
	integrator.ambientLight = float4::rep(0.1f);

	StratifiedSampler samp;
	samp.addRef();
 	samp.samplesX = 3;
	samp.samplesY = 3;

	//Render
	Renderer r;
	r.integrator = &integrator;
	r.target = &img;
//.........这里部分代码省略.........
开发者ID:dayweek,项目名称:raytracer,代码行数:101,代码来源:setup_and_render.cpp


示例19: FreeImage_GetFileType

        Texture* TextureManager::addTexture( const std::string& filename )
        {
            Texture* ret = nullptr;

            FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
            FIBITMAP* dib = nullptr; // TODO This name is nonsense, change it

            // Find format from file signature
            fif = FreeImage_GetFileType( filename.c_str(), 0 );

            if ( FIF_UNKNOWN == fif )
            {
                // Find format from file extension
                fif = FreeImage_GetFIFFromFilename( filename.c_str() );
            }

            if ( FIF_UNKNOWN == fif )
            {
                // Still unknown
                std::string error = "Cannot determine " + filename + " image format.";
                LOG( logERROR ) << error;
                CORE_ASSERT( 0, error.c_str() );

                return nullptr;
            }

            if ( FreeImage_FIFSupportsReading( fif ) )
            {
                dib = FreeImage_Load( fif, filename.c_str() );
            }

            std::string error = "Something went wrong while trying to load " + filename + ".";
            //CORE_ASSERT(dib, error.c_str());

            if ( nullptr == dib )
            {
                LOG( logERROR ) << error;
                return nullptr;
            }

            ret = new Texture( filename, GL_TEXTURE_2D );
            unsigned char* data = FreeImage_GetBits( dib );

            int bpp = FreeImage_GetBPP( dib );
            int format = ( bpp == 24 ? GL_BGR : 0 ); // TODO Handle other formats
            int internal = ( bpp == 24 ? GL_RGB : 0 ); // TODO Handle other formats
            int w = FreeImage_GetWidth( dib );
            int h = FreeImage_GetHeight( dib );

            // FIXME(Charly): Use VLOG instead of the check
            if ( m_verbose )
            {
                LOG( logINFO ) << "Image stats (" << filename << ") :\n"
                               << "\tBPP    : 0x" << std::hex << bpp << std::dec << std::endl
                               << "\tFormat : 0x" << std::hex << format << std::dec << std::endl
                               << "\tSize   : " << w << ", " << h;
            }


            CORE_ASSERT( data, "Data is null" );

            ret->initGL( internal, w, h, format, GL_UNSIGNED_BYTE, data );
            ret->genMipmap( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR );

            m_textures.insert( TexturePair( filename, ret ) );

            FreeImage_Unload( dib );

            return ret;
        }
开发者ID:,项目名称:,代码行数:70,代码来源:


示例20: glyph_origin

// Generates the character and texture data for the layer.
bool FontFaceLayer::Initialise(const FontFaceHandle* _handle, FontEffect* _effect, const FontFaceLayer* clone, bool deep_clone)
{
	handle = _handle;
	effect = _effect;
	if (effect != NULL)
	{
		effect->AddReference();
		colour = effect->GetColour();
	}

	const FontGlyphList& glyphs = handle->GetGlyphs();

	// Clone the geometry and textures from the clone layer.
	if (clone != NULL)
	{
		// Copy the cloned layer's characters.
		characters = clone->characters;

		// Copy (and reference) the cloned layer's textures.
		for (size_t i = 0; i < clone->textures.size(); ++i)
			textures.push_back(clone->textures[i]);

		// Request the effect (if we have one) adjust the origins as appropriate.
		if (!deep_clone &&
			effect != NULL)
		{
			for (FontGlyphList::const_iterator i = glyphs.begin(); i != glyphs.end(); ++i)
			{
				const FontGlyph& glyph = *i;

				if (glyph.character >= characters.size())
					continue;

				Character& character = characters[glyph.character];

				Vector2i glyph_origin(Math::RealToInteger(character.origin.x), Math::RealToInteger(character.origin.y));
				Vector2i glyph_dimensions(Math::RealToInteger(character.dimensions.x), Math::RealToInteger(character.dimensions.y));

				if (effect->GetGlyphMetrics(glyph_origin, glyph_dimensions, glyph))
				{
					character.origin.x = (float) glyph_origin.x;
					character.origin.y = (float) glyph_origin.y;
				}
				else
					character.texture_index = -1;
			}
		}
	}
	else
	{
		// Initialise the texture layout for the glyphs.
		characters.resiz 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Texture2D类代码示例发布时间:2022-05-31
下一篇:
C++ TextWriter类代码示例发布时间: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