Author Topic: Windows GDI animation with semitransparent pixels and custom shape 64 bits  (Read 20641 times)

Offline BalticMusicFan

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
I had fallen into too much bogus information when I tried to create a program for the first time that draws something to the screen. To decrease your chance to get stuck with this topic, I am sharing code that does more than showing sample picture within rectangle. Since source code is way larger than I would like to scroll over here, it is available at https://pastebin.com/nLQgpNqn .

Some myths I would like to debunk with this code:
  • It is required to write your own Window Procedure in order to create a window;
  • To create a window with complex shape, you are stuck with CreateRectRgn/CombineRgn functions;
  • Reserving one RGB colour as transparent is required to achieve transparency effects.
If you are only on 32 bit OS or not very friendly with assembler, you might still see some hints how to deal with Windows graphics some other way.
My primary field is a chemistry, so I might assemble outside limits of Information Technology.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Thanks, BalticMusicFan!

Nasm's Windows users need all the help they can get from each other!

Best,
Frank


Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Hello. I couldn't compile it with

nasm.exe -w-orphan-labels "messageboxa x64.asm" -f win64 -o "messageboxa x64.obj"
GoLink.exe "messageboxa x64.obj" "kernel32.dll" /dynamicbase /entry start /largeaddressaware /nxcompat /fo "messageboxa x64.exe"

I'v got the next error: nasm: fatal: unable to open input file `messageboxa x64.asm'

Thank you

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Hi Alfonso,

Filename on effing pastebin seems to end in "asm.asm". Lemme see if I can attach it here... Thanks for the heads-up!

Best,
Frank

« Last Edit: January 31, 2018, 09:31:47 PM by Frank Kotler »

Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: Windows GDI animation with semitransparent pixels and custom shape 64 bits
« Reply #4 on: February 01, 2018, 02:04:08 PM »
Hello, Frank. Great work, as ever  :)  It was my fault naming the file ???
« Last Edit: February 01, 2018, 02:10:23 PM by avcaballero »

Offline BalticMusicFan

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
Re: Windows GDI animation with semitransparent pixels and custom shape 64 bits
« Reply #5 on: February 01, 2018, 09:11:18 PM »
Thanks for the heads up!

I was experimenting with export labels feature to figure out best way how to properly sort and annotate code pieces so looking at them would make sense what each code block is about to accomplish for programs that are at reasonable size. Preparing myself for greater challenges.
So far figured out one rule that serves well: Every Label Name Is Correct And Unique no matter how labelled position is reached. It is drastic against usage of if elseif else blocks because you are not forced to name them unique, though I have not intended to blame them in first place. Unintended consequences for otherwise nice features.

Thanks, BalticMusicFan!

Nasm's Windows users need all the help they can get from each other!

Best,
Frank
My primary field is a chemistry, so I might assemble outside limits of Information Technology.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Windows GDI animation with semitransparent pixels and custom shape 64 bits
« Reply #6 on: February 01, 2018, 10:28:09 PM »
Well, thanks again in any case. I think you'll find that after four(?) posts you'll be allowed to attach files. I blame the spammers for the fact that the Forum is such a PITA.

Beginners hoping to program for Windows often find an example for Linux, which of course won't work. Your comments at the top of the file showing command lines for Nasm and GoLink are a great help. Nasm will do a lot of things, and the wrong commend line is no help. I haven't worked with Windows since win98 was current, so I can't help much.

Best,
Frank


Offline BalticMusicFan

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
Re: Windows GDI animation with semitransparent pixels and custom shape 64 bits
« Reply #7 on: February 19, 2018, 12:08:23 AM »
So there goes first and most likely final changelog. Last version is available at GitHub https://github.com/BalticMusicFan/messageboxa-x64 .

  • This app is now aware of resolution change and colour depth change. When display colour depth is set to 8 bits, semitransparent pixels are made visible.
  • Window colour now changes every frame (I hope it is not too flashing), so it is no longer boring black. Because of this, you might see tearing and significant GPU usage.


My primary field is a chemistry, so I might assemble outside limits of Information Technology.