0

Welcome. I have the following problem. I have a function written in C++, and it returns an array of RGB pixels representing a single image. Each subsequent call to this function returns a new array representing the next frame of an animation. I want to display this animation frame by frame in a window, and I want this to be as fast as possible.

I have used GDI+ but have not been able to get satisfactory efficiency. I have therefore become interested in the DirectX and Vulkan libraries. Unfortunately for me, but at first glance, these libraries seem downright overwhelming to learn. Moreover, the tutorials I found focus on 3d graphics, which I don't need because, as I wrote earlier, I only want to display a series of RGB pixel arrays.

And this is where my question comes in.

Is there a boilerplate project on Github or anywhere else that I could use? If not, does anyone here know of a tutorial that, without going into learning 3D graphics, would help me to learn DirectX or Vulkan enough so that I could write the code I need myself? Thank you in advance for your reply.

mrmajacuze
  • 65
  • 4
  • 1
    "*have not been able to get satisfactory efficiency*" What does that mean? What is "satisfactory efficiency" to you? How much data are we talking about? Does it *have* to be in RGB format, or can it be in RGBA? – Nicol Bolas Dec 12 '22 at 02:23
  • It could be either an array of RGB or RGBA arrays. It doesn;t really matter. When it comes to performance, simply the faster the better. The more efficiency I can achieve, the larger images I would like to generate. The sky is the limit. – mrmajacuze Dec 12 '22 at 02:44
  • "*It doesn;t really matter.*" Yes, it does. A lot of hardware cannot natively handle RGB data, so they have to manually insert padding between every RGB triple. – Nicol Bolas Dec 12 '22 at 04:58
  • At the moment it's RGB, but what I meant was: it doesn't matter to me. The issue of converting the function's output from RGB to RGBA or vice versa just seems to me at the moment to be incomparably simpler than the problem of creating a function displaying this output in a window. – mrmajacuze Dec 12 '22 at 05:22
  • 1
    We have no idea of what you're actually doing from your question. Maybe you don't need DirectX, maybe you do, please provide a minimal reproducible sample (eg: code that compiles) https://stackoverflow.com/help/minimal-reproducible-example – Simon Mourier Dec 12 '22 at 07:59
  • With DirectX 11 you'll need to create a "mappable" RGBA texture and you should feed the RGBA data to it on each frame using Map/Unmap or UpdateSubResource. Check this: https://stackoverflow.com/a/27666262/2440728. This texture could be easily rendered on a fullscreen quad after each update. – VuVirt Dec 13 '22 at 18:34
  • The *DirectX Tool Kit* on [GitHub](https://github.com/microsoft/DirectXTK)'s ``SpriteBatch`` is a good place to start for 2D textured drawing. – Chuck Walbourn Dec 13 '22 at 19:53

0 Answers0