flat assembler
Message board for the users of flat assembler.
Index
> Windows > Translating OpenGL code |
Author |
|
revolution 17 Dec 2009, 08:38
Code: push myDisplay call glutDisplayFunc |
|||
17 Dec 2009, 08:38 |
|
TmX 17 Dec 2009, 14:57
Ah I see.
So here's my another attempt: Code: format PE GUI 4.0 entry start include 'win32ax.inc' include 'opengl.inc' include 'glut32.inc' include 'macro\if.inc' section '.text' code readable executable start: ;glutInit(&argc, argv); ;invoke glutInitDisplayMode, GLUT_DOUBLE | GLUT_RGB invoke glutInitWindowPosition,100,100 invoke glutCreateWindow,"My Animation" push myDisplay call glutDisplayFunc push myReshape call glutReshapeFunc push myMouse call glutMouseFunc call myInit invoke glutMainLoop myInit: invoke glClearColor,0.0,0.0,0.0,0.0 myDisplay: invoke glClear,GL_COLOR_BUFFER_BIT invoke glPushMatrix invoke glTranslated,0.0,20.0,0.0 invoke glRotatef,[spin],0.0,0.0,1.0 invoke glColor3f,1.0,0.0,0.0 invoke glRectf,-10.0,35.0,10.0,15.0 invoke glPopMatrix invoke glPushMatrix invoke glTranslated,0.0,-20.0,0.0 invoke glRotatef,[spin],0.0,0.0,-1.0 invoke glColor3f,0.0,1.0,0.0 invoke glRectf,-10.0,-15.0,10.0,-35.0 invoke glPopMatrix invoke glutSwapBuffers spinDisplay: add spin, 12.0 .if (spin > 360.0) add spin,-360.0; .endif invoke glutPostRedisplay spinCDisplay: add spin,-11.0 .if (spin < 360.0) add spin,360.0 .endif invoke glutPostRedisplay proc myReshape, w,h push ebx esi edi invoke glViewport,0,0,w,h invoke glMatrixMode,GL_PROJECTION invoke glLoadIdentity invoke glOrtho,-50.0,50.0,-50.0,50.0,-1.0,1.0 invoke glMatrixMode,GL_MODELVIEW invoke glLoadIdentity pop edi esi ebx ret endp proc myMouse, button, state, x, y push ebx esi edi .if (button = GLUT_LEFT_BUTTON) .if (state = GLUT_DOWN) push spinDisplay call glutIdleFunc .endif .endif .elseif (button = GLUT_MIDDLE_BUTTON) .if (state =GLUT_DOWN) push NULL call glutIdleFunc .endif .endif .elseif (button = GLUT_RIGHT_BUTTON) . if (state = GLUT_DOWN) push spinCDisplay call glutIdleFunc break; .endif .endif pop edi esi ebx ret endp section '.data' data readable writeable spin GLfloat 0.0 Quote:
I'm sure more error will be revealed. BTW, I attach the glut32.inc
|
|||||||||||
17 Dec 2009, 14:57 |
|
LocoDelAssembly 17 Dec 2009, 15:08
You must use FPU or SSE instructions to perform the addition because ADD instruction works with integers only (using just "add [spin], 12" won't do the trick because ADD won't follow the IEEE-754 format).
Example using FPU: Code: finit ; use this at the beginning of the program . . . fld [twelve] ; You can't use constants in FPU instructions fld [spin] faddp fstp [spin] . . . spin GLfloat 0.0 twelve GLfloat 12.0 |
|||
17 Dec 2009, 15:08 |
|
revolution 17 Dec 2009, 15:32
Since you are using the macros then you can simply do this:
Code: invoke glutDisplayFunc,myDisplay |
|||
17 Dec 2009, 15:32 |
|
madmatt 20 Dec 2009, 09:44
Hello, TmX
For some functions, like this one: Code: invoke glOrtho,-50.0,50.0,-50.0,50.0,-1.0,1.0 will require 'double floats' for parameters so you'll need to do this: Code: invoke glOrtho, double (-50.0), double 50.0, double (-50.0), double 50.0, double (-1.0), double 1.0 negative values have to be put in parenthesis (-1.0). |
|||
20 Dec 2009, 09:44 |
|
bitshifter 20 Dec 2009, 17:41
Hello
Im glad to see an OpenGL enthusiast! This was a demo i wrote a while back... http://board.flatassembler.net/topic.php?t=9262 Maybe it can help you with learning gl and fpu... And if you are targeting Win32, then drop glut, it sucks... |
|||
20 Dec 2009, 17:41 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.