Re: How to change Image source at runtime?
I would also like to chime in that this is very high priority for me. My game is centered entirely around user generated content and part of that is user-made images that I render in various parts of the UI. It is a requirement of my game that the user can just drop a loose image in a folder and I will find it and display it (I can't have this go through the build tool).
I am using Ogre and before I was handling this by loading the image into memory and generating an Ogre::Texture from it. My previous UI system had support for rendering Ogre::Textures.
I am using Ogre and before I was handling this by loading the image into memory and generating an Ogre::Texture from it. My previous UI system had support for rendering Ogre::Textures.
Re: How to change Image source at runtime?
We have a ticket to implement this in Unity but in C++ it can already be done. Although I would like to test it before if you can try these are the steps:
1. Create a texture using the rendersystem
2. Create an UI Image and set its source from the created texture using a TextureSource
1. Create a texture using the rendersystem
Code: Select all
Ptr<ImageSet> imageSet = *new ImageSet(ImageSetLayout_2D, 1);
imageSet->SetImage(image.GetPtr());
texture = NsGetSystem<IRenderSystem>()->CreateTexture2D(imageSet.GetPtr());
Code: Select all
Ptr<Image> image = *new Image();
Ptr<ImageSource> source = *new TextureSource(texture, w, h);
image->SetSource(source);
Re: How to change Image source at runtime?
It looks like IDX9RenderSystem does not have a CreateTexture2D method so I am not sure how to get an appropriate Texture2D object for this system (i.e. one that isn't the pure virtual ITexture2D). I am actually not even sure what the class of the render system is since that interface is pure virtual and I don't see anything which implements it.
I cannot use ITexture2D because I need smart pointers to these objects as function parameters and member variables and there is an inlined file ptr.inl which attempts to call functions on its templated base type, which if is ITexture2D will not compile.
I cannot use ITexture2D because I need smart pointers to these objects as function parameters and member variables and there is an inlined file ptr.inl which attempts to call functions on its templated base type, which if is ITexture2D will not compile.
Re: How to change Image source at runtime?
An example, creating a texture filled in red
Instead of filling in red like the example, you will have to set properly the content using the interface provided by the image class.
Code: Select all
#include <NsRender/IRenderSystem.h>
#include <NsDrawing/Image.h>
#include <NsDrawing/ImageSet.h>
#include <NsDrawing/Color.h>
using namespace Noesis;
using namespace Noesis::Core;
using namespace Noesis::Drawing;
using namespace Noesis::Render;
Ptr<ITexture2D> CreateTexture()
{
Ptr<Image> image = *new Image(ImageFormat_A8R8G8B8, 32, 32);
image->Fill(Color::Red);
Ptr<ImageSet> mipMaps = GenerateMipmapChain(image.GetPtr());
return NsGetSystem<IRenderSystem>()->CreateTexture2D(mipMaps.GetPtr());
}
Re: How to change Image source at runtime?
My issue is with being able to pass around Ptr<ITexture2D> objects. The code you provided compiles when I try to use that logic in a member function it will not. Here is an example:
Test.h
Test.cpp
The errors are:
ptr.inl, line121, use of undefined type 'Noesis::Render::ITexture2D'
ptr.inl, line121, left of '->Release' must point to class/struct/union/generic type
Test.h
Code: Select all
#pragma once
#include <NsRender/IRenderSystem.h>
class Test
{
public:
static Noesis::Core::Ptr<Noesis::Render::ITexture2D> createTexture();
};
Code: Select all
#include "stdafx.h"
#include "Test.h"
#include <NsCore/NsSystem.h>
#include <NsDrawing/Image.h>
#include <NsDrawing/ImageSet.h>
#include <NsDrawing/Color.h>
using namespace Noesis;
using namespace Noesis::Core;
using namespace Noesis::Drawing;
using namespace Noesis::Render;
Ptr<ITexture2D> Test::createTexture()
{
Ptr<Image> image = *new Image(ImageFormat_A8R8G8B8, 32, 32);
image->Fill(Color::Red);
Ptr<ImageSet> mipMaps = GenerateMipmapChain(image.GetPtr());
return NsGetSystem<IRenderSystem>()->CreateTexture2D(mipMaps.GetPtr());
}
ptr.inl, line121, use of undefined type 'Noesis::Render::ITexture2D'
ptr.inl, line121, left of '->Release' must point to class/struct/union/generic type
Re: How to change Image source at runtime?
at least the following headers are missing in my sample:ptr.inl, line121, use of undefined type 'Noesis::Render::ITexture2D'
ptr.inl, line121, left of '->Release' must point to class/struct/union/generic type
Code: Select all
#include <NsCore/Ptr.h>
#include <NsRender/ITexture2D.h>
Re: How to change Image source at runtime?

Whoops! Thanks for pointing that out. Sorry for the delayed response but everything is working now.

Re: How to change Image source at runtime?
I am also interested in uploading images at runtime to replace UI brushes!
If I am following this conversation correctly..
for my example, imagine a save game menu that takes a screenshot at your location and then the screenshot is used as the brush/background in a list of buttons in the load/save game menu. I would want to update the UI thumbnails on the fly
I also want the image of each button to animate with it's parent/the rest of the UI when I activate/deactivate the container menu.
for my application I am looking at using ogre + noesis gui + GL - will noesis work with GL texture resources (allowing me to control the content)? If not do you have any suggestions on how to approach this?
Best,
Marc
If I am following this conversation correctly..
for my example, imagine a save game menu that takes a screenshot at your location and then the screenshot is used as the brush/background in a list of buttons in the load/save game menu. I would want to update the UI thumbnails on the fly
I also want the image of each button to animate with it's parent/the rest of the UI when I activate/deactivate the container menu.
for my application I am looking at using ogre + noesis gui + GL - will noesis work with GL texture resources (allowing me to control the content)? If not do you have any suggestions on how to approach this?
Best,
Marc
Re: How to change Image source at runtime?
after re reading the previous posts, I think I have my answer 

Re: How to change Image source at runtime?
Hi eniac, welcome.
For now, the texture that must be passed to the GUI must be created by filling a Image class (as the code shown above). But we are going to add (because Unity needs it) the possibility to use your own created DX and GL textures.
For now, the texture that must be passed to the GUI must be created by filling a Image class (as the code shown above). But we are going to add (because Unity needs it) the possibility to use your own created DX and GL textures.
Who is online
Users browsing this forum: Google [Bot] and 4 guests