![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 288
Rep Power: 4
![]() |
Floats to doubles
I have a problem with floats and doubles.
I wanted to put a camera in my OpenGL scene. But when I added the gluLookAt function, the program did'nt started anymore. I was using this code, and simply made a call like _gluLookAt eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz These variables are created like this: eyex dd 0.0 _gluLookAt macro A1, A2, A3, A4, A5, A6, A7, A8, A9 push A9 push A8 push A7 push A6 push A5 push A4 push A3 push A2 push A1 call gluLookAt endm I guessed that the problem was that the gluLookAt function expects 64 bits doubles, instead of 32 bits floats. I tried my assumption by pushing twice as much on the stack. Then the program started again, but with wrong values to gluLookAt of course. How shall I solve this problem? How do I convert my floats to doubles? Is there a simple way of doing this? I am not an assembly guru, so try keeping the answears as clean as possible ![]() Thanks /Klarre |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3
![]() |
|
|
|
|
|
|
#3 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 288
Rep Power: 4
![]() |
Thanks for the link! It took me back on track again.
But... I got that I should use the cdq instruction to extend the eax to edx. Right? Am I thinking correct if I try using this rewritten code instead of the old one? _gluLookAt macro A1, A2, A3, A4, A5, A6, A7, A8, A9 mov eax, A9 cdq push eax push edx mov eax, A8 cdq push eax push edx ... mov eax, A1 cdq push eax push edx call gluLookAt endm |
|
|
|
|
|
#4 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 288
Rep Power: 4
![]() |
Problem solved...
|
|
|
|
|
|
#5 |
|
Professional Programmer
|
Mind posting the solution to help others?
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;} |
|
|
|
|
|
#6 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 288
Rep Power: 4
![]() |
I solved it using constants. It is a solution so far. And next step is to use double variables instead, so I can move the camera around in real time.
The original function used void gluLookAt(GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ,
GLdouble centerX, GLdouble centerY, GLdouble centerZ,
GLdouble upX, GLdouble upY, GLdouble upZ);In C++ the code would look like this: double eyez = 45.0; double upy = 1.0; gluLookAt(0, 0, eyez, 0, 0, 0, 0, upy, 0); Rewritten in assembly it looks like this: _45d0 equ 40468000h ; eyez _45d1 equ 0 _1d0 equ 1072693248 ; upy _1d1 equ 0 ;; upx, upy, upz pushed on the stack push 0 push 0 push _1d0 push _1d1 push 0 push 0 ;; centerx, centery, centerz pushed on the stack push 0 push 0 push 0 push 0 push 0 push 0 ;; eyex, eyey, eyez pushed on the stack push _45d0 push _45d1 push 0 push 0 push 0 push 0 call gluLookAt |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|