3D engine, beginning

Community Forums/Graphic Chat/3D engine, beginning

JoshK(Posted 2005) [#1]
Try out the pixel-perfect 2D drawing commands, with alpha blending.

http://www.leadwerks.com/post/engine2D.zip

Blitz3D and BlitzPlus examples included.




slenkar(Posted 2005) [#2]
I just get a green screen( B3d)


puki(Posted 2005) [#3]
Ooh, I'm not into 2D stuff.

Hey, that "Antony" boy is working on a 2D engine thing - I reckon you two should team up You are both similar in a way - both got technical knowledge.

EDIT:
Oh, it is a 3D engine.


JoshK(Posted 2005) [#4]
Slenkar, what version B3D? What graphics card?


IPete2(Posted 2005) [#5]
Fast isnt in it! Wow!

Puki - this is just the start of the engine 2D first...

and it is very very fast. 895 fps steady on 2000 rectangles.

IPete2.


JoshK(Posted 2005) [#6]
I added image support. Images are automatically drawn with transparency if they are 32-bit.


JoshK(Posted 2005) [#7]
Slenkar, I think I fixed your problem. Your card probably uses GL_CULL_FACE True as a default setting.

New download.


RGR(Posted 2005) [#8]
Nice and very fast


maximo(Posted 2005) [#9]
if this is only the beggining, I can't imagine what wonders of technology we gonna see at the end of this 3d engine. Any ideas halo?


puki(Posted 2005) [#10]
Yeh, and I'm now managing "halo" - he's like a son to me.


JoshK(Posted 2005) [#11]
Maximo, are you being sarcastic?

If anyone is really going to use this for a project, I will make a free 2D version. I would like to see it get used, if only for a small pretty 2D project.


Red Ocktober(Posted 2005) [#12]
no free versions!!!

if you're gonna do it, make a first rate 2d engine... and charge for it... and support it...

but make the 3D engine first :) pleeeeeeeease...


puki... what kinda manager are you... lettin im give away the golden goose...

--Mike


JoshK(Posted 2005) [#13]
I have to write the 2D before I write the 3D, so this is just the base of the 3D engine.

One thing I determined pretty quickly is you can't really use blend modes or lighting with images. I am using glDrawPixels, because it allows me to use images of arbitrary dimensions, with no texture filter blurring. You can load an image with an alpha channel, and it will be smoothly blended, but you can't use an additive or multiplicative blend mode. Still, lights and shadows can be done with the image alpha channel, and it is a solid system. In fact, it is probably identical to BlitzMax's system.

What other features would you like to see in the 2D engine?


Red Ocktober(Posted 2005) [#14]
its looks real good Josh...

--Mike


JoshK(Posted 2005) [#15]
Scratch that, I will need to use textures to do this. I'll be back with a texture-based version.


Picklesworth(Posted 2005) [#16]
A nice start. Very clean. I still don't like your indented endifs though ;)
Can't wait to see the 3d stuff.


Ice9(Posted 2005) [#17]
Is it just a wrapper for this
http://freeimage.sourceforge.net

The documentation makes the dll access look kind of simple
http://prdownloads.sourceforge.net/freeimage/FreeImage370.pdf?download

Is that just for loading images?


JoshK(Posted 2005) [#18]
FreeImage is a library for loading different image file formats. It is not a renderer, it just translates a file format into a buffer of pixel colors.

Using a texture approach, I got image scaling and rotation working, while maintaining pixel-perfect drawing, and and it still works with ImageHandle. So you can now use OpenGL coloring, alpha, and blend modes with images...for example, make a GUI button get brighter when the mouse is over it.

This is the most fun I have ever had with 2D...reminds me of Super Nintendo and "Mode 7 Graphics!"

Will post an update soon.


JoshK(Posted 2005) [#19]
Okay, here it is. Same download at top.




maximo(Posted 2005) [#20]
Halo, sarcastic and interested to know more what you plan to do with it, which you failed to answer ;)


cermit(Posted 2005) [#21]
maximo come on, be nice. :)

Anyway, if this supports realtime rotating and scaling then sure why not buy it :) Go halo!


maximo(Posted 2005) [#22]
cermin, jag är nice ;)

good luck halo


Shambler(Posted 2005) [#23]
Works fine here!


Leiden(Posted 2005) [#24]
Looks Awesome! Working Perfect.


Alienforce(Posted 2005) [#25]
Great as always Halo.

/Alienforce


JoshK(Posted 2005) [#26]
Well, it does everything I want it to. I'm going to finish up a few things and call the 2D routines finished.

Maximo, don't you work for me?

Slenkar, did you try the new version?


Regular K(Posted 2005) [#27]
IIITTTTSSSS GGGGGGGGGGGGGGGGRRRRRRRREEAAAAAAAAATTTTTT!!!!!!

:D

(392 min fps, 426 max)


JoshK(Posted 2005) [#28]
Okay, it's done.

-Draw lines, points, and rectangles with pixel-perfect accuracy
-3D-accelerated performance in 2D
-Draw and tile images
-Rotate and scale images with correct image handles
-Create, load and save images in many formats, with alpha channels, and adjustable JPEG quality
-Set drawing color, with alpha
-Set 5 different drawing blend modes
-Retrieve image data with ImagePixels() and update with UpdateImage()
-Draw on any window, or use multiple windows
-Can be used with any programming language

BlitzMax sells for $80. Play Basic sells for $34.95. I'll sell this for $29.95. If a few people are interested, I will package it up and put it on my site.



Here is the complete list of commands:

;General
Release(node) : "Release"

;Graphics
CreateViewport_%(hWnd) : "CreateViewport"
Cls_() : "Cls"
DrawRect_(x,y,width,height,fill) : "DrawRect"
DrawLine_(Ax,Ay,Bx,By) : "DrawLine"
LoadFont_%(fontname$,size) : "LoadFont"
SetFont_(font) : "SetFont"
DrawText_(text$,x,y) : "DrawText"
Plot_(x,y) : "Plot"
DrawImage_(image,x,y) : "DrawImage"
SetBlend_(blendmode) : "SetBlend"
SetColor_(red,green,blue,alpha) : "SetColor"
FPS_%() : "FPS"
Sync_(vwait) : "Sync"

;Image
LoadImage_%(file$,flags) : "LoadImage"
ImageWidth_%(image) : "ImageWidth"
ImageHeight_%(image) : "ImageHeight"
ImageDepth_%(image) : "ImageDepth"
ImagePitch_%(image) : "ImagePitch"
HandleImage_(image,x,y) : "HandleImage"
MidHandleImage_(image) : "MidHandleImage"
RotateImage_(image,angle#) : "RotateImage"
ScaleImage_(image,x#,y#) : "ScaleImage"
ImagePixels_%(image) : "ImagePixels"
UpdateImage_(image) : "UpdateImage"
SaveImage_%(image,file$,quality) : "SaveImage"
CreateImage_%(width,height,depth) : "CreateImage"

;Maths
RectsOverlap_%(Ax,Ay,Aw,Ah,Bx,By,Bw,Bh) : "RectsOverlap"
PointDistance_#(Ax,Ay,Bx,By) : "PointDistance"
PointInRect_%(Ax,Ay,Bx,By,width,height) : "PointInRect"
WrapAngle_#(angle#) : "WrapAngle"
CurveValue_#(target#,value#,increments#) : "CurveValue"
CurveAngle_#(target#,value#,increments#) : "CurveAngle"
AngleDifference_#(angle0#,angle1#) : "AngleDifference"



Picklesworth(Posted 2005) [#29]
It appears to work quite well, be powerful, fast, and flexible. However: $29.95 for something that we've watched you develop over the last 24 hours?
Comment withdrawn. (Since you are delivering proper support to this product, I may as well not pester you).


JoshK(Posted 2005) [#30]
You're just saying that because you don't have the ability to do what I just did.

I said a few people. That's 4, maximum. $30*4=$120. $120/30 hours of work=$4 an hour.

If anyone has a good amount of experience with 2D games, and has enough art resources, I'll give you a copy if you make me a demo I can put on my site.


slenkar(Posted 2005) [#31]
Any chance of getting this to render 2d stuff over blitz3d graphics????

It would sell a lot more copies if you could do that!

EDIT-
It now says:
"failed to initialize 3d engine"

GFx card-Intel integrated 82845g 11MB

Possible reasons:
32-bit gfx
video mode > 800x600


JoshK(Posted 2005) [#32]
Slenkar, I think your graphics card is missing one of the OpenGL extensions I use. I can remove those ones, just for you.

It's impossible to render this over Blitz3D graphics...this is OpenGL, and that is DirectX...


JoshK(Posted 2005) [#33]
Slenkar, I updated the package so that it no longer requires the two OpenGL extensions I was using.

Please give this a try:
http://www.leadwerks.com/post/engine2D.zip


Red Ocktober(Posted 2005) [#34]
the price is more than fair... in my opinion...

funny how some things are so great... until people find out that they have to pay for em...



--Mike


Kuron(Posted 2005) [#35]
I would definitely be interested in buying this, unfortunately the FreeImage dependency is a stumbling block for me due to the bloated size of the freeimage DLL.

Otherwise well worth the $$ in my opinion and fairly priced.


big10p(Posted 2005) [#36]
I would definitely be interested in buying this, unfortunately the FreeImage dependency is a stumbling block for me due to the bloated size of the freeimage DLL.

Uh? The version I'm using (may not be the latest) is only 281k.


Warren(Posted 2005) [#37]
It appears to work quite well, be powerful, fast, and flexible. However: $29.95 for something that we've watched you develop over the last 24 hours?
I'm looking for a get-rich-quick sheme, so I would be proud if you taught me how to do it!

The value of a piece of software is in no way related to how long it took to develop.


slenkar(Posted 2005) [#38]
sorry, I just get a black screen now,

If you did a directx7 2D engine would that be able to render over blitz3d?


R0B0T0(Posted 2005) [#39]
black screen here too, mind you it's my pc at work with intel integrated graphics.

issues aside, what (if any) advantages would this have over BlitzMax for 2d games?


JoshK(Posted 2005) [#40]
Kuron, wthe FreeImage DLL can be compressed down to 400 kb. Why does it matter? Download speed?

Slenkar, a DX engine might be able to render over Blitz3D, but I don't use it.

You Intel integrated graphics people...I'd like to get this working for you, if possible. I used to have that graphics card, and I know it wouldn't run a lot of simple OpenGL apps...but I would like to get it working, if possible. There must be a really well-known issue with those. Can you get me your precise gfx card names?

Advantages over BlitzMax? I think you should just use what you prefer. If you have BlitzMax, this is a little redundant, unless you want to be able to save images. If you don't have BlitzMax, this is an easy way to get all the same 2D effects, without changing programming languages.


JoshK(Posted 2005) [#41]
If either of you have PureBasic, try running the OpenGL examples in Source - Advanced. That was one program my Intel 810 would not display. If you can figure out what's wrong with that simple code, I can fix this.

Oh, and can you try running the BlitzMax demos and see what you get?


*(Posted 2005) [#42]
Looks good, however I want to do my own OpenGL stuffs. Good work tho :D


Oddball(Posted 2005) [#43]
Stick in pixel perfect collision at any rotation or scale and it'll be worth $29.95.


R0B0T0(Posted 2005) [#44]
halo, intel 82865G. The blitzmax demo (the breakout clone) runs, albeit slowly.


JoshK(Posted 2005) [#45]
Oddball, isn't pixel collision considered too slow for realtime use?


SSS(Posted 2005) [#46]
Greatlooking engine btw... i would buy if i didnt have BlitzMax...

BlitzMax does pixel perfect collision regardless of scale and orientation. Its not to slow.


JoshK(Posted 2005) [#47]
Hmmm...the best way to get pixel-perfect collision would probably be to draw the image with whatever settings it has, get the pixels from the frame buffer, then compare those to the other image.


Kuron(Posted 2005) [#48]
black screen here too, mind you it's my pc at work with intel integrated graphics.
You will likely need a real graphics card. MOBO video chips are notorious issues when it comes to OpenGL or DX. Some will work fine with OpenGL and choke on DX (SiS) others like Intel will work fine on DX and choke on OpenGL.

Kuron, wthe FreeImage DLL can be compressed down to 400 kb. Why does it matter? Download speed?
Even 400k is a joke for a DLL used simply to load images. Heck 400K is bigger than what my game's EXE would be and bigger than what your engine DLL is. The fact remains, FreeImage is likely not needed for what you are using it for.


JoshK(Posted 2005) [#49]
Well, if the BlitzMax demos run, I should be able to get mine to run as well.

What would you suggest as an alternative to FreeImage? It loads every image format, plus .dds textures, and saves to many formats as well. I suppose I could compile a version of the DLL with the unneeded routines removed.

What is your concern with 400 kb, anyway? Download times for 56k users?


Oddball(Posted 2005) [#50]
Oddball, isn't pixel collision considered too slow for realtime use?
BlitzMax manages it at a decent speed. I suppose it doesn't have to be perfect, just pretty damn close to pixel perfect collision :)


Picklesworth(Posted 2005) [#51]
Couldn't there be a detail factor of some sort, which could be set for pixel perfect collision?
With 1 being that it checks every single pixel, 2 being ever second pixel, and so on?


JoshK(Posted 2005) [#52]
Why do you use per-pixel collision anyways? That's like testing polygon intersection in realtime. Don't 2D games usually just move the player around in a tile-based scene?

And why would you need it to work with image scaling? Image scaling, as far as I can tell, is only useful for Super Nintendo effects, like making something fly offscreen up at the camera?

I'm not criticizing, I just don't know much about 2D games, and don't understand how you would make use of such things.


ErikT(Posted 2005) [#53]
This looks very nice. Another potential customer here.

What other features would you like to see in the 2D engine?

Positioning of a quad's vertices any place you want. Could be used for shadows stretching based on the position of a moving lightsource for instance.


JoshK(Posted 2005) [#54]
So you mean polygon drawing. That's doable, you would just pass a buffer of screen coordinates to the engine, and it would transform them into vertex coordinates:

DrawPoly(points,bank*)


puki(Posted 2005) [#55]
I'm glad that people like mine and "halo's" engine.


Kuron(Posted 2005) [#56]
The value of a piece of software is in no way related to how long it took to develop.
I think that comment came about because a couple of posts up Halo said it was going to be free.

Well worth the $$ in my opinion...


slenkar(Posted 2005) [#57]
All the blitzmax demos ran fine for me,
There was a time when the demos that Mark posted on the forums didnt work, like the Directx bug checks.'
Then I asked for a Directx demo and it worked.


JoshK(Posted 2005) [#58]
I uploaded a new version. Whatever the Intel problem is, this won't fix it, but it is a nice finished dll, with a CHM help file. Please take it for a test run.

I'll try to resolve the Intel incompatability thing if I can.

Same link as above.


Picklesworth(Posted 2005) [#59]
I think that comment came about because a couple of posts up Halo said it was going to be free.

Well worth the $$ in my opinion...

Actually, that comment now only exists in quotes. If you read the post where it came from, you will see that I withdrew the comment, because I had been outquoted, and thus had my opinion on the situation changed :)


RocketGnome(Posted 2005) [#60]

Why do you use per-pixel collision anyways? That's like testing polygon intersection in realtime. Don't 2D games usually just move the player around in a tile-based scene?



Aligning a character to a non-straight platform (ala Jungle Hunt/BC's Quest/Sonic) would be easier to accomplish with per-pixel.


And why would you need it to work with image scaling? Image scaling, as far as I can tell, is only useful for Super Nintendo effects, like making something fly offscreen up at the camera?


Mario vs Super Mario. (Granted someone could just re-draw a larger version of Mario, but it's an example)

Here's a better example: Suppose you have a game where you control a bubble that inflates as it moves around. It would be easier on memory to scale one character than keep the different increasingly larger versions in memory. You'd need to detect collision with this "character" regardless of the method you utilized.



Hmmm...the best way to get pixel-perfect collision would probably be to draw the image with whatever settings it has, get the pixels from the frame buffer, then compare those to the other image.


That's the right track. I believe the first step is to do bounding box collision to see if it's even worth checking, and with that, only check the pixels of the bounding box created from the intersection.

Edit - Here's a website that might help you out:
http://www.kuhnstall.de/tutorials/dx9sharp6.html


luigikart(Posted 2007) [#61]
Doesn't anyone care that the link doesn't work?


boomboom(Posted 2007) [#62]
Lol, that site was posted up 2 years ago...

The arthur has changed his site layout since then, here is a new link.

http://www.kalme.de/index.php?option=com_content&task=category&sectionid=4&id=14&Itemid=26


_33(Posted 2007) [#63]
Doesn't Leadwerk's 2D engine give similar features as FastImage?

If Leadwek's 2D engine is still around, I might switch.