Drawing and Rendering with DirectX11
Drawing and Rendering with DirectX11
So recently i started doing some DX11 stuff and i don't know if i have chosen the right path for drawing and rendering bitmaps. I am using the DirectX Toolkit (SpriteBatch and SpriteFont) for drawing sprites and fonts on to the buffer. Its real easy and doesn't require me to draw sprites with quads and vertices.The problem is that i want to have the option to manipulate individual pixels using for example PutPixel() and not just importing bmps and drawing them.
So my question is: How can i achieve this (it doesn't have to be using the toolkit )?
Thanks
So my question is: How can i achieve this (it doesn't have to be using the toolkit )?
Thanks
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Drawing and Rendering with DirectX11
Are you wanting to draw on a specific surfaces texture or maybe an overlay (i.e. health bar )?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Drawing and Rendering with DirectX11
Yeah i want to draw with a specific surface texture.I want to have a system buffer array like in chilis videos that i can just then draw using SpriteBatch.
I've been searching for examples of this and have only managed to find this:
In this code he has an array of Color objects that he sets to a texture and then draws that texture using spritebatch.I'm thinking of making an array of color the size of the screen(800x600) then setting it to the texture(also the size of the screen) and then drawing that texture using spritebatch.
Is this good or is there a better solution?
I've been searching for examples of this and have only managed to find this:
Code: Select all
Texture2D rect = new Texture2D(graphics.GraphicsDevice, 80, 30);
Color[] data = new Color[80*30];
for(int i=0; i < data.Length; ++i) data[i] = Color.Chocolate;
rect.SetData(data);
Vector2 coor = new Vector2(10, 20);
spriteBatch.Draw(rect, coor, Color.White);
Is this good or is there a better solution?
Re: Drawing and Rendering with DirectX11
You have to think about why you need putpixel functionality in the first place. If you're using a system buffer for your drawing, then you won't get any improvement over what is in the tutorials. Just because you write it in DX11 doesn't mean it will be any faster.
To realize the potential of HW acceleration, you need to have the CPU involved as little as possible in the rendering process.
To realize the potential of HW acceleration, you need to have the CPU involved as little as possible in the rendering process.
Chili
Re: Drawing and Rendering with DirectX11
So is it worth rendering a 2d game in DX11? Right now i'm trying to port the platformer to DX11 but if the performance isn't going to improve i don't see the point. I like the performance of the platformer but for future projects should i learn how to do rendering with quads in DX11 or just stick with DX9?
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Drawing and Rendering with DirectX11
Use the textured quads method, will be much faster, as long as you use the vertex and pixel shaders that is.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Drawing and Rendering with DirectX11
Using sprite batch is rendering with textured quads. It's only when you try to access the framebuffer from the CPU each frame that your performance will be killed.
Why do you even want to manipulate individual pixels?
Why do you even want to manipulate individual pixels?
Chili
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Drawing and Rendering with DirectX11
I think what you would want to do to make a 2D accelerated version of the Platformer is load all the textures for the dude to a layered texture, mipmap I believe, and as for the level graphics (walls and floors ) they could be textured quads or cubes that are proceedurally placed just as the 2D tiles were and d3d would take care of the cam/viewport/clipping you would just keep the code for controlling the dude, collision and updating the camera position to the CPU. At least I think how all that would work.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Drawing and Rendering with DirectX11
I'd like to be able to use PutPixel and sprite->Draw together, like in the Advanced Framework with the teapot, but it seems spotty. Sometimes I only get a display of the BeginScene/EndScene stuff OR the buffer/memcpy stuff. I've tried using LockedRect to draw PutPixel-style to a surface and then drawing it with sprite->Draw, but no joy. I must be missing something? It'd sure be nice to find a Chili-style explanation of all that. < hint, hint >
To strive, to seek, to find, and not to yield.
-
- Posts: 97
- Joined: June 9th, 2014, 11:14 pm
Re: Drawing and Rendering with DirectX11
I'm on something simular to this.jkhippie wrote:I'd like to be able to use PutPixel and sprite->Draw together, like in the Advanced Framework with the teapot, but it seems spotty. Sometimes I only get a display of the BeginScene/EndScene stuff OR the buffer/memcpy stuff. I've tried using LockedRect to draw PutPixel-style to a surface and then drawing it with sprite->Draw, but no joy. I must be missing something? It'd sure be nice to find a Chili-style explanation of all that. < hint, hint >
Though I've got a different framework I'm working on, in the Engine::Run() function is a loop that uses BeginScene(), EndScene(), Present()... I've tried adding BeginFrame(); EndFrame(); code into that. Works thus far for drawline, putpixel, etc. right? (It does).
HOWEVER, when I run the FONT code I'm using(which is stripped-down version of the DirectX9 SDK example...it does not require a "font image" file to load from, just puts text on the screen) This font code *also* accesses the backbuffer in a manner that Putpixel does...this does not allow me to have BOTH a text-based font, AND the putpixel drawn stuff at the same time (which is lame, because I need both)
Any ideas? (I could post code, but I'd have to give you the whole project file--which I can't do just yet)
Choose not to go to destruction with a taco-sauce that is bland...
Go to construction with a taco-sauce that is flavorful!!
Mwa ha ha!!
Go to construction with a taco-sauce that is flavorful!!
Mwa ha ha!!