Hey, so i’ve been thinking about it for a while. How can i draw pixels to the screen for example with my mouse. I know i can use SetPixel() but its waaay to expensive… Shaders? Is it possible to draw pixels with shaders? Im familiar with them but i cant possibly think of a way to draw pixels using them. Any ideas? Any help is reeally appreciated!
One way I used before was to have the camera render a render texture - when you click the mouse you can then just draw to that render texture using openGL commands. For example, here’s how I render some debug points:
This needs to be called in the OnPostRender function of the camera you’re using. You don’t actually need to use a render texture either - that would just be more helpful if you didn’t want to redraw all the points each time.
Lets say for example i have a scene with 100x80 pixels on a single texture. If i were to draw pixels to it every single frame we are talking about a lot of drawcalls. What if i want to constantly draw 7 lines using Bresenham’s algorithm? Its expensive. Fps wise its not really what im looking for:smile:
No. Doing pretty much anything once per second is downright leisurely in game development world. Honestly both me and BoredMormon (I assume) have been answering on the assumption that whatever you’re doing, you would’ve been doing every frame.
I’ve got RTS style games that use SetPixels to do a map overlay every frame. Sure there is a limit, but a few textures every frame won’t kill performance.