News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Drawing graphics, redrawing or erasing them

Started by newAsm, January 07, 2010, 01:03:50 AM

Previous topic - Next topic

newAsm

Hi,

I am trying to learn to play around graphics and I would like to get some ideas on how to do some basic things. I have learnt to draw them and changing their colours. What I am interested to learn are the following and would appreciate some ideas or APIs to help me do it:

1.  How do you move them?
2.  How do you erase them completely (discarding them away)?
3.  Is it possible to change their sizes or colours real-time ?

Thank you for your help and looking forward to some advise. ...newAsm

jj2007

If you need more hints, go for GdiPlus, or try OpenGL.

BeginPaint
BitBlt
DrawAnimatedRects
DrawCaption
DrawEdge
DrawFocusRect
DrawFrameControl
DrawState
DrawStateProc
DrawTextEx
EndPaint
ExcludeUpdateRgn
GdiFlush
GdiGetBatchLimit
GdiSetBatchLimit
GetBkColor
GetBkMode
GetBoundsRect
GetROP2
GetUpdateRect
GetUpdateRgn
GetWindowDC
GetWindowRgn
GrayString
InvalidateRect
InvalidateRgn
LockWindowUpdate
OutputProc
PaintDesktop
RedrawWindow
SetBkColor
SetBkMode
SetBoundsRect
SetRectRgn
SetROP2
SetWindowRgn
StretchBlt
UpdateWindow
ValidateRect
ValidateRgn
WindowFromDC
AngleArc
Arc
ArcTo
GetArcDirection
LineDDA
LineDDAProc
LineTo
MoveToEx
PolyBezier
PolyBezierTo
PolyDraw
Polyline
PolylineTo
PolyPolyline
SetArcDirection
CombineRgn
CreateEllipticRgn
CreateEllipticRgnIndirect
CreatePolygonRgn
CreatePolyPolygonRgn
CreateRectRgn
CreateRectRgnIndirect
CreateRoundRectRgn
EqualRgn
ExtCreateRegion
FillRgn
FrameRgn
GetPolyFillMode
GetRegionData
GetRgnBox
InvertRgn
OffsetRgn
PaintRgn
PtInRegion
RectInRegion
SetPolyFillMode

newAsm

Thanks jj2007 for your reply,

I am trying to do this in MASM32. I have been able to draw a filled rectangle (using RECTANGLE) and writing out the text in the filled rectangle (using TEXTIO). What I am interested to do is move both together and maybe do some magic tricks like grow in size, change colours and disappear when done and then later on reappear. It may be something like animation. I would also like to use other filled shapes as well.

I would appreciate if you could maybe provide some other sites that is able to do that - not so much in BASIC as I am not fluent in the GDI.

Thanks ..newASM

newAsm

Hi jj2007,

Forgot to ask. When you create a colour brush using CreateSolidBrush which returns a handle, and after the paint routine, do you need to delete the handle?

Thanks..newASM

raymond

Look at using a double buffer with CreateCompatibleDC, then CreateCompatibleBitmap.
Draw in that second buffer.
After that, look at BitBlt and StretchBlt.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

MichaelW

QuoteWhen you create a colour brush using CreateSolidBrush which returns a handle, and after the paint routine, do you need to delete the handle?

"When you no longer need the HBRUSH object, call the DeleteObject function to delete it."

MSDN: CreateSolidBrush

eschew obfuscation

WryBugz

you might want to look at world transform functions as well for sizing, flipping, rotating etc.. If you like set math it can be a fun exercise; especially in masm.
hmmm, just checked my favourites - don't have the tutorial anymore. There was a good basic lang one. oh well.
gdi object - you create it - you have delete it. They say stock objects don't have to be but if you run the task manager and set up the columns to show gdi leaks; drag you prog around forcing paints - if your gdi count keeps going up you have a leak.

dedndave

there have been a few transformations done in other threads
3x3 and 4x4 matrices - some with sse code - very fast   :U
the forum search tool is your friend

jj2007

#8
Here is a sprite example provided by Ron Thomas posted by Erol, with small adaptions to make it run. It's more than ten years old but demonstrates nicely the techniques you are looking for.

newAsm

Thank you everyone for your replies! It is good to write in and get different perspectives. I will go through them, especially go through sprite3 file. I will probably ask once I have digest them. Thanks..newAsm

herge


Hi jj2007:

I have dowloaded the animation files.

It does not like line 129 of windows.inc

BOOL                        typedef DWORD


06/04/2008  08:57 PM           849,788 windows.inc
               1 File(s)        849,788 bytes
               0 Dir(s)  210,316,406,784 bytes free
D:\masm32\bin>makpdb sprite3

D:\masm32\bin>REM MAKPDB.BAT 5:15 AM 6/3/2006

D:\masm32\bin>REM From Masm Forum

D:\masm32\bin>\masm32\bin\ml /c /coff /Zi /Zd "sprite3.asm"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: sprite3.asm
\masm32\include\windows.inc(129) : error A2004: symbol type conflict : bool
\masm32\include\windows.inc(7804) : error A2179: structure improperly initialize
d
\masm32\include\windows.inc(7804) : error A2008: syntax error : in structure
\masm32\include\windows.inc(8711) : error A2179: structure improperly initialize
d

\masm32\include\windows.inc(9096) : fatal error A1012: error count exceeds 100;
stopping assembly

Volume in drive D is DATA
Volume Serial Number is BC60-6B9F

Directory of D:\masm32\bin

01/15/2010  05:59 AM             9,663 sprite3.asm
01/15/2010  05:33 AM            12,800 sprite3.exe
01/15/2010  05:33 AM               163 sprite3.rc
               3 File(s)         22,626 bytes
               0 Dir(s)  210,316,406,784 bytes free

D:\masm32\bin>pause
Press any key to continue . . .

I am not sure what s going on.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

jj2007

Quote from: herge on January 16, 2010, 04:51:10 PM

Hi jj2007:

I have dowloaded the animation files.

It does not like line 129 of windows.inc

BOOL                        typedef DWORD


Herge,

It seems I included the old version - apologies. Try the new attachment above.

Regards,
Jochen

MichaelW

Hi herge,

The windows.inc problem was because the sprite3 source lacked a:

option casemap :none  ; case sensitive

following the model directive.

Also, to get the correct prototype I had to comment out the:

PlaySound PROTO STDCALL :DWORD, :DWORD, :DWORD

And add:

include winmm.inc

eschew obfuscation

jj2007

Michael,
Thanks for fixing the PlaySound/WinMM issue. I had commented it out, but obviously it's nicer with the sound.

> option casemap :none  ; case sensitive
Is part of include \masm32\include\masm32rt.inc

> Also, to get the correct prototype I had to comment out the:
> PlaySound PROTO STDCALL :DWORD, :DWORD, :DWORD
Works with the protos, too

> And add:
> include winmm.inc
That one helps indeed ;-)

Regards,
Jochen

MichaelW

Hi Jochen,

The proto and the call could have been changed to PlaySoundA (or W), but it was easier to just make one change.
eschew obfuscation