[Community Project] - Win32 GDI graphics

BlitzMax Forums/BlitzMax Programming/[Community Project] - Win32 GDI graphics

** Download - GDI Graphics
_________________________________________________


As a possible community project what do you guys think with regards to creating a Win32 GDI graphics driver?

Here are my thoughts on the pros and cons:

+ No need to rely on OpenGL or DX
+ Uses internal API graphics (smaller executables)
+ Ideal for simple window graphics (boxes, lines, filled ares)
+ Suitable for applications such as paint programs
+ Maxiumum compatibility
- Not as fast (or fully-featured?) as OpenGL or DX
- Windows only

Anyhow, here's something I've been playing with ..



Ideally, I would like to see something which mimics all of the Max2D commands but relys solely on API calls to avoid the need for OpenGL, DX. Example:

SetGraphicsDriver GDIGraphicsDriver()
SetGraphics mypanel ' send graphics output to panel gadget
SetPenColor 100,200,200
SetPenWidth 4
SetFillColor 50,60,70
DrawRect 10,20,40,50


At the moment, I have a GDI type with the following methods:
gdi1:GDI=GDI.CreateGDIPanel(x,y,w,h,group:TGadget)

methods:

.Free - free the GDI panel and resources

Rendering
--------------------------
.SetRenderMethod
.SetBuffer
.Cls
.Flip

Color Handling
--------------------------
.SetPenColor
.SetPenWidth
.SetPenStyle
.SetFillColor
.SetFillPattern

2D Drawing
--------------------------
.Plot
.Point()
.DrawLine
.DrawOval
.DrawRect
.InvertArea
.ScrollArea
.FloodFill

Text Handling
--------------------------
.DrawText
.SetFont
.SetTextFormat

Bitmap/Icon handling
--------------------------
.LoadBitmap
.FreeBitmap
.DrawBitmap
.DrawScaledBitmap
.LoadIcon
.DrawIcon
.FreeIcon


Also, the following events are returned to the Max event system when the mouse is over a GDI gadget:

Event               Source       Data          EventX()     EventY()

EVENT_MOUSEMOVE  | gdi panel | n/a           | mouseXpos  | mouseYpos
EVENT_MOUSEUP    | gdi panel | button(1/2/3) | mouseXpos  | mouseYpos
EVENT_MOUSEDOWN  | gdi panel | button(1/2/3) | mouseXpos  | mouseYpos


Handy Links:
API Guide
Microsoft MSDN
Win32 API reference - 5.43MB

I'll try and update the source code with any mods/additions you come up with ...