Copy Link
Add to Bookmark
Report

Xine - issue #5 - Phile 301

eZine's profile picture
Published in 
Xine
 · 6 months ago

 

Ú-----------------------------¿
| Xine - issue #5 - Phile 301 |
À-----------------------------Ù






here come's the nice little gatos funky, they are provided as standalone
win32asm compilable exemples, enjoy guys


;----------OpenGL in win32asm example 1----------------
;
; draw a simple colored rectangle
; can be used as a template for more complex animations
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
pixformat dd ?
theDC dd ?
theRC dd ?

.code

start:

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 400 ;hauteur
push 600 ;largeur
push 0 ;y
push 0 ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl ;<========= NOW!

;------------------------ the message loop ----------------------------------

winmain_msg_loop:

push 0
push 0
push handle_wd
callW InvalidateRect ;force paint

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl ;<========= NOW!

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite2
push offset rect_struct
push handle_wd
callW GetClientRect
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint

call draw_opengl ;<========= NOW!

mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite2:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:
push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

;set pixel format

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;clear background

push 0
push 0
push 0
push 0
callW glClearColor

;define window

push 400
push 600
push 0
push 0
callW glViewport

;define the perspective parameters
;here it's simple 2D so we use a simple orthographic matrix

push 1701h ;GL_PROJECTION
callW glMatrixMode
callW glLoadIdentity

push 3ff00000h ;this is 1.875 in floating number format [distance max]
push 0
push 0 ;[distance min]
push 0
push 40240000h ;2.5625 [top]
push 0
push 0c0240000h ;-2.5625 [bottom]
push 0
push 40240000h ;2.5625 [right]
push 0
push 0c0240000h ;-2.5625 [left]
push 0
callW glOrtho

;define the eye parameters
;identity matrix is enough here

push 1700h ;GL_MODELVIEW
callW glMatrixMode
callW glLoadIdentity

ret

draw_opengl:

;----------------- here goes the OpenGL animation -------------------------

;clear color buffer

push 4000h ;GL_COLOR_BUFFER_BIT
callW glClear

;define what we are drawing (object, colors)

push 9 ;GL_POLYGON
callW glBegin

;first corner: red

push 0 ;blue
push 0 ;green
push 3f800000h ;red = 1
callW glColor3f

push 0c0a00000h ;y = -5
push 0c0a00000h ;x = -5
callW glVertex2f

;second corner: white

push 3f800000h ;blue = 1
push 3f800000h ;green = 1
push 3f800000h ;red = 1
callW glColor3f

push 40a00000h ;y = 5
push 0c0a00000h ;x = -5
callW glVertex2f

;third corner: blue

push 3f800000h ;blue = 1
push 0 ;green
push 0 ;red
callW glColor3f

push 40a00000h ;y = 5
push 40a00000h ;x = 5
callW glVertex2f

;fourth corner: green

push 0 ;blue
push 3f800000h ;green = 1
push 0 ;red
callW glColor3f

push 0c0a00000h ;y = -5
push 40a00000h ;x = 5
callW glVertex2f

callW glEnd

callW glFlush ;execute OpenGL commands now

push theDC ;not really useful here cause no animation
callW SwapBuffers ;exchange front and back buffer

ret

end start

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


;----------OpenGL in win32asm example 2----------------
;
; draw some simple objects in 3D and rotate them
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
angle dd 0
objet1 dd ?
objet2 dd ?

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

float TYPEDEF REAL4
increment float 3.0
p0_1 float 0.1
p0_5 float 0.5
m0_5 float -0.5
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m3_0 float -3.0
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
m6_0 float -6.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m40 float -40.0
p40 float 40.0
p45 float 45.0

;-------- name some double precision float numbers ---------------------
; (NB: i may not use them all)

dfloat TYPEDEF REAL8
p0__1 dfloat 0.1
p1__0 dfloat 1.0
p1__33 dfloat 1.3333
p2__0 dfloat 2.0
p3__0 dfloat 3.0
m3__0 dfloat -3.0
p4__0 dfloat 4.0
p5__0 dfloat 5.0
m5__0 dfloat -5.0
p7__0 dfloat 7.0
pp10 dfloat 10.0
mm10 dfloat -10.0
pp40 dfloat 40.0
pp45 dfloat 45.0

;-------- small structures with float numbers ---------------------

Light_Diffuse:
qq1 float 1.0 ;Red
qq2 float 1.0 ;Green
qq3 float 1.0 ;Blue
qq4 float 1.0 ;alpha?

Light_Position:
qq5 float 10.0 ;x
qq6 float 10.0 ;y
qq7 float 10.0 ;z
qq8 float 0 ;directional source

.code

start:

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 500 ;hauteur
push 500 ;largeur
push 0 ;y
push 0 ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl ;<========= NOW!

;------------------------ the message loop ----------------------------------

winmain_msg_loop:

push 0
push 0
push handle_wd
callW InvalidateRect ;force paint

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl ;<========= NOW!

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
call disable_opengl
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite2
push offset rect_struct
push handle_wd
callW GetClientRect
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint
call draw_opengl
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite2:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:
push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;--------------------- prepare OpenGL ----------------------

;pre-build objects in a list to speed up the process

push 2 ;2 objects = 2 lists
callW glGenLists
mov objet1, eax

;-------- the cube (with normal, so lighting depends on light angle)

push 1300h ;GL_COMPILE
push objet1
callW glNewList ;first list

push 7 ;GL_QUADS
callW glBegin

;front face

push p1_0
push 0
push 0
callW glNormal3f ;normal points away from the viewer
push 0
push 0
push p1_0
callW glColor3f ;first corner color red
push p1_0
push p1_0
push p1_0
callW glVertex3f ;first corner coordz: top right
push 0
push p1_0
push 0
callW glColor3f ;second corner color green
push p1_0
push m1_0
push p1_0
callW glVertex3f ;second corner coordz: bottom right
push p1_0
push p1_0
push p1_0
callW glColor3f ;third corner color white
push p1_0
push m1_0
push m1_0
callW glVertex3f ;third corner coordz: bottom left
push p1_0
push 0
push p1_0
callW glColor3f ;fourth corner color pink
push p1_0
push p1_0
push m1_0
callW glVertex3f ;fourth corner coordz: top left

;left face

push 0
push 0
push p1_0
callW glNormal3f ;normal points to the right
push p1_0
push 0
push 0
callW glColor3f ;first corner color blue
push p1_0
push p1_0
push p1_0
callW glVertex3f ;first corner coordz: top front
push p1_0
push 0
push 0
callW glColor3f ;second corner color blue
push p1_0
push m1_0
push p1_0
callW glVertex3f ;second corner coordz: bottom front
push 0
push 0
push p1_0
callW glColor3f ;third corner color red
push m1_0
push m1_0
push p1_0
callW glVertex3f ;third corner coordz: bottom far
push 0
push 0
push p1_0
callW glColor3f ;fourth corner color red
push m1_0
push p1_0
push p1_0
callW glVertex3f ;fourth corner coordz: top far

callW glEnd
callW glEndList

;-------- the pyramid (no normals: no shadow effect)

mov eax, objet1
inc eax
mov objet2, eax ;second object handle

push 1300h ;GL_COMPILE
push objet2
callW glNewList ;second list

push 4 ;GL_TRIANGLE
callW glBegin

;front face red

push 0
push 0
push p1_0
callW glColor3f
push 0
push 0
push 0
callW glVertex3f
push 0
push p1_0
push 0
callW glVertex3f
push 0
push 0
push p1_0
callW glVertex3f

;right-back face blue

push p1_0
push 0
push 0
callW glColor3f
push 0
push p1_0
push 0
callW glVertex3f
push 0
push 0
push p1_0
callW glVertex3f
push m1_0
push 0
push 0
callW glVertex3f

;left face pink

push p1_0
push 0
push p1_0
callW glColor3f
push 0
push 0
push 0
callW glVertex3f
push m1_0
push 0
push 0
callW glVertex3f
push 0
push p1_0
push 0
callW glVertex3f

;bottom face white

push p1_0
push p1_0
push p1_0
callW glColor3f
push 0
push 0
push 0
callW glVertex3f
push 0
push 0
push p1_0
callW glVertex3f
push m1_0
push 0
push 0
callW glVertex3f
callW glEnd
callW glEndList

;others things

push 0
push 0
push 0
push 0
callW glClearColor

push 500
push 500
push 0
push 0
callW glViewport

push p1__0
callW glClearDepth
push 0b71h ;GL_DEPTH_TEST
callW glEnable
push 203h ;GL_LEQUAL
callW glDepthFunc
push 1102h ;GL_NICEST
push 0c50h ;GL_PERSPECTIVE_CORRECTION_HINT
callW glHint
push 1d01h ;GL_SMOOTH
callW glShadeModel
;push 0b44h ;GL_CULL_FACE
;callW glEnable ;Don't show faces when drawn counter clockwise

push 1701h ;GL_PROJECTION
callW glMatrixMode
callW glLoadIdentity

push pp10 ;zfar
push p4__0 ;znear
push p3__0 ;top
push m3__0 ;bottom
push p3__0 ;right
push m3__0 ;left
callW glFrustum
push 1700h ;GL_MODELVIEW
callW glMatrixMode
callW glLoadIdentity

push offset Light_Diffuse
push 1201h ;GL_DIFFUSE
push 4000h ;GL_LIGHT0
callW glLightfv

push offset Light_Position
push 1203h ;GL_POSITION
push 4000h ;GL_LIGHT0
callW glLightfv

push 0b57h ;GL_COLOR_MATERIAL
callW glEnable

ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

push 4000h+100h ;GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
callW glClear

;--- draw rotating rectangle on ze left

callW glLoadIdentity

push m6_0 ;z
push 0 ;y
push m1_5 ;x
callW glTranslatef

push 0
push p1_0
push 0
push angle
callW glRotatef

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable

push objet1
callW glCallList

;---- Draw rotating pyramid on the right

callW glLoadIdentity

push m5_0 ;z
push 0 ;y
push p2_0 ;x
callW glTranslatef

push p1_0
push p1_0
push p1_0
push angle
callW glRotatef

push p1_0
push 0
push 0
callW glColor3f
push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable

push objet2
callW glCallList

push theDC
callW SwapBuffers

fld angle
fadd increment ;increment angle
fstp angle

ret

end start


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


;----------OpenGL in win32asm example 3----------------
;
; draw some letters in 3D and rotate them
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
objet1 dd ?
objet2 dd ?
font dd ?
name_font db "Comic Sans MS",0
texte db "Mali"
texte_size equ $ - offset texte

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

float TYPEDEF REAL4
angle float 0.0
increment float 3.0
p0_1 float 0.1
m0_1 float -0.1
p0_5 float 0.5
m0_5 float -0.5
m0_8 float -0.8
p0_8 float 0.8
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m3_0 float -3.0
m3_5 float -3.5
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
m6_0 float -6.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m40 float -40.0
p40 float 40.0
p45 float 45.0

;-------- name some double precision float numbers ---------------------
; (NB: i may not use them all)

dfloat TYPEDEF REAL8
p0__1 dfloat 0.1
p0__5 dfloat 0.5
m0__5 dfloat -0.5
p1__0 dfloat 1.0
p1__33 dfloat 1.3333
p2__0 dfloat 2.0
p3__0 dfloat 3.0
m3__0 dfloat -3.0
p4__0 dfloat 4.0
p5__0 dfloat 5.0
m5__0 dfloat -5.0
p7__0 dfloat 7.0
pp10 dfloat 10.0
mm10 dfloat -10.0
pp20 dfloat 20.0
pp40 dfloat 40.0
pp45 dfloat 45.0

;-------- small structures with float numbers ---------------------

Light_Diffuse:
qq1 float 1.0 ;Red
qq2 float 1.0 ;Green
qq3 float 1.0 ;Blue
qq4 float 1.0 ;alpha?

Light_Position:
qq5 float 10.0 ;x
qq6 float 10.0 ;y
qq7 float 10.0 ;z
qq8 float 0 ;directional source

.code

start:

;----------------- enregistrer la wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 500 ;hauteur
push 500 ;largeur
push 0 ;y
push 0 ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl ;<========= NOW!

;---------------------- the message loop -----------------------------

winmain_msg_loop:
push 0
push 0
push handle_wd
callW InvalidateRect ;force paint?

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl ;<========= NOW!

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
call disable_opengl
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite3
push offset rect_struct
push handle_wd
callW GetClientRect
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint
call draw_opengl
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite3:
cmp wmsg, 100h ;WM_KEYDOWN?
jne suite4
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite4:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:

push 256
push objet1
callW glDeleteLists ;kill font

push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;--------------------- prepare OpenGL ----------------------

;pre-build font in 256 display lists

push 256
callW glGenLists
mov objet1, eax

push offset name_font
push 0+0 ;family and pitch FF_DONTCARE+DEFAULT_PITCH
push 4 ;output quality = ANTIALIASED_QUALITY
push 0 ;clipping precision = CLIP_DEFAULT_PRECIS
push 4 ;output precision = OUT_TT_PRECIS
push 0 ;character set identifier = ANSI_CHARSET
push 0 ;strikeout = FALSE
push 0 ;underline = FALSE
push 0 ;italic = FALSE
push 700h ;weight = FW_BOLD
push 0 ;orientation
push 0 ;angle
push 0 ;width
push -1 ;height
callW CreateFontA
mov font, eax

push font
push theDC
callW SelectObject

push 0 ;When lpgmf is NULL, no glyph metrics are returned
push 1 ;format = WGL_FONT_POLYGONS =1 , 0 = lines
push p0_1 ;thickness in float
push 0 ;deviation in float (nb of polygons in letter, 0 = best, but slooow)
push objet1
push 255 ;nb of display lists to build
push 0 ;starting character
push theDC
callW wglUseFontOutlinesA

;clear background and define window

push 0
push 0
push 0
push 0
callW glClearColor

push 500
push 500
push 0
push 0
callW glViewport

;set some parameters

push 0b57h ;GL_COLOR_MATERIAL
callW glEnable
push p1__0
callW glClearDepth
push 0b71h ;GL_DEPTH_TEST
callW glEnable
push 203h ;GL_LEQUAL
callW glDepthFunc
push 1102h ;GL_NICEST
push 0c50h ;GL_PERSPECTIVE_CORRECTION_HINT
callW glHint
push 1d01h ;GL_SMOOTH
callW glShadeModel
;push 0b44h ;GL_CULL_FACE
;callW glEnable ;Don't show faces when drawn counter clockwise

;define the eye parameters (position, perspective distortion)

push 1701h ;GL_PROJECTION
callW glMatrixMode

callW glLoadIdentity

push p4__0 ;zfar
push p1__0 ;znear
push p0__5 ;top
push m0__5 ;bottom
push p0__5 ;right
push m0__5 ;left
callW glFrustum

;define the object location

push 1700h ;GL_MODELVIEW
callW glMatrixMode

callW glLoadIdentity

push m3_0 ;angle ;z This time object coordz are defined at start
push 0 ;y And at each draw_opengl, we don't put the matrix
push 0 ;x back to zero with glLoadIdentity
callW glTranslatef

ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

callW glPushMatrix ;save position

;go a bit to the left so text is centered

push 0 ;z
push 0 ;y
push m1_0 ;x
callW glTranslatef

;define text properties

push 4000h+100h ;GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
callW glClear
push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push p0_5
push p1_0
push p0_5
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte_size
callW glCallLists

callW glPopAttrib

;now come back, from end of text, a bit to the left and behind the text

push m1_0 ;z
push 0 ;y
push m0_8 ;x
callW glTranslatef

;define rectangle properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 7 ;GL_QUADS
callW glBegin

;draw multicolor rectangle

push p1_0
push 0
push 0
callW glNormal3f ;pointe vers l'avant
push 0
push 0
push p1_0
callW glColor3f
push p0_5
push p0_5
push p0_5
callW glVertex3f
push 0
push p1_0
push p1_0
callW glColor3f
push p0_5
push m0_5
push p0_5
callW glVertex3f
push p1_0
push 0
push p1_0
callW glColor3f
push p0_5
push m0_5
push m0_5
callW glVertex3f
push p1_0
push 0
push 0
callW glColor3f
push p0_5
push p0_5
push m0_5
callW glVertex3f

callW glEnd

;pop initial position/orientation of the objects

callW glPopMatrix

;rotate the matrix a bit

push p1_0
push p1_0
push p1_0
push increment
callW glRotatef

push theDC
callW SwapBuffers

ret

end start


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


;----------OpenGL in win32asm example 4----------------
;
; draw some text in 3D do a StarWars like effect
; for the fun, define a non standart-shaped window
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
angle dd 0
objet1 dd ?
objet2 dd ?
font dd ?
name_font db "Comic Sans MS",0
texte1 db "Miserables"
texte1_size equ $ - offset texte1
texte2 db " by "
texte2_size equ $ - offset texte2
texte3 db " Victor "
texte3_size equ $ - offset texte3
texte4 db " and "
texte4_size equ $ - offset texte4
texte5 db " Hugo "
texte5_size equ $ - offset texte5

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

float TYPEDEF REAL4
position_z float -2.0
increment float 0.02
p0_1 float 0.1
m0_1 float -0.1
p0_5 float 0.5
m0_5 float -0.5
m0_8 float -0.8
p0_8 float 0.8
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m2_5 float -2.5
m3_0 float -3.0
m3_5 float -3.5
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
m6_0 float -6.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m40 float -40.0
p40 float 40.0
p45 float 45.0
m45 float -45.0
m60 float -60.0
m70 float -70.0
p90 float 90.0
m90 float -90.0

;-------- name some double precision float numbers ---------------------
; (NB: i may not use them all)

dfloat TYPEDEF REAL8
p0__1 dfloat 0.1
p0__5 dfloat 0.5
m0__5 dfloat -0.5
p1__0 dfloat 1.0
p1__33 dfloat 1.3333
p2__0 dfloat 2.0
p3__0 dfloat 3.0
m3__0 dfloat -3.0
p4__0 dfloat 4.0
p5__0 dfloat 5.0
m5__0 dfloat -5.0
p7__0 dfloat 7.0
pp10 dfloat 10.0
mm10 dfloat -10.0
pp20 dfloat 20.0
pp40 dfloat 40.0
pp45 dfloat 45.0

;-------- small structures with float numbers ---------------------

Light_Diffuse:
qq1 float 1.0 ;Red
qq2 float 1.0 ;Green
qq3 float 1.0 ;Blue
qq4 float 1.0 ;alpha?

Light_Position:
qq5 float 10.0 ;x
qq6 float 10.0 ;y
qq7 float 10.0 ;z
qq8 float 0 ;directional source

.code

start:

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 400 ;hauteur
push 800 ;largeur
push 100 ;y
push 0 ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;---------- define ellipsoidal window mask -------------------

push 395 ;y lower-right
push 790 ;x lower-right
push 30 ;y upper-left
push 10 ;x upper-left
callW CreateEllipticRgn ;return region handle

push 1 ;window redraw flag 1=true
push eax ;handle to region
push handle_wd
callW SetWindowRgn

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl

;--------------------- the message loop --------------------------

winmain_msg_loop:
push 0
push 0
push handle_wd
callW InvalidateRect ;force paint?

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
call disable_opengl
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite3

push offset rect_struct
push handle_wd
callW GetClientRect

mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint

call draw_opengl

mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite3:
cmp wmsg, 100h ;WM_KEYDOWN?
jne suite4
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite4:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:

push 256
push objet1
callW glDeleteLists ;kill font

push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;--------------------- prepare OpenGL ----------------------

;pre-build font in 256 display lists

push 256
callW glGenLists
mov objet1, eax

push offset name_font
push 0+0 ;family and pitch FF_DONTCARE+DEFAULT_PITCH
push 4 ;output quality = ANTIALIASED_QUALITY
push 0 ;clipping precision = CLIP_DEFAULT_PRECIS
push 4 ;output precision = OUT_TT_PRECIS
push 0 ;character set identifier = ANSI_CHARSET
push 0 ;strikeout = FALSE
push 0 ;underline = FALSE
push 0 ;italic = FALSE
push 700h ;weight = FW_BOLD
push 0 ;orientation
push 0 ;angle
push 0 ;width
push -1 ;height
callW CreateFontA
mov font, eax

push font
push theDC
callW SelectObject

push 0 ;When lpgmf is NULL, no glyph metrics are returned
push 1 ;format = WGL_FONT_POLYGONS =1 , 0 = lines
push p0_1 ;thickness in float
push p1_0 ;deviation in float (nb of polygons in letter, 0 = best, but slooow)
push objet1
push 255 ;nb of display lists to build
push 0 ;starting character
push theDC
callW wglUseFontOutlinesA

;clear background and define window

push 0
push 0
push 0
push 0
callW glClearColor

push 400
push 800
push 0
push 0
callW glViewport

;set some parameters

push 0b57h ;GL_COLOR_MATERIAL
callW glEnable
push p1__0
callW glClearDepth
push 0b71h ;GL_DEPTH_TEST
callW glEnable
push 203h ;GL_LEQUAL
callW glDepthFunc
push 1102h ;GL_NICEST
push 0c50h ;GL_PERSPECTIVE_CORRECTION_HINT (slower)
callW glHint
push 1d01h ;GL_SMOOTH
callW glShadeModel
push 0b44h ;GL_CULL_FACE
callW glEnable ;ne montre pas les faces quand dessinees ccw (faster)

;define the eye parameters (position, perspective distortion)

push 1701h ;GL_PROJECTION
callW glMatrixMode

callW glLoadIdentity

push pp40 ;zfar
push p1__0 ;znear
push p0__5 ;top
push m0__5 ;bottom
push p0__5 ;right
push m0__5 ;left
callW glFrustum

;define the object location/orientation

push 1700h ;GL_MODELVIEW
callW glMatrixMode

callW glLoadIdentity

push position_z ;z Cette fois on definit des le depart les coords de l'objet
push m2_0 ;y Et a chaque draw_opengl on ne remet pas la matrice a
push 0 ;x zero avec glLoadIdentity
callW glTranslatef

push 0
push 0
push p1_0
push m60
callW glRotatef

ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

callW glPushMatrix ;save position for the end - think like a Push EAX

;---- first line

;go a bit to the left so text is centered

push 0 ;z
push 0 ;y
push m2_0 ;x
callW glTranslatef

;define text properties

push 4000h+100h ;GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
callW glClear
push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push 0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte1
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte1_size
callW glCallLists

callW glPopAttrib

;---- second line

;go a bit to the left so text is centered

push m0_5 ;z
push m0_5 ;y
push m4_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte2
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte2_size
callW glCallLists

callW glPopAttrib

;---- third line

;go a bit to the left so text is centered

push p0_5 ;z
push m1_5 ;y
push m2_5 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push p1_0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte3
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte3_size
callW glCallLists

callW glPopAttrib

;---- line 4

;go a bit to the left so text is centered

push m0_5 ;z
push m0_5 ;y
push m4_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte4
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte4_size
callW glCallLists

callW glPopAttrib

;---- line 5

;go a bit to the left so text is centered

push p0_5 ;z
push m1_5 ;y
push m3_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push p1_0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte5
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte5_size
callW glCallLists

callW glPopAttrib

;pop initial position/orientation of the objects

callW glPopMatrix

;deplace the matrix a bit

push 0 ;z
push increment ;y
push 0 ;x
callW glTranslatef

push theDC
callW SwapBuffers

ret

end start


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

;----------OpenGL in win32asm example 5----------------
;
; draw some text in flat 3D do a StarWars like effect
; for the fun, make it full-screen
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
adresse_retour dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
objet1 dd ?
objet2 dd ?
font dd ?
name_font db "Comic Sans MS",0
texte1 db "Miserables"
texte1_size equ $ - offset texte1
texte2 db " by "
texte2_size equ $ - offset texte2
texte3 db " Victor "
texte3_size equ $ - offset texte3
texte4 db " and "
texte4_size equ $ - offset texte4
texte5 db " Hugo "
texte5_size equ $ - offset texte5
screenX dd ?
screenY dd ?

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

float TYPEDEF REAL4
position_z float -2.0
increment float 0.02
p0_1 float 0.1
m0_1 float -0.1
p0_5 float 0.5
m0_5 float -0.5
m0_8 float -0.8
p0_8 float 0.8
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m2_5 float -2.5
m3_0 float -3.0
m3_5 float -3.5
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
m6_0 float -6.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m40 float -40.0
p40 float 40.0
p45 float 45.0
m45 float -45.0
m60 float -60.0
m70 float -70.0
p90 float 90.0
m90 float -90.0

;-------- name some double precision float numbers ---------------------
; (NB: i may not use them all)

dfloat TYPEDEF REAL8
p0__1 dfloat 0.1
p0__5 dfloat 0.5
m0__5 dfloat -0.5
p1__0 dfloat 1.0
p1__33 dfloat 1.3333
p2__0 dfloat 2.0
p3__0 dfloat 3.0
m3__0 dfloat -3.0
p4__0 dfloat 4.0
p5__0 dfloat 5.0
m5__0 dfloat -5.0
p7__0 dfloat 7.0
pp10 dfloat 10.0
mm10 dfloat -10.0
pp20 dfloat 20.0
pp40 dfloat 40.0
pp45 dfloat 45.0

;-------- small structures with float numbers ---------------------

Light_Diffuse:
qq1 float 1.0 ;Red
qq2 float 1.0 ;Green
qq3 float 1.0 ;Blue
qq4 float 1.0 ;alpha?

Light_Position:
qq5 float 10.0 ;x
qq6 float 10.0 ;y
qq7 float 10.0 ;z
qq8 float 0 ;directional source

.code

start:

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;------------------- get screen size --------------------------------

push 0 ;SM_CXSCREEN
callW GetSystemMetrics
mov screenX, eax
push 1 ;SM_CYSCREEN
callW GetSystemMetrics
mov screenY, eax

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push screenY ;hauteur
push screenX ;largeur
push 0 ;y
push 0 ;x
push 80000000h+1000000h ;WS_POPUP
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl

;------------------------ the message loop ----------------------------------

winmain_msg_loop:
push 0
push 0
push handle_wd
callW InvalidateRect ;force paint?

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
call disable_opengl
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite3

push offset rect_struct
push handle_wd
callW GetClientRect

mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint

call draw_opengl

mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite3:
cmp wmsg, 100h ;WM_KEYDOWN?
jne suite4
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite4:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:

push 256
push objet1
callW glDeleteLists ;kill font

push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;--------------------- prepare OpenGL ----------------------

;pre-build font in 256 display lists

push 256
callW glGenLists
mov objet1, eax

push offset name_font
push 0+0 ;family and pitch FF_DONTCARE+DEFAULT_PITCH
push 4 ;output quality = ANTIALIASED_QUALITY
push 0 ;clipping precision = CLIP_DEFAULT_PRECIS
push 4 ;output precision = OUT_TT_PRECIS
push 0 ;character set identifier = ANSI_CHARSET
push 0 ;strikeout = FALSE
push 0 ;underline = FALSE
push 0 ;italic = FALSE
push 700h ;weight = FW_BOLD
push 0 ;orientation
push 0 ;angle
push 0 ;width
push -1 ;height
callW CreateFontA
mov font, eax

push font
push theDC
callW SelectObject

push 0 ;When lpgmf is NULL, no glyph metrics are returned
push 1 ;format = WGL_FONT_POLYGONS =1 , 0 = lines
push 0 ;p0_1 ;thickness in float
push p1_0 ;deviation in float (nb of polygons in letter, 0 = best, but slooow)
push objet1
push 255 ;nb of display lists to build
push 0 ;starting character
push theDC
callW wglUseFontOutlinesA

;clear background and define window

push 0
push 0
push 0
push 0
callW glClearColor

push screenY
push screenX
push 0
push 0
callW glViewport

;set some parameters

push 0b57h ;GL_COLOR_MATERIAL
callW glEnable
push p1__0
callW glClearDepth
push 0b71h ;GL_DEPTH_TEST
callW glEnable
push 203h ;GL_LEQUAL
callW glDepthFunc
push 1102h ;GL_NICEST
push 0c50h ;GL_PERSPECTIVE_CORRECTION_HINT (slower)
callW glHint
push 1d01h ;GL_SMOOTH
callW glShadeModel
push 0b44h ;GL_CULL_FACE
callW glEnable ;ne montre pas les faces quand dessinees ccw (faster)

;define the eye parameters (position, perspective distortion)

push 1701h ;GL_PROJECTION
callW glMatrixMode

callW glLoadIdentity

push pp40 ;zfar
push p1__0 ;znear
push p0__5 ;top
push m0__5 ;bottom
push p0__5 ;right
push m0__5 ;left
callW glFrustum

;define the object location/orientation

push 1700h ;GL_MODELVIEW
callW glMatrixMode

callW glLoadIdentity

push position_z ;z Cette fois on definit des le depart les coords de l'objet
push m2_0 ;y Et a chaque draw_opengl on ne remet pas la matrice a
push 0 ;x zero avec glLoadIdentity
callW glTranslatef

push 0
push 0
push p1_0
push m60
callW glRotatef

ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

callW glPushMatrix ;save position for the end - think like a Push EAX

;---- first line

;go a bit to the left so text is centered

push 0 ;z
push 0 ;y
push m2_0 ;x
callW glTranslatef

;define text properties

push 4000h+100h ;GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
callW glClear
push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push 0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte1
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte1_size
callW glCallLists

callW glPopAttrib

;---- second line

;go a bit to the left so text is centered

push m0_5 ;z
push m0_5 ;y
push m4_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte2
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte2_size
callW glCallLists

callW glPopAttrib

;---- third line

;go a bit to the left so text is centered

push p0_5 ;z
push m1_5 ;y
push m2_5 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push p1_0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte3
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte3_size
callW glCallLists

callW glPopAttrib

;---- line 4

;go a bit to the left so text is centered

push m0_5 ;z
push m0_5 ;y
push m4_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push 0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte4
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte4_size
callW glCallLists

callW glPopAttrib

;---- line 5

;go a bit to the left so text is centered

push p0_5 ;z
push m1_5 ;y
push m4_0 ;x
callW glTranslatef

;define text properties

push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable
push p1_0
push p1_0
push p1_0
callW glColor3f

;draw it

push 20000h ;GL_LIST_BIT
callW glPushAttrib

push objet1
callW glListBase

push offset texte5
push 1401h ;GL_UNSIGNED_BYTE parce que 0 < no de liste (=ASCII) < 255
push texte5_size
callW glCallLists

callW glPopAttrib

;pop initial position/orientation of the objects

callW glPopMatrix

;deplace the matrix a bit

push 0 ;z
push increment ;y
push 0 ;x
callW glTranslatef

push theDC
callW SwapBuffers

ret

end start

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - 


;----------OpenGL in win32asm example 6----------------
;
; draw an hypnotizing spiral in 2D (was done for Hybris)
; (it's actually a bit overkill to do 2D stuff in OpenGL)
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
adresse_retour dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
screenX dd ?
screenY dd ?

;--------- spiral data --------------

color dd 0ffffffffh
pen dd ?
compteur dd 110
hbit dd ?
hbrush dd ?

float TYPEDEF REAL4
angle1 float 0.0
angle2 float 1.0
angle3 float 3.1415926535
angle4 float 4.1415926535
angle_inc float 0.2
zoom float 0.01
zoom_reset float 0.01
zoom_inc float 0.01
angle_anim float 0.0
angle_anim_inc float 0.2
y1 float 0.0
x1 float 0.0
y2 float 0.0
x2 float 0.0
yy1 float 0.0
xx1 float 0.0
yy2 float 0.0
xx2 float 0.0
yyy1 float 0.0
xxx1 float 0.0
yyy2 float 0.0
xxx2 float 0.0
yyyy1 float 0.0
xxxx1 float 0.0
yyyy2 float 0.0
xxxx2 float 0.0

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

p0_1 float 0.1
m0_1 float -0.1
p0_5 float 0.5
m0_5 float -0.5
m0_8 float -0.8
p0_8 float 0.8
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m2_5 float -2.5
m3_0 float -3.0
m3_5 float -3.5
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
m6_0 float -6.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m40 float -40.0
p40 float 40.0
p45 float 45.0
m45 float -45.0
m60 float -60.0
m70 float -70.0
p90 float 90.0
m90 float -90.0

.code

start:

;------------------------- get screen size, center hypno -----------------

push 0 ;SM_CXSCREEN
callW GetSystemMetrics
sub eax, 600
shr eax, 1
mov screenX, eax

push 1 ;SM_CYSCREEN
callW GetSystemMetrics
sub eax, 600
shr eax, 1
mov screenY, eax

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 600 ;hauteur
push 600 ;largeur
push screenY ;y
push screenX ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;---------- define the circle-shaped window mask -------------------

push 590 ;y lower-right
push 590 ;x lower-right
push 30 ;y upper-left
push 10 ;x upper-left
callW CreateEllipticRgn ;return region handle

push 1 ;window redraw flag 1=true
push eax ;handle to region
push handle_wd
callW SetWindowRgn

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl

;------------------------ the message loop ----------------------------------

winmain_msg_loop:
push 0
push 0
push handle_wd
callW InvalidateRect ;force paint?

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
call disable_opengl
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite2
push offset rect_struct
push handle_wd
callW GetClientRect
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint
call draw_opengl
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite2:
cmp wmsg, 84h ;WM_NCHITEST (mouse click)
jne suite3
mov eax, 2 ;HTCAPTION (so you can move it with mouse)
jmp wndproc_end

suite3:
push lparam
push wparam
push wmsg
push hwnd

callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:
push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

;---- clear background

push 0 ;alpha
push 0 ;B
push p1_0 ;G
push p1_0 ;R
callW glClearColor

push 4000h ;GL_COLOR_BUFFER_BIT
callW glClear

;---- draw spirals

mov ecx, compteur
draw_two_spirals:
push ecx

;--- calculate coordinates of next point of the spiral 1

fld angle1 ;x
fcos
fld zoom
fmul
fstp x2

fld angle1 ;y
fsin
fld zoom
fmul
fstp y2

;--- calculate coordinates of next point of the spiral 2

fld angle2 ;x
fcos
fld zoom
fmul
fstp xx2

fld angle2 ;y
fsin
fld zoom
fmul
fstp yy2

;--- calculate coordinates of next point of the spiral 3

fld angle3 ;x
fcos
fld zoom
fmul
fstp xxx2

fld angle3 ;y
fsin
fld zoom
fmul
fstp yyy2

;--- calculate coordinates of next point of the spiral 4

fld angle4 ;x
fcos
fld zoom
fmul
fstp xxxx2

fld angle4 ;y
fsin
fld zoom
fmul
fstp yyyy2

;--- inc angle and thickness

fld angle1
fadd angle_inc
fstp angle1

fld angle2
fadd angle_inc
fstp angle2

fld angle3
fadd angle_inc
fstp angle3

fld angle4
fadd angle_inc
fstp angle4

fld zoom
fadd zoom_inc
fstp zoom

;---- draw the little piece of both spirals

push 7 ;GL_QUADS
callW glBegin

;spiral 1

push 0
push 0
push p1_0
callW glColor3f

push y1
push x1
callW glVertex2f

push y2
push x2
callW glVertex2f

;spiral 2

push yy1
push xx1
callW glVertex2f

push yy2
push xx2
callW glVertex2f

;spiral 3

push yyy1
push xxx1
callW glVertex2f

push yyy2
push xxx2
callW glVertex2f

;spiral 4

push yyyy1
push xxxx1
callW glVertex2f

push yyyy2
push xxxx2
callW glVertex2f

callW glEnd

;--- point p becomes point p-1 (spiral 1)

mov eax, x2
mov x1, eax
mov eax, y2
mov y1, eax

;--- point p becomes point p-1 (spiral 2)

mov eax, xx2
mov xx1, eax
mov eax, yy2
mov yy1, eax

;--- point p becomes point p-1 (spiral 3)

mov eax, xxx2
mov xxx1, eax
mov eax, yyy2
mov yyy1, eax

;--- point p becomes point p-1 (spiral 4)

mov eax, xxxx2
mov xxxx1, eax
mov eax, yyyy2
mov yyyy1, eax

;--- dec counter

pop ecx
dec ecx
jnz draw_two_spirals

push theDC
callW SwapBuffers

;--- reset the parameters for next spirals

mov x1, 0 ;first point back to center
mov y1, 0
mov xx1, 0 ;first point back to center
mov yy1, 0
mov xxx1, 0 ;first point back to center
mov yyy1, 0
mov xxxx1, 0 ;first point back to center
mov yyyy1, 0

fld angle_anim ;rotate next spirals a bit
fadd angle_anim_inc
fstp angle_anim

mov eax, angle_anim ;initialize the new starting angle for spiral 1
mov angle1, eax

fld p0_5 ;idem for spiral 2 but with 180 degrees (pi radians) shift
fadd angle_anim
fstp angle2

fldpi ;idem for spiral 3 but with 180 degrees (pi radians) shift
fadd angle_anim
fstp angle3

fldpi ;idem for spiral 4 but with 180 degrees (pi radians) shift
fadd p0_5
fadd angle_anim
fstp angle4

mov eax, zoom_reset ;reset the zoom level
mov zoom, eax

ret

end start

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

;----------OpenGL in win32asm example 7----------------
;
; draw a complex 3D object (a face) and smooth-shade it
; push 1/2 for x rotation
; push 3/4 for y rotation
; push 5/6 for z rotation
; push 7/8 for distance
; push 9 to see the effect of averaging normals at each vertex:
; - left semi-face uses polygon normals for flat shading
; - right semi-face uses averaged vertex normas for smooth shading
;
; not at all optimized, it's better for code clarity
; by Spanska for Xine#5, February 2001, copyleft
;
; TASM32 /ml /m3 /z /t opengl
; TLINK32 -Tpe -aa opengl,,,import32 opengl32

callW macro x
extrn x:PROC
call x
endm

.386p
.model flat,STDCALL

.data

;------------- funky structures ---------------------

paint_struct:
pshdc dd ?
psfErase dd 0
psrcPaint dd offset rect_struct
psfRestore dd ?
psfIncUpdate dd ?
psrgbReserved db 32 dup(?)

rect_struct:
rcLeft dd ?
rcTop dd ?
rcRight dd ?
rcBottom dd ?

wndclassx:
clscbSize dd wndclassx_size
clsStyle dd 20h+2+1 ; class style CS_OWNDC+CS_VREDRAW+CS_HREDRAW
clsLpfnWndProc dd ?
clsCbClsExtra dd 0
clsCbWndExtra dd 0
clsHInstance dd ? ; instance handle
clsHIcon dd 0 ; class icon handle
clsHCursor dd 0 ; class cursor handle
clsHbrBackground dd 7 ; class background brush
clsLpszMenuName dd 0 ; menu name
clsLpszClassName dd ? ; far ptr to class name
clshIconSm dd 0
wndclassx_size equ $-offset wndclassx

msg:
msHWND dd ?
msMESSAGE dd ?
msWPARAM dd ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?

DDPIXELFORMAT_struct:
pfd_nSize dw 0
pfd_nVersion dw 0
pfd_dwFlags dd 0
pfd_iPixelType db 0
pfd_cColorBits db 0
pfd_cRedBits db 0
pfd_cRedShift db 0
pfd_cGreenBits db 0
pfd_cGreenShift db 0
pfd_cBlueBits db 0
pfd_cBlueShift db 0
pfd_cAlphaBits db 0
pfd_cAlphaShift db 0
pfd_cAccumBits db 0
pfd_cAccumRedBits db 0
pfd_cAccumGreenBits db 0
pfd_cAccumBlueBits db 0
pfd_cAccumAlphaBits db 0
pfd_cDepthBits db 0
pfd_cStencilBits db 0
pfd_cAuxBuffers db 0
pfd_iLayerType db 0
pfd_bReserved db 0
pfd_dwLayerMask dd 0
pfd_dwVisibleMask dd 0
pfd_dwDamageMask dd 0
DDPIXELFORMAT_struct_size equ $-offset DDPIXELFORMAT_struct

;------------- some data ---------------------

nom_fenetre db "OpenGL",0
handle dd ?
handle_wd dd ?
adresse_retour dd ?
pixformat dd ?
theDC dd ?
theRC dd ?
angle dd 0

;--------- data that can be changed with keyboard ------------

float TYPEDEF REAL4
inc_angle float 1.0
cur_anglex float 0
cur_angley float 0
cur_anglez float 0
inc_distance float 0.2
cur_distance float -20.0
smooth_or_flat dd 0

;-------- name some simple precision float numbers ---------------------
; (NB: i may not use them all)

p0_1 float 0.1
p0_5 float 0.5
m0_5 float -0.5
p1_0 float 1.0
m1_0 float -1.0
p1_3 float 1.333333333
m1_4 float -1.4
m1_5 float -1.5
p1_5 float 1.5
p1_6 float 1.6
p1_7 float 1.7
p1_8 float 1.8
p1_85 float 1.85
p1_9 float 1.9
p2_0 float 2.0
m2_0 float -2.0
m3_0 float -3.0
p3_0 float 3.0
m4_0 float -4.0
p4_0 float 4.0
m5_0 float -5.0
p5_0 float 5.0
p6_0 float 6.0
m6_0 float -6.0
p7_0 float 7.0
p8_0 float 8.0
m8_0 float -8.0
p10 float 10.0
m10 float -10.0
m15 float -15.0
p20 float 20.0
m40 float -40.0
p40 float 40.0
p45 float 45.0
p99 float 99.0

;-------- name some double precision float numbers ---------------------
; (NB: i may not use them all)

dfloat TYPEDEF REAL8
p0__1 dfloat 0.1
p1__0 dfloat 1.0
m1__0 dfloat -1.0
p1__33 dfloat 1.3333
p2__0 dfloat 2.0
m2__0 dfloat -2.0
p3__0 dfloat 3.0
m3__0 dfloat -3.0
p4__0 dfloat 4.0
m4__0 dfloat -4.0
p5__0 dfloat 5.0
m5__0 dfloat -5.0
p7__0 dfloat 7.0
pp10 dfloat 10.0
mm10 dfloat -10.0
pp20 dfloat 20.0
pp30 dfloat 30.0
pp40 dfloat 40.0
pp45 dfloat 45.0

;-------- small structures with float numbers ---------------------

Light_Diffuse:
qq1 float 0.2 ;Red
qq2 float 0.2 ;Green
qq3 float 0.2 ;Blue
qq4 float 1.0 ;alpha

Light_Position:
qq5 float 0.0 ;x
qq6 float 0.0 ;y
qq7 float 10.0 ;z
qq8 float 0 ;directional source

mat_Ambient float 1.0,0.01,0.01,1.0
mat_Diffuse float 1.0,0.01,0.01,1.0
mat_Specular float 0.5,0.5,0.5,1.0
mat_Shine float 5.0

;-------- data to construct the face ---------------------

include index.asm ;index of polygons
include faceline.asm ;coordz of vertex

index_1 dd ?
index_2 dd ?
index_3 dd ?
index_4 dd ?

x1 dd ?
y1 dd ?
z1 dd ?
x2 dd ?
y2 dd ?
z2 dd ?
x3 dd ?
y3 dd ?
z3 dd ?

normal_x dd ?
normal_y dd ?
normal_z dd ?
longueur dd ?
v1normal_x dd ?
v1normal_y dd ?
v1normal_z dd ?
v2normal_x dd ?
v2normal_y dd ?
v2normal_z dd ?
v3normal_x dd ?
v3normal_y dd ?
v3normal_z dd ?

table_faces_normals dd ?
current_pointer_facettes dd ?
current_pointer_normals dd ?

a dd ?
b dd ?
c dd ?
anx1 dd 0
any1 dd 0
anz1 dd 0
anx2 dd 0
any2 dd 0
anz2 dd 0
anx3 dd 0
any3 dd 0
anz3 dd 0

.code

start:

;------------- get memory for the big table ---------------------
; table = 441 faces * (24 dd)
; these 24 dd are:
; index123,xyz1,xyz2,xyz3,normalxyz,an1xyz,an2xyz,an3xyz

mov eax, 441*(24*4)
add eax, 1024 ;just in case
push eax ;number of bytes to allocate
push 40h ;40h=LMEM_ZEROINIT
callW LocalAlloc
mov table_faces_normals, eax

;---------------- pre-calculate everything -----------------------
; - normals of each triangle first, we could stop here for flat shading
; - using these, calculate average normals for each vertex, needed for smooth shading

mov ecx, 441
mov esi, offset facettes
mov eax, table_faces_normals
mov current_pointer_normals, eax

;--- get indexes of the current polygon

get_indexes:
xor eax, eax
lodsb ; index no 1
dec al
mov index_1, eax
xor eax, eax
lodsb ; index no 2
dec al
mov index_2, eax
xor eax, eax
lodsb ; index no 3
dec al
mov index_3, eax

pusha

;--- using these indexes, get xyz of the three vertexes (corners)

mov esi, offset coords ;esi at start of coordz table
mov eax, index_1 ;eax = index of first coordz
mov ebx, 12
mul ebx ;1 index = 3 coordz of 4 bytes
add esi, eax
lodsd ;get x
mov x1, eax
lodsd ;get y
mov y1, eax
lodsd ;get z
mov z1, eax

mov esi, offset coords ;same for second vertex
mov eax, index_2
mov ebx, 12
mul ebx
add esi, eax
lodsd
mov x2, eax
lodsd
mov y2, eax
lodsd
mov z2, eax

mov esi, offset coords ;same for second vertex
mov eax, index_3
mov ebx, 12
mul ebx
add esi, eax
lodsd
mov x3, eax
lodsd
mov y3, eax
lodsd
mov z3, eax

;-- now use these coordz to calculate normals (xyz) of each polygon

;coa = -(py1 * (pz2-pz3) + py2*(pz3-pz1) + py3*(pz1-pz2))

fld z2
fsub z3
fmul y1
fld z3
fsub z1
fmul y2
fld z1
fsub z2
fmul y3
fadd
fadd
fchs
fstp normal_x ;save it

;cob = -(pz1 * (px2-px3) + pz2*(px3-px1) + pz3*(px1-px2))

fld x2
fsub x3
fmul z1
fld x3
fsub x1
fmul z2
fld x1
fsub x2
fmul z3
fadd
fadd
fchs
fstp normal_y ;save it

;coc = -(px1 * (py2-py3) + px2*(py3-py1) + px3*(py1-py2))

fld y2
fsub y3
fmul x1
fld y3
fsub y1
fmul x2
fld y1
fsub y2
fmul x3
fadd
fadd
fchs
fstp normal_z ;save it

;--- calculate the length of the normal
;absvec = sqrt ((double) ((coa*coa) + (cob*cob) + (coc*coc)))
; not useful actually because glNormalize will take care of that
; maybe speed difference, but i didn't noticed

fld normal_x
fmul normal_x
fld normal_y
fmul normal_y
fld normal_z
fmul normal_z
fadd
fadd
fsqrt
fstp longueur

;--- normalize this length to 1
; we divide each xyz component by the length of the normal vector
; not useful actually because glNormalize will take care of that
; maybe speed difference, but i didn't noticed

; norm[0] = coa/absvec

fld normal_x
fdiv longueur
fstp normal_x

; norm[1] = cob/absvec

fld normal_y
fdiv longueur
fstp normal_y

; norm[2] = coc/absvec

fld normal_z
fdiv longueur
fstp normal_z

;--- put all the stuff in the big table
; This table has the data for 441 polygons.
; for each polygon we have:
; dd index1,index2,index3,x1,y1,z1,x2,y2,z2,x3,y3,z3,nx,ny,nz,an1xyz,an2xyz,an3xyz
; see above for a clearer structure

mov edi, current_pointer_normals
mov eax, index_1
stosd
mov eax, index_2
stosd
mov eax, index_3
stosd
mov eax, x1
stosd
mov eax, y1
stosd
mov eax, z1
stosd
mov eax, x2
stosd
mov eax, y2
stosd
mov eax, z2
stosd
mov eax, x3
stosd
mov eax, y3
stosd
mov eax, z3
stosd
mov eax, normal_x
stosd
mov eax, normal_y
stosd
mov eax, normal_z
stosd
xor eax, eax ;stuff we still need to calculate (averaged normals)
stosd ;so fill with zeros
stosd
stosd
stosd
stosd
stosd
stosd
stosd
stosd
mov current_pointer_normals, edi

popa

dec ecx
jnz get_indexes

;ok so here we have one big table of 441 faces * 24 dd :
;
;dd index1, index2, index3
;dd x1, y1, z1
;dd x2, y2, z2
;dd x3, y3, z3
;dd normalx, normaly, normalz
;dd averagednormalx1, averagednormaly1, averagednormalz1 <= need to calculate them now
;dd averagednormalx2, averagednormaly2, averagednormalz2 <= need to calculate them now
;dd averagednormalx3, averagednormaly3, averagednormalz3 <= need to calculate them now

;--- calculate the averaged normals to smooth the light

; we have to find which polygons share a vertex, and then
; calculate the average normal at this vertex.

;loop1: for each face, put index1, index2, index3 in 3 variables a b c
; now start again from beginning of the table
; loop2: check if "a" matches one of the 3 indexes
; if yes, go to the normals, add them to 3 variables anx1, any1, anz1
; same for b and c
; continue loop2
; to avoid bad shadowing in the middle, between 2 semi-faces:
; if x1=0 then anx=0 ; if x2=0...
;put anx, any, anz in the averaged normal of the current face
;loop1

mov ecx, 441
mov esi, table_faces_normals

loop1:

lodsd ; get the 3 indexes and put them in a temp location
mov a, eax
lodsd
mov b, eax
lodsd
mov c, eax
add esi, (24*4)-12
mov edi, esi
sub edi, (3*4)*3

pusha

mov ecx, 441
mov esi, table_faces_normals
xor eax, eax ; clean the temp variables
mov anx1, eax
mov any1, eax
mov anz1, eax
mov anx2, eax
mov any2, eax
mov anz2, eax
mov anx3, eax
mov any3, eax
mov anz3, eax

loop2:
@0: ;check if other polygons share the first vertex
lodsd
cmp eax, a
jne @1
fld dword ptr [esi+44] ;normal_x
fadd anx1
fstp anx1
fld dword ptr [esi+48] ;normal_y
fadd any1
fstp any1
fld dword ptr [esi+52] ;normal_z
fadd anz1
fstp anz1
@1: ;check if other polygons share the second vertex
cmp eax, b
jne @2
fld dword ptr [esi+44] ;normal_x
fadd anx2
fstp anx2
fld dword ptr [esi+48] ;normal_y
fadd any2
fstp any2
fld dword ptr [esi+52] ;normal_z
fadd anz2
fstp anz2
@2: ;check if other polygons share the third vertex
cmp eax, c
jne @3
fld dword ptr [esi+44] ;normal_x
fadd anx3
fstp anx3
fld dword ptr [esi+48] ;normal_y
fadd any3
fstp any3
fld dword ptr [esi+52] ;normal_z
fadd anz3
fstp anz3

@3: ;check if other polygons share the first vertex
lodsd
cmp eax, a
jne @4
fld dword ptr [esi+40] ;normal_x
fadd anx1
fstp anx1
fld dword ptr [esi+44] ;normal_y
fadd any1
fstp any1
fld dword ptr [esi+48] ;normal_z
fadd anz1
fstp anz1
@4: ;check if other polygons share the second vertex
cmp eax, b
jne @5
fld dword ptr [esi+40] ;normal_x
fadd anx2
fstp anx2
fld dword ptr [esi+44] ;normal_y
fadd any2
fstp any2
fld dword ptr [esi+48] ;normal_z
fadd anz2
fstp anz2
@5: ;check if other polygons share the third vertex
cmp eax, c
jne @6
fld dword ptr [esi+40] ;normal_x
fadd anx3
fstp anx3
fld dword ptr [esi+44] ;normal_y
fadd any3
fstp any3
fld dword ptr [esi+48] ;normal_z
fadd anz3
fstp anz3

@6: ;check if other polygons share the first vertex
lodsd
cmp eax, a
jne @7
fld dword ptr [esi+36] ;normal_x
fadd anx1
fstp anx1
fld dword ptr [esi+40] ;normal_y
fadd any1
fstp any1
fld dword ptr [esi+44] ;normal_z
fadd anz1
fstp anz1
@7: ;check if other polygons share the second vertex
cmp eax, b
jne @8
fld dword ptr [esi+36] ;normal_x
fadd anx2
fstp anx2
fld dword ptr [esi+40] ;normal_y
fadd any2
fstp any2
fld dword ptr [esi+44] ;normal_z
fadd anz2
fstp anz2
@8: ;check if other polygons share the third vertex
cmp eax, c
jne @9
fld dword ptr [esi+36] ;normal_x
fadd anx3
fstp anx3
fld dword ptr [esi+40] ;normal_y
fadd any3
fstp any3
fld dword ptr [esi+44] ;normal_z
fadd anz3
fstp anz3
@9:
add esi, (24*4)-12

end_loop2:
dec ecx
jnz loop2

popa

;--- small trick to avoid bad smoothing along the 2 semi-faces
;
;here esi = next struct, edi = current anx1
;small routine to smooth the shadow between 2 semi-faces
;ie all triangles touching the frontier (x=0) have their normal X=0

cmp dword ptr [esi-(21*4)], 0 ;x1
jne buzzz1
mov anx1, 0
buzzz1:
cmp dword ptr [esi-(18*4)], 0 ;x2
jne buzzz2
mov anx2, 0
buzzz2:
cmp dword ptr [esi-(15*4)], 0 ;x3
jne buzzz3
mov anx3, 0
buzzz3:

;--- put calculated averaged normals at each vertex in the table

mov eax, anx1
stosd
mov eax, any1
stosd
mov eax, anz1
stosd
mov eax, anx2
stosd
mov eax, any2
stosd
mov eax, anz2
stosd
mov eax, anx3
stosd
mov eax, any3
stosd
mov eax, anz3
stosd

dec ecx
jnz loop1

;----------------- OK, now normal windows stuph ---------------------

;----------------- register wndclass ----------------------------

push 0
callW GetModuleHandleA
mov handle, eax

mov clsHInstance, eax
mov eax, offset wndproc
mov clsLpfnWndProc, eax
mov clsLpszClassName, offset nom_fenetre

push offset wndclassx
callW RegisterClassExA

;--------------------- create the window --------------------------

push 0
push handle
push 0
push 0 ;HWND_DESKTOP
push 500 ;hauteur
push 500 ;largeur
push 0 ;y
push 0 ;x
push 0CF0000h+4000000h+2000000h ;WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_CLIPCHILDREN
push offset nom_fenetre
push offset nom_fenetre
push 0 ;extra style
callW CreateWindowExA
mov handle_wd, eax

;------------------------ show window ------------------------------

push 1
push handle_wd
callW ShowWindow

push handle_wd
callW UpdateWindow

call enable_opengl

;------------------------ the message loop ----------------------------------

winmain_msg_loop:
push 0
push 0
push handle_wd
callW InvalidateRect ;force paint?

push 1
push 0
push 0
push 0
push offset msg
callW PeekMessageA
cmp eax, 0
jnz process_messages

jmp winmain_msg_loop

;----- check if window is closed --------

process_messages:

cmp msMESSAGE, 12h ;WM_QUIT equ 0012h
je end_loop

push offset msg
callW TranslateMessage
push offset msg
callW DispatchMessageA
jmp winmain_msg_loop

end_loop:

call disable_opengl

push table_faces_normals
callW LocalFree

push msWPARAM
callW ExitProcess

;------------------ windows proc ------------------------

wndproc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

cmp wmsg,2 ;WM_DESTROY?
jne suite1
push 0
callW PostQuitMessage
xor eax, eax
jmp wndproc_end

suite1:
cmp wmsg, 0fh ;WM_PAINT?
jne suite3
push offset rect_struct
push handle_wd
callW GetClientRect
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW BeginPaint
call draw_opengl
mov eax, theDC
mov pshdc, eax
push offset paint_struct
push handle_wd
callW EndPaint
xor eax, eax
jmp wndproc_end

suite3:
cmp wmsg, 102h ;WM_CHAR?
jne suite4 ;stuff for keyboard control
;i should have done that with the mouse
cmp wparam, "1" ;but too late: T00fic is gonna kill me
jne __suite1 ;if i ask more time :)
fld cur_anglex
fadd inc_angle
fstp cur_anglex
jmp fin_test_clavier
__suite1:
cmp wparam, "2"
jne __suite2
fld cur_anglex
fsub inc_angle
fstp cur_anglex
jmp fin_test_clavier
__suite2:
cmp wparam, "3"
jne __suite3
fld cur_angley
fadd inc_angle
fstp cur_angley
jmp fin_test_clavier
__suite3:
cmp wparam, "4"
jne __suite4
fld cur_angley
fsub inc_angle
fstp cur_angley
jmp fin_test_clavier
__suite4:
cmp wparam, "5"
jne __suite5
fld cur_anglez
fadd inc_angle
fstp cur_anglez
jmp fin_test_clavier
__suite5:
cmp wparam, "6"
jne __suite6
fld cur_anglez
fsub inc_angle
fstp cur_anglez
jmp fin_test_clavier
__suite6:
cmp wparam, "7"
jne __suite7
fld cur_distance
fadd inc_distance
fstp cur_distance
jmp fin_test_clavier
__suite7:
cmp wparam, "8"
jne __suite8
fld cur_distance
fsub inc_distance
fstp cur_distance
jmp fin_test_clavier
__suite8:
cmp wparam, "9"
jne __suite9
xor smooth_or_flat,0ffh
jmp fin_test_clavier
__suite9:

fin_test_clavier:
xor eax, eax
jmp wndproc_end

suite4:
push lparam
push wparam
push wmsg
push hwnd
callW DefWindowProcA

wndproc_end:
ret
wndproc endp

;--------------------- disable OpenGL ----------------------

disable_opengl:
push 0
push 0
callW wglMakeCurrent

push theRC
callW wglDeleteContext

push theDC
push handle_wd
callW ReleaseDC

ret

;--------------------- enable OpenGL for window -----------------------------------

enable_opengl:

push handle_wd
callW GetDC
mov theDC, eax

mov pfd_nSize, DDPIXELFORMAT_struct_size
mov pfd_nVersion, 1
mov pfd_dwFlags, 20h+1+4 ;PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
mov pfd_dwLayerMask, 0 ;PFD_MAIN_PLANE
mov pfd_iPixelType, 0 ;PFD_TYPE_RGBA
mov pfd_cColorBits, 24
mov pfd_cDepthBits, 16
mov pfd_cAccumBits, 0
mov pfd_cStencilBits, 0
push offset DDPIXELFORMAT_struct
push theDC
callW ChoosePixelFormat
mov pixformat, eax

push offset DDPIXELFORMAT_struct
push pixformat
push theDC
callW SetPixelFormat ;once you call this, td32 becomes crazy?

push theDC
callW wglCreateContext
mov theRC, eax

push theRC
push theDC
callW wglMakeCurrent

;--------------------- prepare OpenGL ----------------------

push 0
push 0
push 0
push 0
callW glClearColor

push 500
push 500
push 0
push 0
callW glViewport

push p1__0
callW glClearDepth
push 0b71h ;GL_DEPTH_TEST
callW glEnable
push 203h ;GL_LEQUAL
callW glDepthFunc
push 1102h ;GL_NICEST
push 0c50h ;GL_PERSPECTIVE_CORRECTION_HINT
callW glHint
push 1d01h ;GL_SMOOTH
callW glShadeModel
push 0b44h ;GL_CULL_FACE
callW glEnable ;don't show faces when drawn ccw

push 1701h ;GL_PROJECTION
callW glMatrixMode
callW glLoadIdentity

push pp30 ;zfar
push p4__0 ;znear
push p3__0 ;top
push m3__0 ;bottom
push p3__0 ;right
push m3__0 ;left
callW glFrustum
push 1700h ;GL_MODELVIEW
callW glMatrixMode
callW glLoadIdentity

push offset Light_Diffuse
push 1201h ;GL_DIFFUSE
push 4000h ;GL_LIGHT0
callW glLightfv

push offset Light_Position
push 1203h ;GL_POSITION
push 4000h ;GL_LIGHT0
callW glLightfv

push 0b57h ;GL_COLOR_MATERIAL
callW glEnable

push 0ba1h ;GL_NORMALIZE let OpenGL normalize normal length (=1)
callW glEnable ;so we don't have to do it; slower but don't care
;because we precalculate everything before drawing
ret

;--------------------- calculate, draw, eat cpu time... ----------------------

draw_opengl:

push 4000h+100h ;GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
callW glClear

;---- Draw

callW glLoadIdentity

push cur_distance ;translate z axis
push 0
push 0
callW glTranslatef

push 0
push 0
push p1_0 ;rotate x axis
push cur_anglex
callW glRotatef
push 0
push p1_0 ;rotate y axis
push 0
push cur_angley
callW glRotatef
push p1_0 ;rotate z axis
push 0
push 0
push cur_anglez
callW glRotatef

push p1_0
push p1_0
push p1_0
callW glColor3f
push 0b50h ;GL_LIGHTING
callW glEnable
push 4000h ;GL_LIGHT0
callW glEnable

push 4 ;GL_TRIANGLES
callW glBegin

push offset mat_Ambient
push 1200h ;GL_AMBIENT
push 404h ;GL_FRONT
callW glMaterialfv
push offset mat_Diffuse
push 1201h ;GL_DIFFUSE
push 404h ;GL_FRONT
callW glMaterialfv
push offset mat_Specular
push 1202h ;GL_SPECULAR
push 404h ;GL_FRONT
callW glMaterialfv
push offset mat_Shine
push 1601h ;GL_SHININESS
push 404h ;GL_FRONT
callW glMaterialfv

;As a reminder: we have one big table of 441 faces * 24 dd :
;
;dd index1, index2, index3
;dd x1, y1, z1
;dd x2, y2, z2
;dd x3, y3, z3
;dd normalx, normaly, normalz
;dd averagednormalx1, averagednormaly1, averagednormalz1
;dd averagednormalx2, averagednormaly2, averagednormalz2
;dd averagednormalx3, averagednormaly3, averagednormalz3

;--- Draw these fucking 441 polygons at once

mov ecx, 441
mov esi, table_faces_normals

draw_them_all_at_once:
push ecx

;--- get everything we need in the table

add esi, 12
lodsd
mov x1, eax
lodsd
mov y1, eax
lodsd
mov z1, eax
lodsd
mov x2, eax
lodsd
mov y2, eax
lodsd
mov z2, eax
lodsd
mov x3, eax
lodsd
mov y3, eax
lodsd
mov z3, eax
lodsd
mov normal_x, eax
lodsd
mov normal_y, eax
lodsd
mov normal_z, eax
lodsd
mov anx1, eax
lodsd
mov any1, eax
lodsd
mov anz1, eax
lodsd
mov anx2, eax
lodsd
mov any2, eax
lodsd
mov anz2, eax
lodsd
mov anx3, eax
lodsd
mov any3, eax
lodsd
mov anz3, eax

;--- at least, draw the shit

cmp smooth_or_flat, 0
je smooth_shading

; flat shade half of the face

flat_shading:

push normal_z ;use not the averaged normals at each vertex
push normal_y ;but the polygon normal => each polygon becomes
push normal_x ;very visible and flat
callW glNormal3f
push z2
push y2
push x2
callW glVertex3f
push z1
push y1
push x1
callW glVertex3f
push z3
push y3
push x3
callW glVertex3f

jmp end_smooth

; smooth shade half of the face

smooth_shading:

push anz2
push any2
push anx2
callW glNormal3f
push z2
push y2
push x2
callW glVertex3f

push anz1
push any1
push anx1
callW glNormal3f
push z1
push y1
push x1
callW glVertex3f

push anz3
push any3
push anx3
callW glNormal3f
push z3
push y3
push x3
callW glVertex3f

end_smooth:

;--- mirror second half-face by inverting all x coordinates (symetric by y,z plan)

fld x1
fchs
fstp x1
fld x2
fchs
fstp x2
fld x3
fchs
fstp x3
fld anx1
fchs
fstp anx1
fld anx2
fchs
fstp anx2
fld anx3
fchs
fstp anx3

fld normal_x
fchs
fstp normal_x

;--- draw second semi-face, always smoothed

push anz1
push any1
push anx1
callW glNormal3f
push z1
push y1
push x1
callW glVertex3f

push anz2
push any2
push anx2
callW glNormal3f
push z2
push y2
push x2
callW glVertex3f

push anz3
push any3
push anx3
callW glNormal3f
push z3
push y3
push x3
callW glVertex3f

pop ecx
dec ecx
jnz draw_them_all_at_once

callW glEnd

push theDC
callW SwapBuffers

ret

end start

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

File: index.inc

facettes:
db 1,2,5
db 1,5,4
db 2,3,6
db 2,6,5
db 7,4,5
db 7,5,8
db 8,5,6
db 8,6,9
db 11,8,9
db 10,7,8
db 10,8,11
db 6,3,14
db 6,14,13
db 9,6,13
db 9,13,12
db 11,9,12
db 11,12,17
db 11,17,18
db 12,13,16
db 12,16,17
db 13,14,15
db 13,15,16
db 16,15,25
db 16,25,24
db 16,24,23
db 17,16,23
db 17,23,22
db 18,17,22
db 18,22,21
db 19,11,18
db 20,19,18
db 20,18,21
db 24,25,26
db 24,26,27
db 23,24,27
db 23,27,28
db 22,23,28
db 22,28,29
db 21,22,29
db 21,29,30
db 32,20,21
db 32,21,31
db 31,21,30
db 31,30,35
db 35,30,29
db 35,29,36
db 29,28,37
db 29,37,36
db 28,27,38
db 28,38,37
db 27,26,39
db 27,39,38
db 38,39,40
db 38,40,41
db 37,38,41
db 37,41,42
db 36,37,42
db 36,42,43
db 35,36,43
db 35,43,44
db 34,31,35
db 34,35,44
db 33,32,31
db 33,31,34
db 45,33,34
db 45,34,46
db 46,34,44
db 46,44,47
db 47,44,43
db 47,43,48
db 48,43,42
db 48,42,49
db 42,41,50
db 42,50,49
db 41,40,51
db 41,51,50
db 50,51,64
db 50,64,63
db 49,50,63
db 49,63,62
db 48,49,62
db 48,62,61
db 47,48,61
db 63,64,65
db 63,65,66
db 66,65,77
db 66,77,76
db 67,66,76
db 67,76,75
db 62,63,66
db 62,66,67
db 73,67,75
db 73,75,74
db 68,62,67
db 68,67,73
db 60,61,62
db 60,62,68
db 52,47,61
db 52,61,60
db 53,46,47
db 53,47,52
db 54,45,46
db 54,46,53
db 55,54,53
db 55,53,56
db 58,55,56
db 58,56,57
db 56,53,52
db 56,52,57
db 58,57,59
db 57,52,60
db 57,60,59
db 58,59,69
db 58,69,70
db 59,60,68
db 59,68,69
db 70,69,72
db 70,72,71
db 69,68,73
db 69,73,72
db 72,73,74
db 58,146,55
db 146,145,54
db 146,54,55
db 145,144,45
db 145,45,54
db 144,142,45
db 142,141,33
db 142,33,45
db 141,98,32
db 141,32,33
db 98,97,20
db 98,20,32
db 97,89,19
db 97,12,20
db 89,87,19
db 19,87,11
db 87,88,10
db 87,10,11
db 87,85,86
db 87,86,88
db 87,84,85
db 84,81,82
db 84,82,85
db 85,82,83
db 85,83,86
db 81,80,79
db 81,79,82
db 82,79,78
db 82,78,83
db 89,90,84
db 89,84,87
db 90,91,81
db 90,81,84
db 91,92,80
db 91,80,81
db 94,93,92
db 94,92,91
db 95,94,91
db 96,95,91
db 96,91,90
db 97,96,90
db 97,90,89
db 98,99,96
db 98,96,97
db 99,100,95
db 99,95,96
db 100,101,102
db 100,102,95
db 102,103,94
db 102,94,95
db 103,104,93
db 103,93,94
db 106,105,104
db 106,104,103
db 102,106,103
db 107,106,102
db 109,101,100
db 110,109,100
db 111,110,100
db 111,100,112
db 111,117,118
db 111,118,110
db 110,118,108
db 110,108,109
db 118,119,107
db 118,107,109
db 119,120,106
db 119,106,107
db 120,121,105
db 120,105,106
db 123,122,121
db 123,121,120
db 124,123,120
db 124,120,119
db 117,124,119
db 117,119,118
db 115,116,117
db 115,117,111
db 113,112,100
db 113,100,99
db 141,113,99
db 141,99,98
db 114,115,111
db 114,111,112
db 114,112,113
db 116,125,124
db 116,124,117
db 124,127,123
db 127,128,122
db 127,122,123
db 126,129,128
db 126,128,127
db 125,126,127
db 125,127,124
db 131,130,129
db 131,129,126
db 132,131,126
db 132,126,125
db 115,132,125
db 115,125,116
db 134,135,130
db 134,130,131
db 133,134,131
db 133,131,132
db 133,132,115
db 133,115,114
db 139,114,113
db 139,113,140
db 140,113,141
db 140,141,142
db 143,140,142
db 144,143,142
db 148,144,145
db 170,148,145
db 170,145,146
db 147,170,146
db 147,171,169
db 147,169,170
db 169,149,148
db 169,148,170
db 149,150,144
db 149,144,148
db 150,151,143
db 150,143,144
db 151,152,140
db 151,140,143
db 152,153,139
db 152,139,140
db 153,138,139
db 139,138,133
db 139,133,114
db 153,138,139
db 138,137,134
db 138,134,133
db 137,136,135
db 137,135,134
db 156,157,136
db 156,136,137
db 155,156,137
db 155,137,138
db 154,155,138
db 154,138,153
db 152,154,153
db 159,158,157
db 159,157,156
db 160,159,156
db 160,156,155
db 161,160,155
db 161,155,154
db 163,162,161
db 163,161,154
db 164,163,154
db 164,154,152
db 165,164,152
db 165,152,151
db 166,165,151
db 166,151,150
db 167,166,150
db 167,150,149
db 169,168,167
db 169,167,149
db 171,174,168
db 171,168,169
db 174,177,178
db 174,178,168
db 168,178,179
db 168,179,167
db 179,180,166
db 179,166,167
db 180,181,165
db 180,165,166
db 181,182,164
db 181,164,165
db 182,183,163
db 182,163,164
db 183,184,162
db 183,162,163
db 184,185,162
db 185,186,161
db 185,161,162
db 186,187,160
db 186,160,161
db 187,188,159
db 187,159,160
db 188,189,158
db 188,158,159
db 191,190,189
db 191,189,188
db 192,191,188
db 192,188,187
db 193,192,187
db 193,187,186
db 194,193,186
db 194,186,185
db 214,193,194
db 214,194,195
db 214,207,192
db 214,192,193
db 208,207,214
db 208,214,213
db 213,214,195
db 213,195,196
db 212,213,196
db 212,196,197
db 211,212,197
db 211,197,198
db 200,211,198
db 200,198,199
db 178,200,199
db 178,199,179
db 177,201,200
db 177,200,178
db 201,210,211
db 201,211,200
db 210,209,212
db 210,212,211
db 209,208,213
db 209,213,212
db 206,191,192
db 206,192,207
db 205,206,207
db 205,207,208
db 204,205,208
db 204,208,209
db 203,204,209
db 203,209,210
db 202,203,210
db 202,210,201
db 176,202,201
db 176,201,177
db 174,176,177
db 191,215,190
db 215,228,229
db 215,229,190
db 228,231,230
db 228,230,229
db 231,242,243
db 231,243,230
db 232,241,242
db 232,242,231
db 232,231,228
db 232,228,227
db 227,228,215
db 227,215,216
db 216,215,191
db 216,191,206
db 217,216,206
db 217,206,205
db 226,227,216
db 226,216,217
db 233,232,227
db 233,227,226
db 240,241,232
db 240,232,233
db 239,240,233
db 239,233,234
db 234,233,226
db 234,226,225
db 225,226,217
db 225,217,218
db 218,217,205
db 218,205,204
db 219,218,204
db 219,204,203
db 224,225,218
db 224,218,219
db 235,234,225
db 235,225,224
db 238,239,234
db 238,234,235
db 237,238,235
db 237,235,236
db 236,235,224
db 236,224,223
db 223,224,219
db 223,219,220
db 221,220,202
db 221,202,176
db 220,219,203
db 220,203,202
db 175,237,236
db 175,236,223
db 175,223,220
db 175,220,221
db 222,221,176
db 222,176,174
db 222,174,171
db 175,221,222
db 175,222,173
db 173,222,171
db 173,171,172
db 172,171,147
db 147,171,169
db 147,169,170
db 244,245,194
db 244,194,185
db 245,246,195
db 245,195,194
db 246,247,196
db 246,196,195
db 247,248,197
db 247,197,196
db 248,249,198
db 248,198,197
db 249,250,199
db 249,199,198
db 250,251,179
db 250,179,199
db 179,251,252
db 179,252,180
db 181,180,252
db 181,252,253
db 182,181,253
db 182,253,254
db 183,182,254
db 183,254,255
db 184,183,255
db 184,255,0 ;256
db 185,184,0 ;256
db 185,0,244 ;256

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

File: Faceline.asm

float TYPEDEF REAL4
coords:
float 0.000, -2.280, 8.875
float 0.000, -2.456, 8.980
float 0.000, -2.701, 9.005
float -0.509, -2.230, 8.865
float -0.577, -2.414, 8.962
float -0.585, -2.670, 8.987
float -1.027, -2.201, 8.544
float -1.135, -2.372, 8.658
float -1.182, -2.556, 8.657
float -1.570, -2.221, 8.025
float -1.805, -2.354, 8.037
float -1.151, -3.134, 8.433
float -0.565, -3.181, 8.583
float 0.000, -3.216, 8.631
float 0.000, -3.545, 8.640
float -0.582, -3.517, 8.557
float -1.158, -3.443, 8.329
float -1.999, -2.568, 7.895
float -2.121, -2.222, 7.917
float -2.395, -2.073, 7.692
float -2.213, -2.797, 7.639
float -1.358, -3.775, 8.198
float -0.837, -3.880, 8.520
float -0.590, -3.910, 8.645
float 0.000, -3.914, 8.646
float 0.000, -4.564, 8.583
float -0.700, -4.532, 8.584
float -1.058, -4.461, 8.459
float -1.579, -4.290, 8.085
float -1.995, -3.660, 7.538
float -2.572, -2.969, 7.100
float -2.746, -1.859, 7.124
float -2.990, -1.690, 6.640
float -2.751, -3.033, 6.688
float -2.147, -4.156, 7.145
float -1.620, -4.770, 7.945
float -1.081, -4.944, 8.281
float -0.699, -4.994, 8.360
float 0.000, -5.021, 8.360
float 0.000, -5.412, 7.852
float -0.602, -5.444, 7.853
float -0.990, -5.418, 7.854
float -1.597, -5.169, 7.416
float -2.342, -4.202, 6.524
float -3.374, -1.344, 5.866
float -3.118, -3.043, 5.708
float -2.559, -4.377, 5.351
float -1.600, -5.205, 6.353
float -0.945, -5.501, 6.834
float -0.542, -5.601, 7.067
float 0.000, -5.636, 7.068
float -3.232, -3.283, 3.861
float -3.686, -2.281, 4.257
float -3.797, -0.831, 4.703
float -4.136, -0.236, 3.398
float -4.093, -1.041, 3.153
float -3.959, -1.660, 2.889
float -4.295, 0.021, 2.170
float -3.485, -2.252, 2.286
float -2.740, -3.866, 3.388
float -2.315, -4.570, 4.819
float -0.966, -5.443, 4.589
float -0.556, -5.511, 4.589
float 0.000, -5.553, 4.589
float 0.000, -7.061, 3.726
float -0.436, -6.971, 3.553
float -0.926, -6.872, 3.196
float -2.414, -4.428, 2.801
float -3.120, -3.336, 1.701
float -3.204, -2.934, 1.002
float -3.120, -5.511, 0.149
float -3.119, -5.510, 0.702
float -2.343, -6.297, 1.993
float -2.389, -6.885, 1.708
float -1.053, -8.199, 2.359
float -0.336, -8.622, 2.554
float 0.000, -8.714, 2.559
float 0.000, -2.278, 8.878
float 0.000, -2.064, 9.078
float 0.000, -1.830, 9.119
float -0.484, -1.720, 9.116
float -0.512, -2.003, 9.070
float -0.521, -2.231, 8.876
float -1.170, -1.928, 9.000
float -1.083, -2.093, 8.703
float -1.032, -2.198, 8.549
float -1.773, -2.057, 8.299
float -1.572, -2.217, 8.022
float -2.039, -1.735, 8.072
float -1.285, -1.456, 8.655
float -0.456, -1.314, 8.986
float 0.000, -1.461, 8.920
float 0.000, -0.710, 8.876
float -0.237, -0.648, 8.971
float -0.446, -0.648, 8.971
float -1.316, -0.911, 8.428
float -2.206, -1.333, 7.855
float -2.274, -1.067, 7.654
float -1.276, -0.534, 8.239
float -0.753, -0.441, 8.580
float -0.534, -0.074, 8.714
float -0.191, -0.056, 9.150
float -0.171, -0.426, 9.051
float 0.000, -0.441, 9.053
float 0.000, -0.232, 9.570
float -0.168, -0.224, 9.570
float -0.560, 0.058, 9.376
float -0.767, 0.046, 9.042
float -0.843, -0.128, 8.806
float -0.978, -0.276, 8.684
float -1.091, -0.204, 8.513
float -0.905, -0.325, 8.292
float -1.320, -0.188, 8.010
float -0.895, 0.194, 8.202
float -1.002, 0.217, 8.462
float -1.077, 0.307, 8.703
float -1.017, 0.325, 8.904
float -0.900, 0.099, 9.033
float -0.574, 0.252, 9.485
float -0.118, -0.099, 9.722
float 0.000, -0.098, 9.723
float 0.000, 0.512, 9.855
float -0.158, 0.508, 9.820
float -0.587, 0.550, 9.557
float -0.660, 0.776, 9.277
float -0.242, 1.137, 9.532
float -0.208, 0.854, 9.713
float 0.000, 0.862, 9.749
float 0.000, 1.192, 9.559
float 0.000, 1.445, 9.385
float -0.250, 1.387, 9.361
float -0.495, 1.190, 9.132
float -0.526, 1.443, 8.894
float -0.284, 1.740, 9.158
float 0.000, 1.817, 9.200
float 0.000, 2.180, 8.995
float -0.322, 2.100, 8.927
float -0.667, 1.571, 8.598
float -1.312, 0.849, 8.093
float -2.093, 0.282, 7.775
float -2.327, -0.805, 7.560
float -3.108, -0.078, 7.267
float -3.182, 0.649, 7.412
float -3.805, 0.868, 6.790
float -4.108, 1.022, 5.942
float -4.360, 1.772, 4.387
float -4.187, 2.611, 4.596
float -4.028, 1.464, 6.118
float -3.708, 2.236, 6.211
float -3.359, 1.693, 6.896
float -2.876, 1.352, 7.271
float -2.100, 1.207, 7.559
float -1.337, 1.263, 8.027
float -1.270, 1.664, 7.809
float -0.723, 2.023, 8.332
float -0.357, 2.487, 8.669
float 0.000, 2.608, 8.699
float 0.000, 2.909, 8.460
float -0.392, 2.825, 8.420
float -0.623, 2.411, 8.173
float -0.853, 2.189, 7.760
float -1.119, 2.259, 7.352
float -1.460, 1.887, 7.332
float -2.095, 1.531, 7.388
float -2.765, 1.605, 7.294
float -3.156, 1.949, 6.974
float -3.399, 2.397, 6.443
float -3.657, 2.603, 6.413
float -3.904, 2.477, 5.990
float -4.092, 1.936, 5.653
float -3.994, 2.776, 5.641
float -4.121, 3.106, 4.611
float -4.105, 3.756, 4.772
float -3.883, 2.972, 6.298
float -3.928, 4.609, 5.060
float -3.866, 3.453, 6.724
float -3.788, 3.260, 6.846
float -3.556, 2.930, 6.956
float -3.201, 2.669, 6.903
float -3.001, 2.353, 7.274
float -2.571, 2.177, 7.578
float -2.113, 2.147, 7.561
float -1.602, 2.246, 7.687
float -1.210, 2.404, 7.438
float -0.967, 2.609, 7.023
float -0.638, 2.684, 7.661
float -0.584, 3.052, 8.055
float -0.431, 3.211, 8.189
float 0.000, 3.262, 8.208
float 0.000, 3.664, 8.101
float -0.487, 3.639, 8.101
float -0.760, 3.420, 7.947
float -0.829, 3.210, 7.554
float -1.006, 2.963, 7.129
float -1.309, 3.290, 7.370
float -1.772, 3.474, 7.615
float -2.268, 3.493, 7.824
float -2.704, 3.315, 7.781
float -3.129, 3.065, 7.391
float -3.421, 3.337, 7.438
float -3.624, 3.650, 7.348
float -3.730, 3.872, 7.238
float -3.285, 4.274, 7.783
float -2.569, 4.558, 8.182
float -1.841, 4.676, 8.353
float -1.067, 4.327, 8.469
float -1.150, 4.072, 8.222
float -1.853, 4.265, 8.296
float -2.509, 4.191, 8.259
float -3.195, 3.970, 7.895
float -2.963, 3.637, 7.879
float -2.381, 3.830, 8.100
float -1.782, 3.850, 8.071
float -1.227, 3.657, 8.072
float -0.450, 4.377, 8.175
float -0.991, 4.862, 8.093
float -1.731, 5.054, 7.962
float -2.474, 4.937, 7.775
float -3.170, 4.658, 7.356
float -3.605, 4.334, 6.861
float -3.890, 3.957, 6.326
float -3.941, 3.197, 5.815
float -3.590, 5.230, 6.286
float -3.102, 5.495, 6.831
float -2.330, 5.690, 7.264
float -1.576, 5.648, 7.632
float -0.888, 5.445, 7.804
float -0.406, 5.084, 7.869
float 0.000, 4.670, 7.912
float 0.000, 6.172, 7.196
float -0.354, 6.247, 7.229
float -0.746, 6.328, 7.263
float -1.426, 6.432, 7.212
float -2.244, 6.373, 6.969
float -3.105, 6.092, 6.495
float -3.639, 5.648, 5.945
float -3.562, 6.154, 5.544
float -3.109, 6.630, 5.986
float -2.176, 7.198, 6.426
float -1.281, 7.365, 6.600
float -0.547, 7.488, 6.717
float -0.286, 7.510, 6.750
float 0.000, 7.522, 6.764
float -0.973, 2.625, 7.123
float -1.041, 2.870, 7.229
float -1.295, 3.155, 7.470
float -1.693, 3.288, 7.715
float -2.196, 3.267, 7.924
float -2.545, 3.146, 7.881
float -2.856, 2.944, 7.491
float -3.091, 2.634, 7.003
float -2.846, 2.481, 7.474
float -2.383, 2.398, 7.878
float -2.012, 2.370, 7.961
float -1.574, 2.388, 7.987
float -1.197, 2.479, 7.638


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT