Game Development Community

Can I draw pixels direct to bitmap/screen?

by Lawrence Chrysler · in Torque Game Builder · 07/29/2008 (5:48 am) · 3 replies

I'd like to use TGB to make a Qix remake. The game will require a floodfill. I can't seem to locate
a way to draw pixels, which of course is key to the floodfill. I would prefer to render to an offscreen
bitmap first, then blast to the screen rather than straight to the screen. This all trivial in other graphics
libs that I've worked with in C++ - like DarkGDK and SDL. You just get a pointer to the buffer, lock the
memory and blast away at the pointer.
I'd love to know if I can do that with TGB, any ideas anyone?


Thanks in advance,
Lawrence

#1
07/29/2008 (12:22 pm)
Interesting, I was just brainstorming how to make Qix in TGB. But... there is no low level rendering exposed to script in TGB and there is no per pixel collision in TGB...

Everything you need to render is either a line or a rectangle, so perhaps representing those as a solid color static sprite stretched to the shape you require would work. Traveling along those lines represented by static sprites sounds kind of like a pain in the ass though.

A much much easier, and less true-to the original, way to make Qix might be to do everything on a tileLayer. You don't have a pixel level of detail (unless you make a tilelayer of size x/y the same as the screen resolution--which sounds like a bad idea), but it would still work and be much much less a pain than finding a way to emulate a "per-pixel" type old-school game in TGB.
#2
07/30/2008 (5:56 am)
Humm... That's the bad news I was affraid of. I also thought about the tilemap idea. Perhaps small 4x4 tiles
on a 1024 screen would make a large enough playing area. I believe I saw a Qix clone done in that way and
it wasn't too bad. I always thought if I was to do something tile-mappy I'd grab a 3d engine and make a
grid of 3d cubes and see how that looked. ...And I noticed TGB has 3d shapes, so if it's fast enough that
may work for me. I'd Just change the cubes visibility and or texture/color as needed.

What are my chances of allocating my own buffer the size of the screen and maintaing it (flood filling etc)
on a pixel basis myself in script, and then creating a bitmap/image or something out of it and blasting it to the
screen?

...Or perhaps, TorqueX would allow me my pixel access in c#? Anyone know about that?

Thanks for the input James, and good luck with your Qix.

Word to the TGB team - Pixel access please!!! ...This thing is too good to be with out it.

Thanks,
Lawrence
#3
07/30/2008 (10:03 am)
Maybe make a new t2dSceneObject or perhaps GuiControl... t2dBuffer / GuiBufferCtrl, which has methods exposed for drawing to it, and querying the pixel value at a uv coord. As long as you aren't actually specifying each pixel/color in script on each frame, you have some methods like drawLine / floodFill / drawRect methods, so it can be done more optimally in C++.