flat assembler
Message board for the users of flat assembler.

Index > Linux > [SOLVED] 64bit opengl call trouble...

Author
Thread Post new topic Reply to topic
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb 18 Feb 2010, 00:47
glVertexXXXX is giving me unpredictable (and usually non-existant) results. I am under the impression that I'm simply giving it data in the wrong format.
For example,
Code:
invoke glVertex3f,-0.5,-0.5,0.0  ; GLfloat is single-precision
invoke glVertex3f,0.5,0.0,0.0
invoke glVertex3f,0.0,0.5,0.0
    

gives me nothing at all,and
Code:
invoke glVertex2i,     0,0   ; GLint is 4-byte singed
invoke glVertex2i,    1,0
invoke glVertex2i,       1,1
    

gives me points that appear to be way off-screen.
And, of course, I've been experimenting with all the numbers with no luck.

One of the data types I need to work with, GLdouble, is defined as a 'double-precision float'
How would I load these values properly using fasm?
Here's my invoke macro, btw.
Code:
macro invoke func,p1,p2,p3,p4,p5,p6
{
if ~ p1 eq
 mov rdi,p1
end if
if ~ p2 eq
  mov rsi,p2
end if
if ~ p3 eq
  mov rdx,p3
end if
if ~ p4 eq
  mov rcx,p4
end if
if ~ p5 eq
  mov r8,p5
end if
if ~ p6 eq
   mov r9,p6
end if
call [func]
}
    


Last edited by eilenbeb on 18 Feb 2010, 02:16; edited 1 time in total
Post 18 Feb 2010, 00:47
View user's profile Send private message Reply with quote
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb 18 Feb 2010, 01:23
Hmm... I'm afraid I don't know fasm's macros well enough to understand how that works, or how to rewrite it for 64bit.

I tried using things like
mov eax,0.5
mov rdi,rax
but still no results. Going to try the vector form of the functions, I guess.
Post 18 Feb 2010, 01:23
View user's profile Send private message Reply with quote
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb 18 Feb 2010, 02:06
Strange, someone responded but now their post isn't there anymore...

Anyways, using the vector forms of glVertex didn't get me anywhere. I either get nothing at all, or the verts are way off-screen.

I'm stumped.
Post 18 Feb 2010, 02:06
View user's profile Send private message Reply with quote
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb 18 Feb 2010, 02:20
Solved. I went through all of the glVertexXXX's until one worked.
Turns out that glVertex3fv works with floating point values defined as doubles in the data section.
Couldn't get any of the others to work.
Post 18 Feb 2010, 02:20
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 18 Feb 2010, 02:47
eilenbeb wrote:
Strange, someone responded but now their post isn't there anymore...

Anyways, using the vector forms of glVertex didn't get me anywhere. I either get nothing at all, or the verts are way off-screen.

I'm stumped.


Uh yeah.....that was me. I didn't read your post fully and assumed calling was stack based, not register based. That's why I posted to look at that pushd macro, and also why I deleted my post.


I need to stay out of subforums I know nothing about.

_________________
----> * <---- My star, won HERE
Post 18 Feb 2010, 02:47
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 18 Feb 2010, 05:47
eilenbeb wrote:
Solved. I went through all of the glVertexXXX's until one worked.
Turns out that glVertex3fv works with floating point values defined as doubles in the data section.
Couldn't get any of the others to work.

Any of the v-appended gl calls expect a pointer to an array, not a single value.
Also, your macro look like some type of fastcall, where normally stdcall is used.
Meaning the values are pushed onto the stack instead of passed in registers.
Please post an attachment of your code so we can have a look-see...

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 18 Feb 2010, 05:47
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Feb 2010, 06:34
bitshifter, this is 64-bit code and it is Linux forum so no stack nor stdcall (32-bit code typically use cdecl) is commonly used here. Wink

eilenbeb, I think that float values are passed in xmm registers.

[edit]Yep, xmm registers. Take a look at this: http://board.flatassembler.net/topic.php?t=10553 . I have no reasons to suspect about the correctness of the macros, but since perhaps them were not extensively tested some things may be wrong so make sure to read the Linux ABI (some post there has a link). Also note that fasm now has extended support for ELF so you no longer need to create raw binaries as in those macros.[/edit]

[edit2]Well, the link is not there so here it is: http://www.x86-64.org/documentation/abi.pdf . In a quick look I think I saw that kohlrak's invoke uses all of the xmm registers to pass arguments but the specs uses from xmm0 to xmm7 only.[/edit]
Post 18 Feb 2010, 06:34
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 18 Feb 2010, 07:11
LocoDelAssembly wrote:
bitshifter, this is 64-bit code and it is Linux forum so no stack nor stdcall (32-bit code typically use cdecl) is commonly used here. Wink

How cool is that!

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 18 Feb 2010, 07:11
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 26 Feb 2010, 12:36
LocoDelAssembly wrote:
bitshifter, this is 64-bit code and it is Linux forum so no stack nor stdcall (32-bit code typically use cdecl) is commonly used here. Wink

eilenbeb, I think that float values are passed in xmm registers.

[edit]Yep, xmm registers. Take a look at this: http://board.flatassembler.net/topic.php?t=10553 . I have no reasons to suspect about the correctness of the macros, but since perhaps them were not extensively tested some things may be wrong so make sure to read the Linux ABI (some post there has a link). Also note that fasm now has extended support for ELF so you no longer need to create raw binaries as in those macros.[/edit]

[edit2]Well, the link is not there so here it is: http://www.x86-64.org/documentation/abi.pdf . In a quick look I think I saw that kohlrak's invoke uses all of the xmm registers to pass arguments but the specs uses from xmm0 to xmm7 only.[/edit]


To be honest, i never really tested the floating point stuff too extensively, especially since i'm not really good with sse. In light of this topic, i have updated it. Anyway, here's some c code and it's -S output. I guess i got lucky on this one...

EDIT: Jumped the gun... only the first 8 (0-7) are used. I didn't notice that they were moved to the stack after conversion to double. Embarassed
Post 26 Feb 2010, 12:36
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.