Blitz3D-like commands in Blitz2D?

Blitz3D Forums/Blitz3D Programming/Blitz3D-like commands in Blitz2D?

Axel Wheeler(Posted 2012) [#1]
I'm wondering if anyone has written something like the following for BlitzBasic (i.e. using the Graphics command instead of Graphics3D). I couldn't find anything like it in the archives, or for any graphics system that I have heard of:

The system would allow the programmer to create shapes in 2D the same way you can create meshes in 3D. So:

myShape=CreateShape()
v0=Create2DVertex(myShape, -1,1)
v1=Create2DVertex(myShape, 1,1)
v2=Create2DVertex(myShape, 1,-1)
v3=Create2DVertex(myShape, -1,-1)
ShapeColor(myShape, 255,0,0)
RotateShape(myShape,45)
ScaleShape(myShape,10,10)  ; Based on Pixels, perhaps?
PositionShape(myShape,100,100)


...You get the idea. The programmer could then create a custom type storing position, speed, etc. and have a dead-simple way to put lots of basic graphical elements on the screen without touching photoshop.

And of course advanced versions could have commands like:

TextureShape(myShape,"c:\mypicture.png")
ShapeFX(myShape,6) ; Curved lines instead of straight, etc.
SaveShape(myShape,"c:\myFile.svg") ; It's basically a vector graphic
etc...


Has anything like this been done, for blitzbasic or for that matter any 2D gaming system?

Thanks Folks!


Yasha(Posted 2012) [#2]
Two ways...

The first thing to know is that there are two main types of 2D engine in use at the moment. Pure "pixel crunching" 2D, which treats the drawing area as an array of RGB values and simply blits rectangles over this, and "2D-in-3D", which uses the graphics hardware to draw textured polygons aligned to the point of view.

Of these, 2D-in-3D is infinitely more popular and, because of the hardware support, is much faster for anything not involving manipulating individual pixels (and these days, one would use a shader for that anyway). Max2D uses this system, and there are several implementations of it for Blitz3D as well (check out FastImage, Draw3D, SpriteCandy etc.). I'm not sure if any of them have exactly the commands you want, but since what you're envisaging lines up so well with 2D-in-3D (mainly, the use of vertices and skinned connections), it could definitely be implemented very easily in all of the mentioned engines, as long as you're willing to write SaveShape yourself. (I know things like "ShapeFX" can be done with Draw3D, because it's similar to one of the demos... and I've seen it done, as well, changing from flat lines to wobbly lines and back).

This can also be done with a pixel-crunching engine, but for the most part it involves writing about 80% of a software-rendering engine because to get rotation, scale and arbitrary vertex position essentially requires recreating most of what 3D hardware will do for you. It has, however, been done in Blitz3D: look for Peter Scheutz's "TooD" (It's Just Too Dimensional!) for an incredibly impressive example.

In general though, for practical usage you want 2D-in-3D.


big10p(Posted 2012) [#3]
I did once write a 2D vector graphics lib that emulated all the B3D commandset (vector entities you could create, parenting, rotation, tforming etc.). No texturing or such like, though.

Last edited 2012


Axel Wheeler(Posted 2012) [#4]
Wow! Great responses and fast. Thanks for the info. I'll check out those products and won't reinvent the wheel.

Thanks again,

-Pete