Page 1 of 1

Small trick with ASM

Posted: Sat Oct 09, 2004 8:23 am
by Progs

Code: Select all

Procedure mae_setambient( r.f, g.f, b.f )
    Protected *t
    mov *t, esp ;now *t point to 3 floats array :)
    glLightModelfv_( #GL_LIGHT_MODEL_AMBIENT, *t );
EndProcedure

Re: Small trick with ASM

Posted: Sat Oct 09, 2004 8:40 am
by PB
What does it do?

Posted: Sat Oct 09, 2004 8:43 am
by Dreglor
somthing with gl and ambient light...?

Posted: Sat Oct 09, 2004 8:47 am
by PolyVector
It appears to set *t to point to the stack of parameters sent to mae-setambient()... I've seen this method used in ASM to call VxDCall

Posted: Sat Oct 09, 2004 9:01 am
by Progs
Yes. glLightModelfv sets Ambient light level.
Function takes pointer to array of 3 floats
without asm it may looks like

Code: Select all

structure color
r.f, g.f, b.f
end structure

procedure set_ambient( r.f,g.f,b.f )
 c.color
 c\r = r
 c\g = g
 c\b = b
 glLightModelfv_( #GL_LIGHT_MODEL_AMBIENT, @c ); 
endprocedure
but now its only

Code: Select all

!extrn _glLightModelfv@8
Procedure mae_setambient( r.f, g.f, b.f ) 
    !PUSH esp
    !PUSH 0x0B53
    !CALL _glLightModelfv@8
EndProcedure
asm rulez :)