News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Using DirectDraw

Started by NoCforMe, March 02, 2025, 09:41:53 AM

Previous topic - Next topic

NoCforMe

This thread is an introduction to the Win32 DirectDraw API.
DirectDraw is an interface that allows the programmer more direct access to the video system than the earlier GDI and GDI+ interfaces.

According to Microsoft:

QuoteThe DirectDraw application programming interface (API) is the component of DirectX that enables you to directly manipulate display memory, the hardware blitter, hardware overlay support, and flipping surface support. For more information, see the Microsoft.DirectX.DirectDraw managed code reference documentation.

In this thread you'll find coding examples showing how to use DirectDraw, as well as discussions and questions and answers regarding that interface.

Note: Be aware that this is actually an old interface that, according to Microsoft, has been "deprecated":

QuoteWarning: Microsoft DirectDraw has been deprecated. Deprecated components of Microsoft DirectX 9.0 for Managed Code are considered obsolete. While these components are still supported in this release of DirectX 9.0 for Managed Code, they may be removed in the future. When writing new applications, you should avoid using these deprecated components. When modifying existing applications, you are strongly encouraged to remove any dependency on these components.
Assembly language programming should be fun. That's why I do it.

Siekmanski

2 examples using DirectDraw.
Very old but, maybe you can use it.

Creative coders use backward thinking techniques as a strategy.

satpro

Quote from: Siekmanski on March 02, 2025, 11:13:02 AM2 examples using DirectDraw.
Very old but, maybe you can use it.



I credit you (and your coding style) with making DirectX click for me.  Really.  Thank you!

David:  It's coming soon; I'm working on it now.  BTW, this thread is a very good idea for many of us.

jj2007

Quote from: Siekmanski on March 02, 2025, 11:13:02 AM2 examples using DirectDraw.

include\ddraw.inc(731) : error A2181: initializer must be a string or single item
include\ddraw.inc(731) : error A2138: invalid data initializer
include\ddraw.inc(774) : error A2181: initializer must be a string or single item
include\ddraw.inc(774) : error A2138: invalid data initializer

Does your code require an older version of ddraw.inc?

NoCforMe

Looking at that file (ddraw.inc), I only see prototypes for the following functions:

  • DDGetAttachedSurfaceLcl()
  • DDInternalLock()
  • DDInternalUnlock()
  • DSoundHelp()
  • DirectDrawCreate()
  • DirectDrawCreateClipper()
  • DirectDrawCreateEx()
  • DirectDrawEnumerate() (4 flavors, A/W & "Ex")
  • GetDDSurfaceLocal()
  • GetSurfaceFromDC()

No primitives, like line, ellipse, etc., so I guess that's all up to the programmer to create? (I still really have no clue how this all works.)
Assembly language programming should be fun. That's why I do it.

TimoVJL

Those are just wrapper functions.
DirectDraw is COM based.
May the source be with you

NoCforMe

Ah, so. So the real functions are pointed to in the vtable. Gotcha.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: jj2007 on March 03, 2025, 08:10:22 AM
Quote from: Siekmanski on March 02, 2025, 11:13:02 AM2 examples using DirectDraw.

include\ddraw.inc(731) : error A2181: initializer must be a string or single item
include\ddraw.inc(731) : error A2138: invalid data initializer
include\ddraw.inc(774) : error A2181: initializer must be a string or single item
include\ddraw.inc(774) : error A2138: invalid data initializer

Does your code require an older version of ddraw.inc?

Marinus has code and include files+libs linked somewhere around here. He was once helping felipe get a handle on DirectDraw stuff way back whenever... I recall only bits of it, it could have been 3D stuff.  Maybe in the GameDevelopment section?

Later:
I found what I was thinking of Here. But the link no longer works there.

Also further down, Siekmanski mentioned using DX9...
Quote from: Siekmanski on April 11, 2018, 08:02:41 AMDid you download the latest DirectX9 End-User Runtimes?
DirectX End-User Runtimes (June 2010)
https://www.microsoft.com/en-us/download/details.aspx?id=8109
I would think that is what his code posted above uses, as he said they were 'old' examples.
Maybe Siekmanski will come back and shed some light on this, but he doesn't visit here very often anymore.
¯\_(ツ)_/¯
tictactoe_final is finished    :smiley:

sinsi

include\ddraw.inc(731) : error A2181: initializer must be a string or single item
include\ddraw.inc(731) : error A2138: invalid data initializer
include\ddraw.inc(774) : error A2181: initializer must be a string or single item
include\ddraw.inc(774) : error A2138: invalid data initializer
Just define LARGE_INTEGER in your code.

jj2007

Quote from: sinsi on March 03, 2025, 05:12:12 PMJust define LARGE_INTEGER in your code.

With LARGE_INTEGER equ QWORD I get internal assembler errors

MASM : fatal error A1016: Internal error

  Version 10.00.40219.01

  ExceptionCode            = C0000005
  ExceptionFlags           = 00000000
  ExceptionAddress         = 0096484F

Masm 6.14 complains about the structure in Windows.inc, line 8112:
LARGE_INTEGER UNION
    STRUCT
      LowPart  DWORD ?
      HighPart DWORD ?
    ENDS
  QuadPart QWORD ?
LARGE_INTEGER ENDS

Without defining:
include\ddraw.inc(731) : error A2181: initializer must be a string or single item

Which is kind of funny because ddraw.inc is just 44 lines short...

sinsi

Confucius say "When you dash off a glib answer you tend to get bitten in the bum  :sad: "

I have problems building too.

NoCforMe

After looking at a couple of the example source files posted here, I have a request to make:

If you're going to post a programming example here, please, PLEASE COMMENT IT! Nothing more useless than an example that might work but gives the uninitiated programmer no clue as to HOW it works.

Even commented pseudocode would be better than uncommented actual ASM code.
Assembly language programming should be fun. That's why I do it.

jj2007

If it's deprecated, why not go for Direct2D?

TimoVJL

Quote from: jj2007 on March 04, 2025, 11:19:16 PMIf it's deprecated, why not go for Direct2D?
also Direct2D is deprecated and included to Direct3D since version 9
May the source be with you

jj2007

So... how complicated would it be to draw a circle in Direct3D?