Esempio n. 1
0
//----------------------------------------------------------------------------//
void Direct3D9Texture::loadFromMemory(const void* buffer,
                                      const Sizef& buffer_size,
                                      PixelFormat pixel_format)
{
    if (!isPixelFormatSupported(pixel_format))
        CEGUI_THROW(InvalidRequestException(
            "Data was supplied in an unsupported pixel format."));

    const D3DFORMAT pixfmt = toD3DPixelFormat(pixel_format);
    createDirect3D9Texture(buffer_size, pixfmt);

    LPDIRECT3DSURFACE9 surface = getTextureSurface();
    const PixelBuffer pixel_buffer(buffer, buffer_size, pixel_format);

    const RECT src_rect = { 0, 0,
        static_cast<LONG>(buffer_size.d_width),
        static_cast<LONG>(buffer_size.d_height) };

    HRESULT hr = D3DXLoadSurfaceFromMemory(
            surface, 0, 0, pixel_buffer.getPixelDataPtr(),
            pixfmt == D3DFMT_X8R8G8B8 ? D3DFMT_R8G8B8 : pixfmt,
            pixel_buffer.getPitch(), 0, &src_rect, D3DX_FILTER_NONE, 0);

    surface->Release();

    if (FAILED(hr))
        CEGUI_THROW(RendererException(
            "D3DXLoadSurfaceFromMemory failed."));
}
Esempio n. 2
0
UITexture::UITexture(FilePath *texturePath, Vector2 position)
{
	this->texturePath = texturePath;
	this->position = position;

	SDL_Surface *surface = getTextureSurface(texturePath);

	element.position = position;
	element.surface = surface;

	UIElementsHandler::addUIElement(element);
}