DigitalKarnage
Topic Author
Posts: 22
Joined: 09 Dec 2013, 18:45

Setting ImageSource to Runtime generated RGBA Information

26 Jul 2018, 20:20

I'm currently trying to render images which are generated at runtime. I have tried drawing this image over the Noesis application window, this fails cause i'm unable to restore the state of the OpenGL context to a state in which it works previous to instantiation of the GLRenderDevice provided by the Application Framework. So instead (for integration purposes) like to just set the source information based on the pixel data I have obtained from the generator.

Is there anyway to do this. I'm not looking for restoring states, i'm looking for being able to set the pixel information for ImageSource

Tags:
 
User avatar
jsantos
Site Admin
Posts: 2563
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++] Setting ImageSource to Runtime generated RGBA Information

26 Jul 2018, 23:15

The most efficient way to do this is creating a Texture with that RGBA pixel information and then passing that texture to a TextureSource.
 
DigitalKarnage
Topic Author
Posts: 22
Joined: 09 Dec 2013, 18:45

Re: [C++] Setting ImageSource to Runtime generated RGBA Information

27 Jul 2018, 01:25

Awesome works well.
GLuint TextureID = 0;

glGenTextures(1, &TextureID);
glBindTexture(GL_TEXTURE_2D, TextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);

Ptr<GLRenderDevice> GraphicsDevice = MakePtr<GLRenderDevice>();
Image* ImageElement= _WindowView->GetContent()->FindName<Image>("Image_src"); // _WindowContent is the IView* Xaml object associated with the drawing 

const auto& Height = ImageElement->GetRenderSize().height;
const auto& Width = ImageElement->GetRenderSize().width;

Ptr<Texture> NsTexture = GraphicsDevice->WrapTexture(TextureID, Width, Height , 0, TextureFormat::BGRA8, false);
Ptr<TextureSource> NsTextureSource = MakePtr<TextureSource>(NsTexture);
ImageElement->SetSource(NsTextureSource);

 
User avatar
jsantos
Site Admin
Posts: 2563
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++] Setting ImageSource to Runtime generated RGBA Information

27 Jul 2018, 13:28

Thanks for the feedback!
 
ducdanganhit
Posts: 25
Joined: 18 May 2019, 10:46

Re: [C++] Setting ImageSource to Runtime generated RGBA Information

02 Jul 2019, 11:41

Awesome works well.
GLuint TextureID = 0;

glGenTextures(1, &TextureID);
glBindTexture(GL_TEXTURE_2D, TextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);

Ptr<GLRenderDevice> GraphicsDevice = MakePtr<GLRenderDevice>();
Image* ImageElement= _WindowView->GetContent()->FindName<Image>("Image_src"); // _WindowContent is the IView* Xaml object associated with the drawing 

const auto& Height = ImageElement->GetRenderSize().height;
const auto& Width = ImageElement->GetRenderSize().width;

Ptr<Texture> NsTexture = GraphicsDevice->WrapTexture(TextureID, Width, Height , 0, TextureFormat::BGRA8, false);
Ptr<TextureSource> NsTextureSource = MakePtr<TextureSource>(NsTexture);
ImageElement->SetSource(NsTextureSource);

Hello,
Where is the image source to show?
If I want to read an image from local, how to set it to be rendered?
Thanks in advanced!

Who is online

Users browsing this forum: No registered users and 6 guests