Reputation: 32173
I plan on doing some experimentation with my math skills in a program I plan on making. I plan on doing some rendering with it but half of the fun will be the math behind recreated all of those 3D things myself. I know that the .net graphics library is SLOW and definitely not worth the time and effort. I use XNA all the time but I'd rather not use something that just hands me all of the tools.
What is a way to draw to my form (or directly to the screen if necessary) in VB.net pixel by pixel? I want to slowly - from the ground up - create my own simple rendering system.
Thanks if you can help! I'm using VB.net but all .net answers apply so I'll accept it all :)
Upvotes: 1
Views: 196
Reputation: 24759
You could create an instance of System.Drawing.Bitmap
and use GetPixel(x, y)
and SetPixel(x, y, color)
to respectively get/set individual pixels.
If you want some of the basic things done for you (drawing lines, braziers, polygons and such) then you can create a System.Drawing.Graphics
from this Bitmap.
Getting/Setting pixels will be incredibly slow, but I understand that this is a learning experience, not a product, and this is not really an issue. Using Graphics
will be quite a bit faster if you don't want to deal with line rasterizations or anything like that, but it seems like those are exactly the problems you want to tackle. If you really want faster, and still low level, graphics, then you can use bitmap.LockBits(...)
and interact with the bitmap directly in memory.
To put it on your form, just pass it to a PictureBox
.
Upvotes: 3