How to set an image using LPDIRECT3DBASETEXTURE9

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

tedlin01
Just popping in
Just popping in
Posts: 12
Joined: Wed Apr 29, 2009 19:22

How to set an image using LPDIRECT3DBASETEXTURE9

Postby tedlin01 » Wed Dec 08, 2010 15:50

Hello!

I have an Window with an image, loaded from an layout. Now I would like to change the image on using a LPDIRECT3DBASETEXTURE9 that I created on the fly using a RenderSurface ingame. How do I set set the image to the CEGUI::Window?

Also I have another question. Feels stupid to ask about it but I honestly can't find anything about it. How do i Simply load an image from the hardrive, I mean, without using layouts, schemes or whatever. I was looking for something like "LoadImage("image.png");

Kind Regards! :)


EDIT: SOLVED:

This is my code atm:

LPDIRECT3DBASETEXTURE9 xD3DTexture = TVManager::getSingletonPtr()->m_pCTVInternalObjects->GetTexture(iTextureID);

CEGUI::Direct3D9Renderer * pD3DRender = &CEGUI::Direct3D9Renderer::create(TVManager::getSingletonPtr()->m_pCTVInternalObjects->GetDevice3D());

CEGUI::Texture * pGUITexture = &pD3DRender->createTexture((LPDIRECT3DTEXTURE9)xD3DTexture);

CEGUI::Imageset* tempImageset = &m_pGui->GetImagesetManager()->create( "previewImage", *pGUITexture );
tempImageset->defineImage("previewImage", CEGUI::Point(0.0f,0.0f), CEGUI::Size( 512.0, 512.0 ), CEGUI::Point(0.0f,0.0f));

std::string tmpString = "set: previewImage" + std::string(" image:") + "previewImage";
m_pPreviewWnd->setProperty("Image", tmpString.c_str());

It turns up black though
Last edited by tedlin01 on Wed Dec 08, 2010 16:51, edited 1 time in total.

User avatar
Mikademus
CEGUI MVP
CEGUI MVP
Posts: 130
Joined: Wed Mar 18, 2009 19:14

Re: How to set an image using LPDIRECT3DBASETEXTURE9

Postby Mikademus » Wed Dec 08, 2010 16:50

About loading images, I think CrEGUI images might abstracted to imagesets. Check this recent thread for a similar question and a possible solution, and some bonus forum drama:

viewtopic.php?f=10&t=5304

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: How to set an image using LPDIRECT3DBASETEXTURE9

Postby Jamarr » Wed Dec 08, 2010 20:02

tedlin01 wrote:EDIT: SOLVED:...It turns up black though


So is it solved, or not solved? If not, can you post your CEGUI.log as mentioned in the Forum Guidelines; this way we know what version/environment you are using (so we can in/exclude known bugs, etc.). Also, please use the [ code] [/code] tags so that code/logs/etc. sections of your post are easier to distinguish/read. As far as why your texture is all black, the only code you've shown is that of creating and assigning a blank texture - since you've not populated the texture with any color data, that is probably why it is black.

Mikademus wrote:and some bonus forum drama:

:lol:
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: How to set an image using LPDIRECT3DBASETEXTURE9

Postby Kulik » Thu Dec 09, 2010 13:32

CEGUI assumes the texture is RGB or RGBA and you have to tell CEGUI which one it is. Make sure you select the right pixel format! If you fed the texture with something else you have to convert. There is a patch adding support for more pixel formats but AFAIK it hasn't been committed yet.

Mikademus wrote: and some bonus forum drama


Seriously, who needs a theater when you can have CEGUI forums!! :lol:


Return to “Help”

Who is online

Users browsing this forum: No registered users and 13 guests