I'm trying to write a basic OpenGL program.

Everything works up to the point of drawing the triangles.
All I get is a black window.

I believe this is because I am not passing the floats correctly
such as:

invoke glVertex3f,1,0,0

GoAsm does not support numbers like 1.5 or 0.26, so how do
represent a floating point number without a using a decimal point or
what do they actually look like (perhaps something like 00010005h = 1.5 ?)

- Mike
Posted on 2003-03-12 17:14:29 by ASMMike
I think GoAsm is passing a DWORD integer instead of a REAL4 float. What you should do is dfine you x, y and z coordinates in a memory variable (as a single precision floating point of course :) ) and then pass it on to glVertex3f. Like this for example

xcoord REAL4 1.0
ycoord REAL4 0.0f
zcoord REAL4 0.0f


invoke glVertex3f, xoord, ycoord, zcoord

Note that I use MASM syntax, it is the assembler I recommend for Win32ASM programming. If GoAsm doesnt support the variable names you'll have to change them.
Posted on 2003-03-12 17:43:11 by x86asm

I am sorry I did not see your message until recently. I have in fact just dealt with a similar point made in the GoAsm forum, by adding functionality in GoAsm for PUSH 1.0.

This pushes the real number itself only the stack (as opposed to a pointer) to suit some APIs which take a single-precision (32-bit) real number as a parameter.

You can use it straight or through a defined word (equate):-

THING = 7.3E9
PUSH 65.6

Or you can use the INVOKE equivalent.

You need the latest GoAsm 0.46f beta.

Your question, however, related to the OpenGL functions. These are different and actually take double-precision (64-bit) real numbers on the stack.

Unfortunately the Windows SDK could be misleading to assembler programmers about this. Here is the "C"-type description of the parameters taken by the API gluPerspective:-

void gluPerspective(
GLdouble fovy,
GLdouble aspect,
GLdouble zNear,
GLdouble zFar

One might think each parameter was a dword since this is usually the case with APIs, but in fact the GLdouble type is 64-bits, so there will be 8 PUSH instructions in total to send all the necessary parameters to this API. These are done in reverse dword order. In other words suppose you have a real number declared as follows:-

AValue DQ 45.0

Since the data here is 64-bits but the stack is only 32-bits, to push the data on the stack requires two PUSH instructions. The API expects it to be pushed in the order then .

I toyed with the idea of adding a PUSHQ instruction to GoAsm to achieve this more easily, but Donkey got there first with his PUSHQ macro as follows:-


Thanks, Donkey!

Jeremy Gordon
(author of GoAsm assembler and tools
Posted on 2003-12-30 12:37:51 by jorgon