flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > Dword push in FASM (OpenGL procedures)

Author
Thread Post new topic Reply to topic
Tyler Durden



Joined: 24 Feb 2004
Posts: 50
Hi all
The question is how I can push a dword value to use with OpenGL procedures ? For example with glOrtho ?
Post 28 Apr 2004, 11:27
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 212
Location: Budapest, Hungary
Tyler Durden wrote:
how I can push a dword value to use with OpenGL procedures ? For example with glOrtho ?


if you think of double value then it seems something like this

Code:
fld  qword double_source
fstp qword esp
call calc
...
    


if you really think of dword value (int32) then you likely want to use fild instead of fld

Code:
fild dword int32_source
fstp qword esp
call calc
...
    


Don't forget that fstp, unlike push, doesn't change esp register, that is you may still have to change it according to the calling convention.

Endre.
Post 28 Apr 2004, 12:20
View user's profile Send private message Reply with quote
Tyler Durden



Joined: 24 Feb 2004
Posts: 50
But can i use something like glPush in MASM ?
Post 28 Apr 2004, 12:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
I made a few macros my self some time ago (attachment), they makes life easier to use OpenGLs float funcions (those which use GLfloat).

As for masm, I don't recall how it's done there but iirc the stanard push could handle it.


Short description of some of the macros:

glPush <GLfloatVar>
Push a GLfloat (immediate) value, eg. glPush 1.2f

macro glCall <proc name>, [arg]
call a procedure, passing *only* immediate GLfloats.

macro glPush2 <GLfloatVar>
Push a GLfloat variable('s value) which is defined in eg, the .data section. Eg. glPush2 detlaX

macro glCall2 <proc>, [arg]
call a function, like in glCall, but pass *only* GLfloat variables

macro glCall3 <proc>,[arg]
An attempt to make one function of glCall and glCall2, tries to sense if it's an immediate valuer or an variable.

there are some more macros, you can take a look at them to see glCall2 in use - it was so long time ago since I used them I don't recall how they work, so I'll leave them uncommeneted for now.


Description: Macros
Download
Filename: opengl.mac.inc
Filesize: 1.11 KB
Downloaded: 369 Time(s)


_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 28 Apr 2004, 13:35
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
Hello Scientica...
I saw the thread about Windows faq, where you say about this opengl float macros. I have downloaded, and i think you can simplify the macros a little; i mena, you can have only one macro for each situation; for example, instead have glPush and glPush2 you can have for example:
Code:
macro glPush GLfloatVar 
      if GLfloatVar eqtype 0.0f
        virtual at 0
                dq GLfloatVar
                load name.l dword from 0
                load name.h dword from 4
        end virtual
        push name.h
        push name.l
      else
        ..name = GLfloatVar
        push dword ..name+4
        push dword ..name
      end if

    


The same with the glCall, right?
Smile

Thanks for these macros.


Last edited by metalfishx on 04 Nov 2004, 05:35; edited 1 time in total
Post 01 Nov 2004, 12:59
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
Sure, feel free to shorten them down Smile
Post 01 Nov 2004, 15:39
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
Hello. Smile Ok, tellme if this work for you Wink (fasm 1.56) Smile

Code:
macro glPush GLfloatVar 
      if GLfloatVar eqtype 0.0f
        virtual at 0
                dq GLfloatVar
                load name.l dword from 0
                load name.h dword from 4
        end virtual
        push name.h
        push name.l
      else
        ..name = GLfloatVar
        push dword ..name+4
        push dword ..name
      end if


macro glCall proc,arg 
        common
        if ~ arg eq
        reverse
                glPush arg
        common
        end if
       call proc

    



try to do this, and tellme if its ok?..

Code:
....
    TestF  dq 4.232f
    TestF2 dq 1.2f

....
    glPush TestF
    glPush TestF2
    glPush 4.232f
    glPush 1.2f  
    


?

Cheers...! Smile
Post 04 Nov 2004, 05:33
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.