News:

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

Questions about Include files

Started by savage, May 29, 2006, 03:06:16 PM

Previous topic - Next topic

savage

Why are the prototypes in OpenGL all built of DWORDs?

Shouldn't they be REAL4 and REAL8 most of the time?


glClearDepth  proto  :qword


Shouldn't that be ...

glClearDepth  proto  :real8


:dazzled:

I'm not understanding the basics of OpenGL in asm for these reasons.

hitchhikr

Such distinction is only useful to display variables infos in debuggers but since you don't have the sourcecode of the opengl drivers it doesn't really matter as everything located within the ogl functions will be displayed in hexadecimal or decimal.

Afaik, MASM doesn't have enforcing policies about arguments types, only the size of them is used to detemine the stack displacement (someone may confirm or cancel this).

asmfan

Actually MASM cares of types of operands when you use pseudo HI level syntax - .if, .while,... etc. It cares if it is signed or unsigned (BYTE/SBYTE, etc.) But i dont hear that type checking was made on REAL4 or REAL8... don't know at all what for these REALx types...
Russia is a weird place

savage

Quote from: asmfan on May 29, 2006, 04:08:34 PM
Actually MASM cares of types of operands when you use pseudo HI level syntax - .if, .while,... etc. It cares if it is signed or unsigned (BYTE/SBYTE, etc.) But i dont hear that type checking was made on REAL4 or REAL8... don't know at all what for these REALx types...

Hmm, this may be one source of my problem.

But the main problem I"m getting is due to the number of arguments.
Quote
: error A2137: too few arguments to INVOKE

For example, sometimes a function that takes one REAL8 parameter will be defined as "PROTO :DWORD, :DWORD", which is evidently to match up the stack displacement.


stanhebben

To pass a REAL8 parameter, you have to split it in two parts. I suppose invoke can't do that.

Solution: do it by hand. But don't ask me which half to push first  :bg

GregL

savage,

The MASM32 include files are generated programmatically. It would be an enormous amount of work to do them by hand. Hutch would have to fill you in on the details of how this is done. From what I have seen, where parameters are larger than a DWORD, the include files have the equivalent number of DWORDS. Correct me if I am wrong Hutch.


Stan Hebben,

INVOKE can handle REAL8 just fine if you PROTO them as REAL8.

I usually pass pointers to them (PTR REAL8) in my own functions.


Ossa

Quote from: Stan Hebben on May 29, 2006, 06:14:19 PM
To pass a REAL8 parameter, you have to split it in two parts. I suppose invoke can't do that.

Solution: do it by hand. But don't ask me which half to push first  :bg

suppose REAL8 is 8 bytes in order: 01234567
then, if the REAL8 were pushed as one whole value, we would get this them in this order in memory. Thus (as stack addresses go downwards), we want to push bytes 4567 first and 0123 second... therefore we push dword(1) frist and dword(0) second... therefore we need to pass dword(0) as the leftmost parameter and dword(1) as the one after. In other words:


value REAL8 ?

...

mov eax, offset value

invoke function, dword ptr [eax], dword ptr [eax+4], ...


should be correct (but that was quite fiddly, so I might have made a mistake ::) )

I'd just stick with allowing invoke to deal with REAL8's and redo the PROTO so that it's correct.

Ossa
Website (very old): ossa.the-wot.co.uk

GregL

Quote from: OssaI'd just stick with allowing invoke to deal with REAL8's and redo the PROTO so that it's correct.

That's what I do.


hitchhikr

#8
My examples don't use masm32 opengl includes but the ones located in the Examples/Include directory.
When a real8 is awaited the prototype uses a qword like for glClearDepth (for example).
But if you find some protos with incorrect arguments size, please report them to me asap.

GregL

hitchhikr,

Yes, I was referring to the MASM32 includes, not your OpenGL includes.