コード例 #1
0
ファイル: DirectX9.cpp プロジェクト: garrynewman/GWEN
		void DirectX9::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
			IDirect3DTexture9* pImage = ( IDirect3DTexture9* ) pTexture->data;

			// Missing image, not loaded properly?
			if ( !pImage )
			{
				return DrawMissingImage( rect );
			}

			Translate( rect );

			if ( m_pCurrentTexture != pImage )
			{
				Flush();
				m_pDevice->SetTexture( 0, pImage );
				m_pCurrentTexture = pImage;
			}

			AddVert( rect.x, rect.y,			u1, v1 );
			AddVert( rect.x + rect.w, rect.y,		u2, v1 );
			AddVert( rect.x, rect.y + rect.h,	u1, v2 );
			AddVert( rect.x + rect.w, rect.y,		u2, v1 );
			AddVert( rect.x + rect.w, rect.y + rect.h, u2, v2 );
			AddVert( rect.x, rect.y + rect.h, u1, v2 );
		}
コード例 #2
0
ファイル: ClanLib.cpp プロジェクト: Kezeali/Fusion
		void ClanLib::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
			TextureData* data = static_cast<TextureData*>( pTexture->data );

			if ( !data )
			{ return DrawMissingImage( rect ); }

			const clan::Image* tex = data->image;

			if ( !tex )
			{ return DrawMissingImage( rect ); }

			Translate( rect );
			
			tex->draw(m_Target, clan::Rectf(u1, v1, u2, v2), clan::Rect(rect.x, rect.y, rect.w, rect.h));
		}
コード例 #3
0
		void OpenGL_DebugFont::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
			GLuint* tex = (GLuint*)pTexture->data;

			// Missing image, not loaded properly?
			if ( !tex )
			{
				return DrawMissingImage( rect );
			}

			Translate( rect );
			GLuint boundtex;

			GLboolean texturesOn;
			glGetBooleanv(GL_TEXTURE_2D, &texturesOn);
			glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&boundtex);
			if ( !texturesOn || *tex != boundtex )
			{
				Flush();
				glBindTexture( GL_TEXTURE_2D, *tex );
				glEnable(GL_TEXTURE_2D);
			}		

			AddVert( rect.x, rect.y,			u1, v1 );
			AddVert( rect.x+rect.w, rect.y,		u2, v1 );
			AddVert( rect.x, rect.y + rect.h,	u1, v2 );

			AddVert( rect.x+rect.w, rect.y,		u2, v1 );
			AddVert( rect.x+rect.w, rect.y+rect.h, u2, v2 );
			AddVert( rect.x, rect.y + rect.h, u1, v2 );			
		}
コード例 #4
0
ファイル: SFML.cpp プロジェクト: dabroz/gwen-mirror
		void SFML::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
#if SFML_VERSION_MAJOR == 2
			const sf::Texture* tex = static_cast<sf::Texture*>( pTexture->data );
#else 
			const sf::Image* tex = static_cast<sf::Image*>( pTexture->data );
#endif 

			if ( !tex ) 
				return DrawMissingImage( rect );

			Translate( rect );
		
			tex->Bind();

			glColor4f(1, 1, 1, 1 );

			glBegin( GL_QUADS );
				glTexCoord2f( u1, v1 );		glVertex2f(rect.x,     rect.y);
				glTexCoord2f( u1, v2 );		glVertex2f(rect.x,     rect.y + rect.h);
				glTexCoord2f( u2, v2 );		glVertex2f(rect.x + rect.w, rect.y + rect.h);
				glTexCoord2f( u2, v1 );		glVertex2f(rect.x + rect.w, rect.y) ;
			glEnd();

			glBindTexture( GL_TEXTURE_2D, 0);
		}
コード例 #5
0
ファイル: GDIPlus.cpp プロジェクト: charliesome/battlecars
		void GDIPlus::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect pTargetRect, float u1, float v1, float u2, float v2 )
		{
			Gdiplus::Bitmap* pImage = (Gdiplus::Bitmap*) pTexture->data;

			// Missing image, not loaded properly?
			if ( !pImage || pImage->GetType() == Gdiplus::ImageTypeUnknown ) 
				return DrawMissingImage( pTargetRect );

			Translate( pTargetRect );

			Gdiplus::RectF TargetRect( pTargetRect.x, pTargetRect.y, pTargetRect.w, pTargetRect.h );

			// Convert UV to pixel coords
			float fW = pImage->GetWidth();
			float fH = pImage->GetHeight();

			u1 *= fW;
			v1 *= fH;

			u2 *= fW;
			u2 -= u1;

			v2 *= fH;
			v2 -= v1;

			graphics->DrawImage( pImage, TargetRect, u1, v1, u2, v2, Gdiplus::UnitPixel );
			
		}
コード例 #6
0
		void Chowdren::DrawTexturedRect( Gwen::Texture* pTexture,
            Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
            Translate(rect);

            if (pTexture->data) {
                ::Texture tex = ((FileImage*)pTexture->data)->tex;
                if (tex) {
                    Render::draw_tex(rect.x, rect.y, rect.x + rect.w,
                        rect.y + rect.h, m_Color, tex, u1, v1, u2, v2);
                    return;
                }
            }

            DrawMissingImage(rect);
		}
コード例 #7
0
ファイル: SDL2Renderer.cpp プロジェクト: Catchouli-old/ca2d
        void SDL2Renderer::DrawTexturedRect(Gwen::Texture* pTexture, Gwen::Rect rect,
                                    float u1, float v1, float u2, float v2)
        {
            SDL_Texture *tex = static_cast<SDL_Texture*>(pTexture->data);

            if (!tex)
                return DrawMissingImage(rect);

            Translate(rect);
            
            const unsigned int w = pTexture->width;
            const unsigned int h = pTexture->height;
            
            const SDL_Rect source = { int(u1*w), int(v1*h), int((u2-u1)*w), int((v2-v1)*h) },
                             dest = { rect.x, rect.y, rect.w, rect.h };

            SDL_RenderCopy(m_renderer, tex, &source, &dest);
        }
コード例 #8
0
ファイル: SFML.cpp プロジェクト: 32bitmicro/GWEN
		void SFML::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
		{
#if SFML_VERSION_MAJOR == 2
			const sf::Texture* tex = static_cast<sf::Texture*>( pTexture->data );
#else 
			const sf::Image* tex = static_cast<sf::Image*>( pTexture->data );
#endif 

			if ( !tex ) 
				return DrawMissingImage( rect );

			Translate( rect );
		
#if SFML_VERSION_MAJOR == 2
			u1 *= tex->GetWidth();
			v1 *= tex->GetHeight();

			u2 *= tex->GetWidth();
			u2 -= u1;

			v2 *= tex->GetHeight();
			v2 -= v1;

			sf::RectangleShape rectShape( sf::Vector2f( rect.w, rect.h ) );
			rectShape.SetPosition( rect.x, rect.y );
			rectShape.SetTexture( tex );
			rectShape.SetTextureRect( sf::IntRect( u1, v1, u2, v2 ) );
			
			m_Target.Draw( rectShape );
#else
			tex->Bind();

			glColor4f(1, 1, 1, 1 );

			glBegin( GL_QUADS );
				glTexCoord2f( u1, v1 );		glVertex2f(rect.x,     rect.y);
				glTexCoord2f( u1, v2 );		glVertex2f(rect.x,     rect.y + rect.h);
				glTexCoord2f( u2, v2 );		glVertex2f(rect.x + rect.w, rect.y + rect.h);
				glTexCoord2f( u2, v1 );		glVertex2f(rect.x + rect.w, rect.y) ;
			glEnd();

			glBindTexture( GL_TEXTURE_2D, 0);
#endif
		}
コード例 #9
0
ファイル: SFML2.cpp プロジェクト: jjiezheng/lfant
void Gwen::Renderer::SFML2::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2 )
{
	TextureData* data = reinterpret_cast<TextureData*>( pTexture->data );

	// Missing image, not loaded properly?
	if ( !data )
		return DrawMissingImage( rect );

	const sf::Texture* tex = data->texture;

	EnsurePrimitiveType( sf::Triangles );
	EnsureTexture( tex );

	Translate( rect );

	AddVert( rect.x, rect.y, u1, v1 );
	AddVert( rect.x+rect.w, rect.y,	u2, v1 );
	AddVert( rect.x, rect.y + rect.h,	u1, v2 );

	AddVert( rect.x+rect.w, rect.y, u2, v1 );
	AddVert( rect.x+rect.w, rect.y+rect.h, u2, v2 );
	AddVert( rect.x, rect.y + rect.h, u1, v2 );
}