I need help with gluLookAt function in assembler. I am very new to asm and this is just modified example from FASM but when program goes to my function it crashes for no reason.
Whole code: http://pastebin.com/6UpkutWV
My code: lines开发者_运维技巧 86 - 90 (not much but enough to cause problems :P)
First invoke causes crash. I am compiling with FASM.
Without being a FASM expert, your 'doubles' are declared as floats on lines 166–169, so presumably for each argument you're trying to read and submit 64 bits from an area that has the relevant numbers stored in just 32?
Otherwise your parameters to gluLookAt seem to be correct. You're specifying an eye at (2, 0, 1), looking at (0, 0, 0) with (0, 1, 0) being up. So you've met the only constraint required by gluLookAt for its documented behaviour — that the vector from the eye to the thing it's looking at and the up vector not be parallel.
Have a look at http://flatassembler.net/docs.php?article=win32#2
Your problem seems to be in the gluLookAt invocation, since you are passing pointers to doubles, but the function actually requires you pass the actual data to the stack instead.
The correct invokation (after replacing "include 'win32a.inc'" with "include 'win32ax.inc'" (notice the "x") is:
invoke gluLookAt, double [double2], double [double0], double [double0_5], double [double0], double [double0], double [double0], double [double0], double [double1], double [double0]
Also you need to fix your data because you declared it with the wrong type (as Tommy said), but additionally you forgot to use float literals (GLdouble is defined as "dq" so the assembler cannot infer the data is supposed to be stored as a double). The correct code for the variables is this:
theta GLfloat 5.0
double0_5 GLdouble 1.0
double0 GLdouble 0.0
double1 GLdouble 1.0
double2 GLdouble 2.0
With this the program will stop crashing, but will show some wired stuff or nothing but a black screen nonetheless. You'll have to find out what's wrong with your algorithm.
精彩评论