Title: OpenGL test ---- for mams3

------- down load -----

1130818956_opengl test.zip

opengl test.zip
----------------------------------------




; ------------------------------------------
; Title: OpenGL test
;; ------------------------------------------
;
; referenc this ----------------------------
;Title: OpenGL test ---- Author: Franck Charlet. masm32
;
; lesson17 ------nehe.gamedev.net
;
;
;
; ------------------------------------------

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

; --------------- Assembler directives
.386
.modelflat,stdcall
optioncasemap:none

; --------------- External includes
include\masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\opengl32.inc
include \masm32\include\glu32.inc

include \masm32\include\masm32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\opengl32.lib
includelib \masm32\lib\glu32.lib

includelib \masm32\lib\masm32.lib

include \masm32\include\fpu.inc
includelib \masm32\lib\fpu.lib


;include unknwn.inc
;;include ddraw.inc
;include windowsx.inc

; --------------- Macros Section proc --------------- begin ///////////////////////-
szTextMACROName,Text:VARARG
LOCALlbl
jmplbl
NamedbText,0
lbl:
ENDM

m2mMACROM1, M2
pushM2
popM1
ENDM

return MACROarg
moveax,arg
ret
ENDM

print_dos_scr MACRO Quoted_Text:VARARG
LOCAL Txt
.data
Txt db Quoted_Text,0
.code
invoke StdOut,ADDR Txt
ENDM

input MACRO Quoted_Prompt_Text:VARARG
LOCAL Txt
LOCAL Buffer
.data
Txt db Quoted_Prompt_Text,0
Buffer db 128 dup(?)
.code
invoke StdOut,ADDR Txt
invoke StdIn,ADDR Buffer,LENGTHOF Buffer
mov eax, offset Buffer
ENDM

cls MACRO
invoke ClearScreen
ENDM

;----------------- _glColor3f MACRO ---------- begin ----------------------
; (GLfloat red, GLfloat green, GLfloat blue)
_glColor3f MACRO R,G,B
glCall_f <glColor3f>,R,G,B
ENDM

glCall_f MACRO glApiName:REQ,Args:VARARG
GL_PUSH_FLOAT_ARGS Args
call glApiName
ENDM

GL_PUSH_FLOAT_ARGS MACRO a1,a2,a3,a4,a5,a6,a7,a8,a9,a10
IFNB <a1>
GL_PUSH_FLOAT_ARGS <a2>,<a3>,<a4>,<a5>,<a6>,<a7>,<a8>,<a9>,<a10>
gl_fpush a1
ENDIF
ENDM

gl_fpush MACRO numb
LOCAL prmstr,prmlen,x,n
prmstr EQU <numb>
prmlen SIZESTR prmstr
IF (prmlen LE 7)
;; constant or varname
x SUBSTR prmstr,prmlen,1
IFIDNI x,<f>
x SUBSTR prmstr,1,prmlen-1
push 12345678h
ORG $-4
real4 &x
ELSE
push GLfloat ptr prmstr
ENDIF
ELSE
x SUBSTR prmstr,1,7
IFIDNI x,<(float)>
x SUBSTR prmstr,8
n=&x
x TEXTEQU %n
x CATSTR x,<.0>
push 12345678h
ORG $-4
real4 &x
ELSE
x SUBSTR prmstr,prmlen,1
IFIDNI x,<f>
x SUBSTR prmstr,1,prmlen-1
push 12345678h
ORG $-4
real4 &x
ELSE
push GLfloat ptr prmstr
ENDIF
ENDIF
ENDIF
ENDM
;----------------- _glColor3f MACRO ---------- end ----------------------

_glVertex3f MACRO x,y,z
glCall_f <glVertex3f>,x,y,z
ENDM

_glTranslatef MACRO x,y,z
glCall_f <glTranslatef>,x,y,z
ENDM


_glNormal3f MACRO nx,ny,nz
glCall_f <glNormal3f>,nx,ny,nz
ENDM

; (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
_glRotatef MACRO angle,x,y,z
glCall_f <glRotatef>,angle,x,y,z
ENDM

; (GLfloat x, GLfloat y, GLfloat z)
_glScalef MACRO x,y,z
glCall_f <glScalef>,x,y,z
ENDM


_glTexCoord2f MACRO u,v
glCall_f <glTexCoord2f>,u,v
ENDM

_glVertex2f MACRO x,y
glCall_f <glVertex2f>,x,y
ENDM

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

_glOrtho MACRO l,r,b,t,zNear,zFar
glCall_d <glOrtho>,l,r,b,t,zNear,zFar
ENDM

glCall_d MACRO glApiName:REQ,Args:VARARG
GL_PUSH_DOUBLE_ARGS Args
call glApiName
ENDM

GL_PUSH_DOUBLE_ARGS MACRO a1,a2,a3,a4,a5,a6,a7,a8,a9,a10
IFNB <a1>
GL_PUSH_DOUBLE_ARGS <a2>,<a3>,<a4>,<a5>,<a6>,<a7>,<a8>,<a9>,<a10>
gl_dpush a1
ENDIF
_GL_DPUSH_FIX
ENDM

gl_dpush MACRO numb
LOCAL loc1,dat,prmstr,prmlen,x
prmstr EQU <numb>
prmlen SIZESTR prmstr
x SUBSTR prmstr,prmlen,1
IFIDNI x,<f>
x SUBSTR prmstr,1,prmlen-1
jmp loc1
ALIGN DWORD
dat real8 &x
loc1:
push dword ptr dat[4]
push dword ptr dat
ELSE
x CATSTR prmstr,<[4]>
push dword ptr x
push dword ptr prmstr
ENDIF
ENDM

_GL_DPUSH_FIX MACRO
ENDM


;*** string define macro CStr(xxx)

CStr macro y:req,x
local sym
ifnb <x>
x segment dword public 'DATA'
else
CONST segment dword public 'DATA'
endif
ifidni <y>,<"">
sym db 0
else
sym db y,0
endif
ifnb <x>
x ends
else
CONST ends
endif
exitm <offset sym>
endm

; --------------- Macros Section --------------- end --------------------------

; --------------- These constants are not defined in windows.inc
PFD_MAIN_PLANEequ0
PFD_TYPE_COLORINDEXequ1
PFD_TYPE_RGBAequ0
PFD_DOUBLEBUFFERequ1
PFD_DRAW_TO_WINDOWequ4
PFD_SUPPORT_OPENGLequ020h


;/* BeginMode */
;GL_POINTSEQU000000000h
;GL_LINESEQU000000001h
;GL_LINE_LOOPEQU000000002h
;GL_LINE_STRIPEQU000000003h
;GL_TRIANGLESEQU000000004h
;GL_TRIANGLE_STRIPEQU000000005h
;GL_TRIANGLE_FANEQU000000006h
;GL_QUADSEQU000000007h
;GL_QUAD_STRIPEQU000000008h
;GL_POLYGONEQU000000009h

;-------------------------- window 6 ---------------
WinMain6 proto :DWORD,:DWORD,:DWORD,:DWORD

.data
ClassName6 db "SimpleWinClass",0
AppName6 db " window6 Our First Window",0

window6_scr dd 200,200,300,300 ;x,y,w,h

.data?
hInstance6 HINSTANCE ?
CommandLine6 LPSTR ?
;-------------------------- window 6 ------ end ---------


; --------------- Data Section proc --------- begin /////////////////////////////////
.data ;------------------------

w1_redraw_tfdb 0;
real_str_buffer db "ccccccc",210 dup (?)
w1_btndb 'uuuuu',0,0
ms_btn_status db 'uuuuuuuuu',0,0 ;l,m,r,wheel --> u-up,d-down,f-forth,b-back
;
ms_btn_dn_xy dd 0,0,0 ;x,y,window nu.
dd 0,0 ;+12 now ms x,y
dd 0,0 ;+20 delta x,y
dd 0,0,0,0

per_deci_speed dd 80.0f
real_float_speed_xy dd 340.3667f,1.0f ;<-- x/50 , y/50
dd 0,0,0
;------------- 윈도우 위치 세팅 -----------------
window1_xywh dd 10 ,100,400,400
window7_xywh dd 200,160,200,200
window8_xywh dd 220,180,200,200
;-------------------------- window 7 ---------------

WinMain7 PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc7 PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY7 PROTO :DWORD,:DWORD
Paint_Proc7 PROTO :DWORD,:DWORD

szDisplayName7 db "window7 Bitmap Buttons",0
CommandLine7 dd 0
hWnd7 dd 0
hInstance7 dd 0
hIcon7 dd 0

;.data?
WINRect7 RECT <>

;hWnddd0
w7_HDCdd0
w7_OpenDCdd0
;hInstancedd0

PixFormat7dd 00
PixFrm7PIXELFORMATDESCRIPTOR <>

;-------------------------- window 7 ------- end --------
;-------------------------- window 8 ---------------

WinMain8 PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc8 PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY8 PROTO :DWORD,:DWORD
Paint_Proc8 PROTO :DWORD,:DWORD

;window8_xywh dd 220,180,200,200

szDisplayName8 db "window8 - Written by Choi myung hoan.",0
CommandLine8 dd 0
hWnd8 dd 0
hInstance8 dd 0
hIcon8 dd 0

WINRect8 RECT <>

;hWnddd0
w8_HDCdd0
w8_OpenDCdd0
;hInstancedd0

PixFormat8dd 00
PixFrm8PIXELFORMATDESCRIPTOR <>

;-------------------------- window 8 ------- end --------

;-------------------------- window 9 ---------------

WinMain9 PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc9 PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY9 PROTO :DWORD,:DWORD
Paint_Proc9 PROTO :DWORD,:DWORD

szDisplayName9 db "window9 - Written by Choi myung hoan.",0
CommandLine9 dd 0
hWnd9 dd 0
hInstance9 dd 0
hIcon9 dd 0

WINRect9 RECT <>

;hWnddd0
w9_HDCdd0
w9_OpenDCdd0
;hInstancedd0

PixFormat9dd 00
PixFrm9PIXELFORMATDESCRIPTOR <>

;-------------------------- window 9 ------- end --------

real_temp7 dd 2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f,2.1f
radian_t7 dd 0.017453292f ;= 3.1415927/180

;; psptv dd 45,45,01,1,03,3,07,7
; psptv dd 45,00,01,0,03,0,07,0
; psptv dd 00.0,45.0,00.0,0,00.0,3.0,00.0,7.0
psptv dq 50.0,1.0,3.0,570.0 ;시야각,비율,근거리,원거리


frstm dq -1.0f,+10.0f, -7.0f, +7.0f, 1.0f,+5.0f

kat dq 2.0 , 5.0 , 20.0 ; // 카메라위치
dq 0.0 , 0.0 , 0.0 ; +28 // 카메라방향
dq 0.0 , 1.0 , 0.0 ; +48 // 카메라 up방향
dq 0.0 , 0,0 ;buffer

kat2 dd 0,0,0,0,0,0
dd 0,0,0,0,0,0
dd 0,0,0,0,0,0
dq 0.0 , 0,0 ;buffer

rot_line_xyz_x dd 0.00, 1.0 ,0.0 ,0.0


msg_all_point dd 00
window1_hWnd dd 00
window5_hWnd dd 00

mrmy_hWin DWORD 0
mrmy_uMsg DWORD 0
mrmy_wParam DWORD 0
mrmy_lParam DWORD 0
;-------------------------------------------------------------------------
window5_szDisplayName db"TestOpenGL5 - Written by Choi myung hoan.",0
window5_hWinDWORD 0
window5_uMsgDWORD 0
window5_wParamDWORD 0
window5_lParamDWORD 0

window5_CommandLinedd0
; window5_hWnddd0
window5_MainHDCdd0
window5_OpenDCdd0
window5_hInstancedd0

window5_MainInitPROTO:DWORD,:DWORD,:DWORD,:DWORD
window5_MainLoopPROTO:DWORD,:DWORD,:DWORD,:DWORD
window5_PixFrm PIXELFORMATDESCRIPTOR <>

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

WinMain_6 PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc_6 PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY_6 PROTO :DWORD,:DWORD

szDisplayName_6 db "window 6 Demo",0
CommandLine_6 dd 0
hWnd_6 dd 0
hInstance_6 dd 0
hList1_6 dd 0
hList2_6 dd 0

window6_hWin DWORD 0
window6_uMsg DWORD 0
window6_wParam DWORD 0
window6_lParam DWORD 0


dos_str_buffer db " dos str bffer ----- "
db 256 dup (0)

AppName db "Our First Window",0
MouseClick db 0 ; 0=no click yet
hitpoint POINT <>


Caption db "JAV_ASM",0
ErrorMsg db "String conversion error",0
SccsMsg db "MessageBox displayed",0

szDisplayNamedb"TestOpenGL1 - Written by Choi myung hoan.",0
even
PixFrmPIXELFORMATDESCRIPTOR <>

CommandLinedd0
hWnddd0
w1_HDCdd0
w1_OpenDCdd0
hInstancedd0

; Some values
Value0Fltdd0.0
Value1Fltdd1.0
Value1Dbldq1.0
Value45Dbldq45.0
Value3Dbldq3.0
Value7Dbldq7.0

; Light position
LightSourcePositiondd-2.0,-2.0,-4.0,0.0
LightSource2Positiondd2.0,2.0,4.0,0.0
LightSource3Positiondd-2.0,2.0,4.0,0.0
LightAmbientdd0.2,0.0,0.0,1.0
Light2Ambientdd0.0,0.2,0.0,1.0
Light3Ambientdd0.0,0.0,0.2,1.0
LightDiffusedd1.0,1.0,1.0,1.0
LightSpeculardd1.0,1.0,1.0,1.0
SpotCutdd-1.0
SpotExpdd0.0
SpotDirdd-1.0,-1.0,-1.0
LightConstAttdd1.0
LightLinAttdd1.0
LightQuadAttdd1.0

; --- Sphere 1
; Angles
Sphere1AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere1AnglesSpeedFltdd-1.0,-1.2,-1.4
; Objects datas
Sphere1Colordd0.6,0.4,0.2,0.0
Sphere1Radiusdq1.0
sphere1Partsdd24
Sphere1Positiondd0.0,0.0,-5.0
GlSphere1dd0

; --- Sphere 2
; Angles
Sphere2AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere2AnglesSpeedFltdd-1.0,0.8,-0.4
; Objects datas
Sphere2Colordd0.4,0.6,0.2,0.0
Sphere2Radiusdq0.3
sphere2Partsdd16
Sphere2Positiondd0.0,0.0,-1.5
GlSphere2dd0

; --- Sphere 3
; Angles
Sphere3AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere3AnglesSpeedFltdd-1.0,-0.8,1.4
; Objects datas
Sphere3Colordd0.2,0.4,0.6,0.0
Sphere3Radiusdq0.3
sphere3Partsdd16
Sphere3Positiondd0.0,0.0,1.5
GlSphere3dd0

; --- Sphere 4
; Angles
Sphere4AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere4AnglesSpeedFltdd-1.0,1.4,-0.8
; Objects datas
Sphere4Colordd0.4,0.2,0.6,0.0
Sphere4Radiusdq0.3
sphere4Partsdd16
Sphere4Positiondd0.0,1.5,0.0
GlSphere4dd0

; --- Sphere 5
; Angles
Sphere5AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere5AnglesSpeedFltdd1.0,1.8,0.8
; Objects datas
Sphere5Colordd0.6,0.2,0.4,0.0
Sphere5Radiusdq0.3
sphere5Partsdd16
Sphere5Positiondd1.5,0.0,0.0
GlSphere5dd0

; --- Sphere 6
; Angles
Sphere6AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere6AnglesSpeedFltdd1.0,-1.8,2.0
; Objects datas
Sphere6Colordd0.2,0.6,0.4,0.0
Sphere6Radiusdq0.3
sphere6Partsdd16
Sphere6Positiondd-1.5,0.0,0.0
GlSphere6dd0

; --- Sphere 7
; Angles
Sphere7AnglesFltdd0.0,0.0,0.0
; Rotations speed
Sphere7AnglesSpeedFltdd-2.1,-1.8,2.0
; Objects datas
Sphere7Colordd0.6,0.6,0.6,0.0
Sphere7Radiusdq0.3
sphere7Partsdd16
Sphere7Positiondd0.0,-1.5,0.0
GlSphere7dd0


OurText db "Win32 assembly is small and not easy!",0
base dd 0
loc_x dd -0.42
loc_y dd -0.42
loc_z dd -0.1
color_rdd 0.5
color_gdd 0.5
color_bdd 0.5
x_2ddd 0.1
y_2ddd 0.1

;LOCAL c2:REAL4, c12:REAL4

t_rot_speed dd 0.7
q_rot_speed dd 0.5

rtri dd 0.10, 0.0 ,1.0 ,0.0
rquad dd 0.10, 1.0 ,1.0 ,1.0


;---------------------- bmp data ------------- begin -------------------------
.data
txt_Font_BMPdb"Font.BMP",0
txt_Bumps_BMPdb"Bumps.BMP",0

txt_NeHedb"NeHe",0
txt_Giueseppedb"Giuseppe D'Agata",0
txt_OpenGLdb"OpenGL",0

; INITIALISED DATA * * * * * * * * * * * * * * * * * * * * * * * * * *
.data

rotate_bmp dd 1.0 , 1.0 , 0.0
rotate_bmp2 dd 45.0 , 0.0 , 0.0 , 1.0 ; Rotate on Z axis 45 degrees clockwise

;gld_10_0GLdouble10.0f
gld_10_0REAL810.0f
r4_0_0REAL40.0f
r4_0_01REAL40.01f
r4_0_02REAL40.02f
r4_0_0625REAL40.0625f
r4_16_0REAL416.0f
r4_1_0REAL41.0f
r4_0_0081REAL40.0081f
r4_235_0REAL4235.0f
r4_280_0REAL4280.0f
r4_30_0REAL430.0f
r4_200_0REAL4200.0f
r4_250_0REAL4250.0f
r4_0_5REAL40.5f
r4_230_0REAL4230.0f
r4_240_0REAL4240.0f
r4_m0_5REAL4-0.5f
r4_5_0REAL42.0f

; UNINITIALISED DATA * * * * * * * * * * * * * * * * * * * * * * * * *
.data?
textureDWORD 2 dup (?);GLuint GL Texture handle x 2
BMPTextureDWORD2 dup (?); Texture pointer x 2
;
;baseDWORD?; Base display list for the font
cnt1REAL4?; GLfloat 1st temp used to move text & for colouring
cnt2REAL4?; GLfloat you guessed it.. second temp

; STRUCTURES * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; Define BMP structure
; I use this to reference width/height & data section from BMP files
BMPFILE STRUCT
header BITMAPFILEHEADER <>
info BITMAPINFOHEADER <>
data DWORD ?
BMPFILE ENDS

BuildFontPROTO
KillFontPROTO
glPrintPROTO :DWORD, :DWORD, :DWORD, :UINT
DrawGLScene_texture PROTO
LoadGLTexturesPROTO

;------------- EXAMPLE1\WINENUM ------- var.----------- begin ---------------------------

; #########################################################################

;=============
; Local macros
;=============

szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM

m2m MACRO M1, M2
push M2
pop M1
ENDM

return MACRO arg
mov eax, arg
ret
ENDM

;=================
; Local prototypes
;=================
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
; TopXY PROTO :DWORD,:DWORD
ListBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
EnmProc PROTO :DWORD,:DWORD
; EnmProc PROTO :DWORD,:DWORD
Static PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ListProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

.data
szDisplayName2 db "Enumerate Windows",0
CommandLine2 dd 0
hWnd2 dd 0
hInstance2 dd 0
hList dd 0
hStat1 dd 0
hStat2 dd 0
lpfnListProc dd 0


;------------- EXAMPLE1\WINENUM -------- var. ---------- end -----------------------------

;------------- window3 ----------------- var. ---------- begin ---------------------------

szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM

m2m MACRO M1, M2
push M2
pop M1
ENDM

return MACRO arg
mov eax, arg
ret
ENDM

;=================
; Local prototypes
;=================
WinMain_3 PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc_3 PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY_3 PROTO :DWORD,:DWORD
ListBox_3 PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ListBoxProc_3 PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
szDisplayName_3 db "List Box Demo",0
CommandLine_3 dd 0
hWnd_3 dd 0
hInstance_3 dd 0
hList1_3 dd 0
hList2_3 dd 0
lpLstBox1_3 dd 0

; jmp @@@1
lItem1 db "Roses are red,",0
lItem2 db "Violets are blue.",0
lItem3 db "If sugar is sweet,",0
lItem4 db "What happhgfhfhfhg ggggggggggggggh ghfhfhf ened to you ?",0

str_mouse_pressed db "mouse pressed -->,",0

; @@@1:

;------------- window3 ----------------- var. ---------- end -----------------------------

window1_width dd 100
window1_height dd 100

ddsd dd 456
hWndLB dd 00
IDC_LIST1 equ 1000

;----------------------------- end data --------------------------
;///////////////////////////////////////////////////////////////////////////////////
;//////////////////////////////////////////////////////////////////////////////////

;------------------------ code --------------------- begin -------------------
; --------------- Procedures Declarations
.code

MainInitPROTO:DWORD,:DWORD,:DWORD,:DWORD
MainLoopPROTO:DWORD,:DWORD,:DWORD,:DWORD
TopXYPROTO:DWORD,:DWORD
DrawScene_mainPROTO
GlInitPROTO:DWORD,:DWORD
ResizeObjectPROTO:DWORD,:DWORD
CreateSpherePROTO:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
SetLightSourcePROTO:DWORD,:DWORD,:DWORD
RotateObjectPROTO:DWORD,:DWORD,:DWORD,:DWORD
DeleteSpheresPROTO

;glPrint PROTO:DWORD


DrawGLScene_b_texture PROTO
DrawGLScene_c_pyramid_cub PROTO


; --------------- Procedures Section
CenterFormPROC wDim:DWORD, sDim:DWORD
shrsDim,1
shrwDim,1
moveax,wDim
subsDim,eax
returnsDim
CenterFormENDP

DoEventsPROC
LOCALmsg:MSG
StartLoop:; Check for waiting messages
invokePeekMessage,ADDR msg,0,0,0,PM_NOREMOVE ;PM_NOREMOVE
oreax,eax
jzNoMsg
invokeGetMessage,ADDR msg,NULL,0,0
oreax,eax
jzExitLoop
invokeTranslateMessage,ADDR msg
invokeDispatchMessage,ADDR msg
jmpStartLoop
NoMsg:; No pending messages: draw the scene
invokeDrawScene_main
jmpStartLoop
ExitLoop:moveax,msg.wParam
ret
DoEventsENDP

; --------------- Program start
start:

; call start2
call start3
; call start5


invokeGetModuleHandle,NULL
movhInstance, eax
invokeGetCommandLine
movCommandLine,eax

invoke ClearScreen
print_dos_scr "Console function test",13,10,13,10
print_dos_scr "Console function test2 ",13,10
print_dos_scr "Console function kkhhhhhh hhh test3 " ,13,10 ;,13,10
;input "Enter Some Text > "
;invoke StdOut,eax ; return address in eax


;invoke LoadGLTextures; Load textures
;invoke BuildFont; Build the font
;callfont_make
; call start5
FINIT
invokeMainInit,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
; call start5
call start6
call start7
call start8
invoke BuildFont; Build the font

callfont_make


akc10:
;.WHILE TRUE
invoke UpdateWindow, window1_hWnd
invoke GetMessage, ADDR msg_all_point ,NULL,0,0
;.BREAK .IF (!eax)
cmpeax,0
jzakc20
invoke TranslateMessage, ADDR msg_all_point
invoke DispatchMessage, ADDR msg_all_point
;.ENDW
;------------------------------------------------------
; invoke UpdateWindow, window5_hWnd
;invoke GetMessage, ADDR msg_all_point,NULL,0,0
;cmpeax,0
;jzakc20
;invoke TranslateMessage, ADDR msg_all_point
;invoke DispatchMessage, ADDR msg_all_point


jmpakc10

akc20:
;mov eax,msg.wParam


invokeExitProcess, 0 ;eax
;----------------------------------------------------------------------


; --------------- Program main inits
MainInit PROC \ ;--------------- begin first start ------ opengl -------------
hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCALwc:WNDCLASSEX
LOCALWwd:DWORD
LOCALWht:DWORD
LOCALWtx:DWORD
LOCALWty:DWORD
LOCAL msg:MSG


szTextszClassName,"Win32SDI_Class"
movwc.cbSize,sizeof WNDCLASSEX
movwc.style,0
; mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_OWNDC

movwc.lpfnWndProc,offset MainLoop
movwc.cbClsExtra,NULL
movwc.cbWndExtra,NULL
m2mwc.hInstance,hInst
movwc.hbrBackground,COLOR_WINDOWTEXT+1
movwc.lpszMenuName,NULL
movwc.lpszClassName,offset szClassName
invokeLoadIcon,hInst,2
movwc.hIcon,eax
invokeLoadCursor,NULL,IDC_ARROW
movwc.hCursor,eax
movwc.hIconSm,0
invokeRegisterClassEx, ADDR wc


m2m Wtx, window1_xywh
m2m Wty, window1_xywh +4
m2m Wwd, window1_xywh +8
m2m Wht, window1_xywh +12
;movWwd,400
;movWht,420
;invokeGetSystemMetrics,SM_CXSCREEN
;invokeCenterForm,Wwd,eax
;movdword ptr Wtx, 10 ;eax
;invokeGetSystemMetrics,SM_CYSCREEN
;invokeCenterForm,Wht,eax
;movdword ptr Wty, 100 ;eax

invokeCreateWindowEx,0,ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
Wtx,Wty, Wwd,Wht,\
;window1_width, window1_height, ; dd 100 , 100
NULL,NULL,
hInst,NULL
movwindow1_hWnd,eax
invokeLoadMenu,hInst,600
invokeSetMenu,window1_hWnd,eax
invokeShowWindow,window1_hWnd,SW_SHOWNORMAL
invokeUpdateWindow,window1_hWnd
;callDoEvents


ret
; call start5
;----------- window out ru.--- begin ---------------------------
invoke UpdateWindow, window1_hWnd
@@@10:
;.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
;.BREAK .IF (!eax)
cmpeax,0
jz@@@20
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
;.ENDW
jmp@@@10
@@@20:
mov eax,msg.wParam
ret
;----------- window out ru.--- end -----------------------------
;------------------------------------------------------
;invoke MessageBox, NULL, addr ErrorMsg, addr Caption, 16

ret

MainInit ENDP

; --------------- Program main loop
MainLoop PROC \ ; ------------------ window 1 main loop --------------------
hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCALWINRect:RECT
LOCALPixFormat:DWORD

LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC


mov eax,hWin
mov mrmy_hWin,eax
mov eax,uMsg
mov mrmy_uMsg,eax
mov eax,wParam
mov mrmy_wParam,eax
mov eax,wParam
mov mrmy_hWin,eax
mov eax,lParam
mov mrmy_lParam,eax


.if uMsg == WM_COMMAND
.if wParam == 1000
invokeSendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.endif
return0


.elseifuMsg == WM_CREATE
invokeGetDC,hWin
movw1_HDC,eax
movax,SIZEOF PixFrm
movPixFrm.nSize,ax
movPixFrm.nVersion,1
movPixFrm.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
movPixFrm.dwLayerMask,PFD_MAIN_PLANE
movPixFrm.iPixelType,PFD_TYPE_RGBA
movPixFrm.cColorBits,8
movPixFrm.cDepthBits,16
movPixFrm.cAccumBits,0
movPixFrm.cStencilBits,0
invokeChoosePixelFormat,w1_HDC,ADDR PixFrm
movPixFormat,eax
invokeSetPixelFormat,w1_HDC,PixFormat,ADDR PixFrm
oreax,eax
jzNoPixelFmt
invokewglCreateContext,w1_HDC
movw1_OpenDC,eax
invokewglMakeCurrent,w1_HDC,w1_OpenDC
invokeGetClientRect,hWin,ADDR WINRect
invokeGlInit,WINRect.right,WINRect.bottom
;invokeGlInit,WINRect.right,WINRect.top
NoPixelFmt:
return0


.elseifuMsg == WM_SIZE
print_dos_scr "window 1 wmsize test",13,10,13,10
invokeGetClientRect,hWin,ADDR WINRect
invokewglMakeCurrent,w1_HDC,w1_OpenDC
invokeResizeObject,WINRect.right,WINRect.bottom
invokeDrawScene_main
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4

;invoke ClearScreen
;print_dos_scr "Console function test",13,10,13,10
;input "Enter Some Text > "
;invoke StdOut,eax ; return address in eax
return0


.elseifuMsg == WM_CLOSE
szText TheText,"Are you sure ?"
invokeMessageBox,hWin,ADDR TheText,ADDR szDisplayName \
,MB_YESNO+MB_ICONQUESTION
.if eax == IDNO
return0
.endif
moveax,w1_OpenDC
oreax,eax
jzNoGlDC
; Delete our objects
invokeDeleteSpheres
invokewglDeleteContext,w1_OpenDC
NoGlDC:invokeReleaseDC,hWin,w1_HDC
invokeDestroyWindow,hWin
return0

nop ;---- 이루틴은 리턴과 엘스이프의 중간이므로 ---
callwinow_mouse_move_dragg_set
nop ;---- 절대로 수행되지 않는다 ----------------


;---------------- paint begin --------------------------------------------
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWin, ADDR ps
mov hdc,eax
;invoke GetClientRect,hWin, ADDR WINRect
;invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
; , DT_SINGLELINE or DT_CENTER or DT_VCENTER
; invokeDrawScene_main
;invoke EndPaint,hWin, ADDR ps

;invokewglMakeCurrent,w1_HDC,w1_OpenDC

;call draw_scene_w1;
invokeGetClientRect,hWin,ADDR WINRect
invokewglMakeCurrent,w1_HDC,w1_OpenDC
invokeResizeObject,WINRect.right,WINRect.bottom
invokeDrawScene_main
;calldraw_scene_w1


;invokeGetClientRect,hWin,ADDR WINRect
;invokeResizeObject,WINRect.right,WINRect.bottom
; invokeDrawScene_main
;invoke GetClientRect,hWin, ADDR WINRect
;invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
; , DT_SINGLELINE or DT_CENTER or DT_VCENTER

invoke EndPaint,hWin, ADDR ps
return0
;----------------- paint end ---------------------------------------------

.elseif uMsg == WM_DESTROY
invokePostQuitMessage,NULL
return0
.endif

nop
callwinow_mouse_move_dragg_set
;ret
cmp mrmy_uMsg, WM_MOUSEMOVE
jnz@@@500
moveax,"uuuu"
cmpdword ptr [ms_btn_status],eax
jz@@@500
print_dos_scr " @@@ 500 run test",13,10
mov byte ptr [w1_redraw_tf],1 ;
invoke InvalidateRect,hWin,NULL,TRUE ;이루틴은 윈도의 페인트를 콜하게 한다


@@@500:
nop
nop
invokeDefWindowProc,hWin,uMsg,wParam,lParam ;이루틴을 메인루프를 다시콜하기위해서 중요하다
ret
MainLoopENDP

winow_mouse_move_dragg_setproc ;------- botton ---
; local addr_ms_btn_status: DWORD ;'uuuuuuuuu',0,0 ;l,m,r,wheel --> u-up,d-down,f-forth,b-back
;jmp@@@20
;ms_btn_status db 'uuuuuuuuu',0,0 ;l,m,r,wheel --> u-up,d-down,f-forth,b-back
; ;
;ms_btn_dn_xy dd 0,0,0 ;x,y,window nu.
; dd 0,0 ;+12 now ms x,y
; dd 0,0 ;+29 delta x,y
;
;@@@20:

;movbyte ptr wmmds_somting_occur ,"y"

;--------------------------------------------------------
.IF mrmy_uMsg==WM_LBUTTONDOWN
print_dos_scr "window 1 action test",13,10,13,10
movbyte ptr [ms_btn_status],"d"
callbutton_down_first_point_set
return 0

;----------------------------------------------------------------------
.ELSEIF mrmy_uMsg==WM_LBUTTONUP
movbyte ptr [ms_btn_status],"u"
callbutton_down_first_point_set
;----------------------------------------------------------

;--------------------------------------------------------
.ELSEIF mrmy_uMsg==WM_MBUTTONDOWN
movbyte ptr [ms_btn_status+1],"d"
callbutton_down_first_point_set
.ELSEIF mrmy_uMsg==WM_MBUTTONUP
movbyte ptr [ms_btn_status+1],"u"
callbutton_down_first_point_set
;----------------------------------------------------------

;--------------------------------------------------------
.ELSEIF mrmy_uMsg==WM_RBUTTONDOWN
movbyte ptr [ms_btn_status+2],"d"
callbutton_down_first_point_set
.ELSEIF mrmy_uMsg==WM_RBUTTONUP
movbyte ptr [ms_btn_status+2],"u"
callbutton_down_first_point_set
;----------------------------------------------------------

;--------------------------------------------------------
.ELSEIF mrmy_uMsg==WM_MOUSEWHEEL
movbyte ptr [ms_btn_status+4],"n"
mov eax,mrmy_wParam
shr eax,16
cmpeax,60000
ja@@@10
movbyte ptr [ms_btn_status+4],"f"
callms_btn_status_to_scr
ret
@@@10:
movbyte ptr [ms_btn_status+4],"b"
callms_btn_status_to_scr
ret
;----------------------------------------------------------

.ELSEIF mrmy_uMsg==WM_MOUSEMOVE
print_dos_scr "window 1 mouse move " ; ,13,10,13,10
call MOUSEMOVE_now_point_set
; call LBUTTONDOWN_rou ; left button down ----
callms_btn_status_to_scr
callmove_camera;--
;----------------------------------------------------------
ret
.endif
ret

wmmds_somting_occurdd0,0,0
;data.
; addr_ms_btn_status dd 0,0

winow_mouse_move_dragg_setendp ;--------------------------------------

button_down_first_point_setproc

mov eax,mrmy_lParam
and eax,0ffffh
mov ms_btn_dn_xy,eax ; x
mov eax,mrmy_lParam
shr eax,16
mov ms_btn_dn_xy+4,eax ; y

callms_btn_status_to_scr

ret
button_down_first_point_setendp

MOUSEMOVE_now_point_setproc
mov eax,mrmy_lParam
and eax,0ffffh
mov ms_btn_dn_xy+12,eax ; x
mov eax,mrmy_lParam
shr eax,16
mov ms_btn_dn_xy+16,eax ; y

;delta set ----
mov eax,ms_btn_dn_xy+12 ; x
sub eax,ms_btn_dn_xy ; x
;neg eax
mov ms_btn_dn_xy+20,eax ; x delta

mov eax,ms_btn_dn_xy+16 ; y
sub eax,ms_btn_dn_xy+4 ; y
mov ms_btn_dn_xy+24,eax ; y delta

FINIT ; fild 할경우에는 이것을 실행해야한다 -> 한쪽이 음일경우 가끔마다 다른쪽의 부호가 바뀐다 -----
fild ms_btn_dn_xy+20 ;delta x
fdiv per_deci_speed
fstp real_float_speed_xy;<-- x/50

;FINIT

fild dword ptr ms_btn_dn_xy+24 ;delta y
fdiv per_deci_speed
fstp dword ptr real_float_speed_xy+4;<-- y/50
ret
MOUSEMOVE_now_point_setendp

ms_btn_status_to_scrproc ;--

invoke StdOut,addr ms_btn_status
;print_dos_scr " <=",13,10

print_dos_scr " button_down_first_point_set X= " ;,13,10
mov eax,ms_btn_dn_xy ; x
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer

print_dos_scr " , Y= " ;,13,10
mov eax,ms_btn_dn_xy+4 ; x
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer
; print_dos_scr " <=",13,10

print_dos_scr " delta x= " ;,13,10
mov eax,ms_btn_dn_xy+20 ; x delta
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer
print_dos_scr " y= " ;,13,10
mov eax,ms_btn_dn_xy+24 ; y delta
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer

print_dos_scr " real ="
fld dword ptr real_float_speed_xy
invoke FpuFLtoA, 0, 4, ADDR real_str_buffer , SRC1_FPU or SRC2_DIMM
invoke StdOut,ADDR real_str_buffer
print_dos_scr " y= "
fld dword ptr real_float_speed_xy+4
invoke FpuFLtoA, 0, 4, ADDR real_str_buffer , SRC1_FPU or SRC2_DIMM
invoke StdOut,ADDR real_str_buffer

print_dos_scr " <=",13,10

ret
ms_btn_status_to_screndp

move_cameraproc ;----------------------
moveax,"uuuu"
cmpdword ptr [ms_btn_status],eax
jnz@@@10
ret
@@@10:
cmpbyte ptr [ms_btn_status],"d"
jnz@@@200
jmp@@@500
@@@200:
cmpbyte ptr [ms_btn_status+2],"d"
jnz@@@210
jmp@@@600
@@@210:
ret

@@@500:;--------- 버튼 1 시작 -----------
finit
;-- 카메라 좌우로 -----
fld qword ptr kat
fadd real_float_speed_xy;x<-- x/50
fstp qword ptr kat

fld qword ptr kat +24
fadd real_float_speed_xy;x<-- x/50 카메라방향
fstp qword ptr kat + 24

;-- 카메라 앞뒤로 -----
fld qword ptr kat+16
fadd real_float_speed_xy+4;z<-- y/50
fstp qword ptr kat+16

fld qword ptr kat+16+24
fadd real_float_speed_xy+4;z<-- y/50 카메라방향
fstp qword ptr kat+16+24

ret

@@@600:;----- 버튼3 시작 -------------------
;---- 카메라 위아래로 ---------
fld qword ptr kat+8
fsub real_float_speed_xy+4;y<-- y/50
fstp qword ptr kat+8

fld qword ptr kat+8 +24
fsub real_float_speed_xy+4;y<-- y/50 카메라방향
fstp qword ptr kat+8 +24

;-------------------------- 카메라 위치 회전 --------- begin -------------------------------------
; Math.sin(angle*3.1415927/180);
; centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
; newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
; newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y

finit

filddword ptr ms_btn_dn_xy+20 ;angle
fmulradian_t7
fstpreal_temp7+32 ; (angle*3.1415927/180);

fldkat ;x 카메라 위치
fsubkat+24 ;x-centerx
fstpreal_temp7

fldkat+16 ;z 카메라 위치
fsubkat+40 ;z-centerz
fstpreal_temp7+4

;filddword ptr ms_btn_dn_xy+20 ;angle
fldreal_temp7+32 ; (angle*3.1415927/180);
fcos
fstpreal_temp7+8 ; fcos (angle)

;filddword ptr ms_btn_dn_xy+20 ;angle
fldreal_temp7+32 ; (angle*3.1415927/180);
fsin
fstpreal_temp7+12; fsin (angle)

;newx --- begin --- (((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX
fldreal_temp7 ;x-centerx
fmulreal_temp7+8 ; fcos (angle)
fstpreal_temp7+16; (x-centerx)*cos[phi]

fldreal_temp7+4 ;z-centerz
fmulreal_temp7+12; fsin (angle)
fstpreal_temp7+20; (z-centerz)*sin[phi])

fldreal_temp7+16; (x-centerx)*cos[phi]
fsubreal_temp7+20;-(z-centerz)*sin[phi])
faddkat+24 ;+centerx
fstpqword ptr kat ;x 카메라 위치

;newz --- begin ---(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz)
fldreal_temp7 ;x-centerx
fmulreal_temp7+12; fsin (angle)
fstpreal_temp7+24; (x-centerx)*sin[phi]

fldreal_temp7+4 ;z-centerz
fmulreal_temp7+8 ; fcos (angle)
fstpreal_temp7+28; (z-centerz)*cos[phi])

fldreal_temp7+24; (x-centerx)*sin[phi]
faddreal_temp7+28; (z-centerz)*cos[phi])
faddkat+40 ;+centerz
fstpqword ptr kat+16 ;z 카메라 위치

;-------------------------- 카메라 위치 회전 --------- end ---------------------------------------


ret

call draw_scene_w1;
ret
move_cameraendp ;--

draw_scene_w1proc ;

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

invokeglViewport,5,5,200,200
;invokeglViewport,50,50,150,150
invokeglMatrixMode,GL_PROJECTION
invokeglLoadIdentity
;invokegluPerspective,DWORD PTR Value45Dbl,DWORD PTR Value45Dbl+4,DWORD PTR Value1Dbl,DWORD PTR Value1Dbl+4,DWORD PTR Value3Dbl,DWORD PTR Value3Dbl+4,DWORD PTR Value7Dbl,DWORD PTR Value7Dbl+4
invokegluPerspective,DWORD PTR psptv ,DWORD PTR psptv+4 ,DWORD PTR psptv+8 ,DWORD PTR psptv+12 , \
DWORD PTR psptv+16,DWORD PTR psptv+20 ,DWORD PTR psptv+24,DWORD PTR psptv+28

call kat_to_kat2
invokeglMatrixMode,GL_MODELVIEW
invokeglLoadIdentity


;-----------------------------------------------------------
invokeDrawScene_main
ret

draw_scene_w1endp


; ------------------------------
; OpenGl related stuff
; ------------------------------
font_makeproc
invoke LoadGLTextures; Load textures
.IF (eax == NULL); Exit if the textures failed to load
ret
.ENDIF

invoke BuildFont; Build the font
ret
moveax,"ok"
font_makeendp


; --------------- Init the scene
GlInitPROC ParentW:DWORD,ParentH:DWORD

;callfont_make
;.IF (eax == NULL); Exit if the textures failed to load
;ret
;.ENDIF



invokeSetLightSource,GL_LIGHT0,ADDR LightSourcePosition,ADDR LightAmbient
invokeSetLightSource,GL_LIGHT1,ADDR LightSource2Position,ADDR Light2Ambient
invokeSetLightSource,GL_LIGHT2,ADDR LightSource3Position,ADDR Light3Ambient
invokeCreateSphere,1,GLU_FILL,GLU_SMOOTH,ADDR Sphere1Color,ADDR Sphere1Radius,sphere1Parts
movGlSphere1,eax
invokeCreateSphere,2,GLU_FILL,GLU_SMOOTH,ADDR Sphere2Color,ADDR Sphere2Radius,sphere2Parts
movGlSphere2,eax
invokeCreateSphere,3,GLU_FILL,GLU_SMOOTH,ADDR Sphere3Color,ADDR Sphere3Radius,sphere3Parts
movGlSphere3,eax
invokeCreateSphere,4,GLU_FILL,GLU_SMOOTH,ADDR Sphere4Color,ADDR Sphere4Radius,sphere4Parts
movGlSphere4,eax
invokeCreateSphere,5,GLU_FILL,GLU_SMOOTH,ADDR Sphere5Color,ADDR Sphere5Radius,sphere5Parts
movGlSphere5,eax
invokeCreateSphere,6,GLU_FILL,GLU_SMOOTH,ADDR Sphere6Color,ADDR Sphere6Radius,sphere6Parts
movGlSphere6,eax
invokeCreateSphere,7,GLU_FILL,GLU_SMOOTH,ADDR Sphere7Color,ADDR Sphere7Radius,sphere7Parts
movGlSphere7,eax

;-------------- from sphere rotate ---------------------------
; Set global flags
invokeglEnable,GL_DEPTH_TEST
;invokeglEnable,GL_LIGHTING
invokeglEnable,GL_CULL_FACE; Don't render back faces
invokeglShadeModel,GL_SMOOTH
invokeglEnable,GL_NORMALIZE

;------------ from pyramid rotate -----------------------------
invoke glShadeModel, GL_SMOOTH ;enable smooth shading
; _glClearDepth 1.0f ;depth buffer setup
invoke glEnable, GL_DEPTH_TEST ;enable depth testing
invoke glDepthFunc, GL_LEQUAL ;type of depth test
;set really nice perspective calculations
invoke glHint, GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST


;------------- from bmp texture -----------------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
;invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
;invoke glEnable, GL_TEXTURE_2D; Enable texture mapping


mov eax, 1

ret
GlInitENDP


; --------------- Display the scene
DrawScene_mainPROC
;LOCAL c1:REAL4
;LOCAL c2:REAL4, c12:REAL4

invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

; invoke DrawGLScene_c_pyramid_cub ;drawing
;invokeSwapBuffers,w1_HDC
;ret


;invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
invokeglEnable,GL_LIGHTING
call DrawGLScene_a_sphere_rotate ;drawing spher

; invoke DrawGLScene_b_texture ;drawing
invokeglDisable,GL_LIGHTING
invoke DrawGLScene_c_pyramid_cub ;drawing
call DrawGLScene_d_line_xyz ;drawing

;------------- from bmp texture ------- begin ----------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
invoke glEnable, GL_TEXTURE_2D; Enable texture mapping

invoke DrawGLScene_texture

invokeglDisable,GL_TEXTURE_2D
invokeglDisable,GL_BLEND
;invoke glBlendFunc, GL_SRC_ALPHA, GL_SRC_ALPHA; Select the type of blending
;------------- from bmp texture ------- end ----------------

; PER_PIXEL REAL4 26.458333
;fld PER_PIXEL ; mov to stack
; fistp temp ; get integer result (rounds it too)
;fstpDWORD PTR [eax]

; mole REAL4 0.5 ;6.023E+23
; moveax, mole
;movc1, eax
; loc_x dd 0.0
; loc_y dd 0.0
; loc_z dd -1.0
; color_rdd 0.5
; color_gdd 0.5
; color_bdd 0.5
; x_2ddd 1.0
; y_2ddd 1.0

; invoke glLoadIdentity ;reset modelview matrix
; invoke glTranslatef, loc_x,loc_y,loc_z
; invoke glColor3f, color_r,color_g,color_b
; invoke glRasterPos2f, x_2d , y_2d
; invoke glPrint, addr OurText

invokeSwapBuffers,w1_HDC
;invokeSwapBuffers,window5_MainHDC
ret
DrawScene_mainENDP

DrawScene_main_not_clear PROC
;invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

invokeglEnable,GL_LIGHTING
call DrawGLScene_a_sphere_rotate ;drawing spher

; invoke DrawGLScene_b_texture ;drawing
invokeglDisable,GL_LIGHTING
invoke DrawGLScene_c_pyramid_cub ;drawing
call DrawGLScene_d_line_xyz ;drawing

;------------- from bmp texture ------- begin ----------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
invoke glEnable, GL_TEXTURE_2D; Enable texture mapping

invoke DrawGLScene_texture

invokeglDisable,GL_TEXTURE_2D
invokeglDisable,GL_BLEND
;invoke glBlendFunc, GL_SRC_ALPHA, GL_SRC_ALPHA; Select the type of blending
;------------- from bmp texture ------- end ----------------

invokeSwapBuffers,w1_HDC
;invokeSwapBuffers,window5_MainHDC
ret
DrawScene_main_not_clear ENDP

; --------------- Display the scene
DrawScene_w6PROC

invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

invokeglEnable,GL_LIGHTING
call DrawGLScene_a_sphere_rotate ;drawing spher

; invoke DrawGLScene_b_texture ;drawing
invokeglDisable,GL_LIGHTING
invoke DrawGLScene_c_pyramid_cub ;drawing
call DrawGLScene_d_line_xyz ;drawing

;------------- from bmp texture ------- begin ----------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
invoke glEnable, GL_TEXTURE_2D; Enable texture mapping

invoke DrawGLScene_texture

invokeglDisable,GL_TEXTURE_2D
invokeglDisable,GL_BLEND
;invoke glBlendFunc, GL_SRC_ALPHA, GL_SRC_ALPHA; Select the type of blending
;------------- from bmp texture ------- end ----------------


;invokeSwapBuffers,w1_HDC
invokeSwapBuffers,window5_MainHDC
ret
DrawScene_w6ENDP

DrawScene_w7PROC

invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

invokeglEnable,GL_LIGHTING
call DrawGLScene_a_sphere_rotate ;drawing spher

; invoke DrawGLScene_b_texture
invokeglDisable,GL_LIGHTING
invoke DrawGLScene_c_pyramid_cub ;drawing
call DrawGLScene_d_line_xyz ;drawing

;------------- from bmp texture ------- begin ----------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
invoke glEnable, GL_TEXTURE_2D; Enable texture mapping

invoke DrawGLScene_texture

invokeglDisable,GL_TEXTURE_2D
invokeglDisable,GL_BLEND
;invoke glBlendFunc, GL_SRC_ALPHA, GL_SRC_ALPHA; Select the type of blending
;------------- from bmp texture ------- end ----------------


invokeSwapBuffers,w7_HDC
ret
DrawScene_w7ENDP

DrawScene_w8PROC

invokeglClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

invokeglEnable,GL_LIGHTING
call DrawGLScene_a_sphere_rotate ;drawing spher

; invoke DrawGLScene_b_texture
invokeglDisable,GL_LIGHTING
invoke DrawGLScene_c_pyramid_cub
call DrawGLScene_d_line_xyz ;drawing

;------------- from bmp texture ------- begin ----------------
;invoke glDepthFunc, GL_LEQUAL; Set type of depth test
invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE; Select the type of blending
;invoke glShadeModel,GL_SMOOTH; Enable smooth shading
invoke glEnable, GL_TEXTURE_2D; Enable texture mapping

invoke DrawGLScene_texture

invokeglDisable,GL_TEXTURE_2D
invokeglDisable,GL_BLEND
;invoke glBlendFunc, GL_SRC_ALPHA, GL_SRC_ALPHA; Select the type of blending
;------------- from bmp texture ------- end ----------------


invokeSwapBuffers,w8_HDC
ret
DrawScene_w8ENDP


DrawGLScene_a_sphere_rotate proc ;drawing
invokeglPushMatrix
invokeRotateObject,1,ADDR Sphere1Position,ADDR Sphere1AnglesSpeedFlt,ADDR Sphere1AnglesFlt

invokeglPushMatrix
invokeRotateObject,2,ADDR Sphere2Position,ADDR Sphere2AnglesSpeedFlt,ADDR Sphere2AnglesFlt
invokeglLightfv,GL_LIGHT0,GL_POSITION,ADDR LightSourcePosition
invokeglPopMatrix

invokeglPushMatrix
invokeRotateObject,3,ADDR Sphere3Position,ADDR Sphere3AnglesSpeedFlt,ADDR Sphere3AnglesFlt
invokeglLightfv,GL_LIGHT1,GL_POSITION,ADDR LightSource2Position
invokeglPopMatrix

invokeglPushMatrix
invokeRotateObject,4,ADDR Sphere4Position,ADDR Sphere4AnglesSpeedFlt,ADDR Sphere4AnglesFlt
invokeglLightfv,GL_LIGHT2,GL_POSITION,ADDR LightSource3Position
invokeglPopMatrix

invokeglPushMatrix
invokeRotateObject,5,ADDR Sphere5Position,ADDR Sphere5AnglesSpeedFlt,ADDR Sphere5AnglesFlt
invokeglPopMatrix

invokeglPushMatrix
invokeRotateObject,6,ADDR Sphere6Position,ADDR Sphere6AnglesSpeedFlt,ADDR Sphere6AnglesFlt
invokeglPopMatrix

invokeglPushMatrix
invokeRotateObject,7,ADDR Sphere7Position,ADDR Sphere7AnglesSpeedFlt,ADDR Sphere7AnglesFlt
invokeglPopMatrix

invokeglPopMatrix

ret
DrawGLScene_a_sphere_rotate endp ;drawing


DrawGLScene_b_texture proc ;drawing

;clear screen and depth buffer
; invoke glClear, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

; invoke glLoadIdentity ;reset modelview matrix
; _glTranslatef -1.5f, 0.0f, -6.0f
; ; _glRotatef rtri, 0.0f,1.0f,0.0f
; invoke glBegin, GL_TRIANGLES
; _glColor3f 1.0f,0.0f,0.0f
; _glVertex3f 0.0f,1.0f,0.0f
; _glColor3f 0.0f,1.0f,0.0f
; _glVertex3f -1.0f,-1.0f,0.0f
; _glColor3f 0.0f,0.0f,1.0f
; _glVertex3f 1.0f,-1.0f,0.0f
; invoke glEnd

invoke glBegin, GL_QUAD_STRIP ;GL_QUADS
invoke glLoadIdentity
; _glTranslatef 1.5f,0.0f,-6.0f
_glTranslatef -1.5f, 0.0f, -6.0f
; _glRotatef rquad,1.5f,0.0f,0.0f
; _glColor3f 0.5f,0.5f,1.0f
_glColor3f 1.0f,0.0f,0.0f
; invoke glBegin, GL_QUADS
_glColor3f 1.0f,0.0f,0.0f
_glVertex3f -1.0f,1.0f,0.0f
_glColor3f 1.0f,0.0f,0.0f
_glVertex3f 1.0f,1.0f,0.0f
_glColor3f 1.0f,0.0f,0.0f
_glVertex3f 1.0f,-1.0f,0.0f
_glColor3f 1.0f,0.0f,0.0f
_glVertex3f -1.0f,-1.0f,0.0f
invoke glEnd


; fld rtri
; fadd t_rot_speed
; fstp rtri
; fld rquad
; fsub q_rot_speed
; fstp rquad
mov eax, 1
ret
DrawGLScene_b_texture endp

DrawGLScene_c_pyramid_cub proc ;drawing
;clear screen and depth buffer
; invoke glClear, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
invoke glLoadIdentity ;reset modelview matrix
_glTranslatef -1.5f, 0.0f, -6.0f
invoke glRotatef , rtri, rtri+4, rtri+8 , rtri+12
invoke glBegin, GL_TRIANGLES

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 0.0f, 1.0f, 0.0f
_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f -1.0f,-1.0f, 1.0f
_glColor3f 0.0f, 0.0f, 1.0f
_glVertex3f 1.0f,-1.0f, 1.0f

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 0.0f, 1.0f, 0.0f
_glColor3f 0.0f, 0.0f, 1.0f
_glVertex3f 1.0f,-1.0f, 1.0f
_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f 1.0f,-1.0f,-1.0f

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 0.0f, 1.0f, 0.0f
_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f 1.0f,-1.0f,-1.0f
_glColor3f 0.0f, 0.0f, 1.0f
_glVertex3f -1.0f,-1.0f,-1.0f

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 0.0f, 1.0f, 0.0f
_glColor3f 0.0f, 0.0f, 1.0f
_glVertex3f -1.0f,-1.0f,-1.0f
_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f -1.0f,-1.0f, 1.0f

invoke glEnd
invoke glLoadIdentity
_glTranslatef 1.5f,0.0f,-7.0f
; _glRotatef rquad,1.0f,1.0f,1.0f
invoke glRotatef , rquad, rquad+4, rquad+8 , rquad+12
invoke glBegin, GL_QUADS

_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f 1.0f, 1.0f,-1.0f
_glVertex3f -1.0f, 1.0f,-1.0f
_glVertex3f -1.0f, 1.0f, 1.0f
_glVertex3f 1.0f, 1.0f, 1.0f

_glColor3f 1.0f, 0.5f, 0.0f
_glVertex3f 1.0f,-1.0f, 1.0f
_glVertex3f -1.0f,-1.0f, 1.0f
_glVertex3f -1.0f,-1.0f,-1.0f
_glVertex3f 1.0f,-1.0f,-1.0f

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 1.0f, 1.0f, 1.0f
_glVertex3f -1.0f, 1.0f, 1.0f
_glVertex3f -1.0f,-1.0f, 1.0f
_glVertex3f 1.0f,-1.0f, 1.0f

_glColor3f 1.0f, 1.0f, 0.0f
_glVertex3f 1.0f,-1.0f,-1.0f
_glVertex3f -1.0f,-1.0f,-1.0f
_glVertex3f -1.0f, 1.0f,-1.0f
_glVertex3f 1.0f, 1.0f,-1.0f

_glColor3f 0.0f, 0.0f, 1.0f
_glVertex3f -1.0f, 1.0f, 1.0f
_glVertex3f -1.0f, 1.0f,-1.0f
_glVertex3f -1.0f,-1.0f,-1.0f
_glVertex3f -1.0f,-1.0f, 1.0f

_glColor3f 1.0f, 0.0f, 1.0f
_glVertex3f 1.0f, 1.0f,-1.0f
_glVertex3f 1.0f, 1.0f, 1.0f
_glVertex3f 1.0f,-1.0f, 1.0f
_glVertex3f 1.0f,-1.0f,-1.0f

invoke glEnd
fld rtri
fadd t_rot_speed
fstp rtri
fld rquad
fsub q_rot_speed
fstp rquad
mov eax, 1
ret
DrawGLScene_c_pyramid_cub endp


DrawGLScene_d_line_xyz proc ;drawing
;clear screen and depth buffer
; invoke glClear, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
invoke glLoadIdentity ;reset modelview matrix
; _glTranslatef -1.5f, 0.0f, -6.0f
_glTranslatef 0.0f, 0.0f, 0.0f
; invoke glRotatef , rtri, rtri+4, rtri+8 , rtri+12
invoke glRotatef , rot_line_xyz_x, rot_line_xyz_x+4, rot_line_xyz_x+8 , rot_line_xyz_x+12 ;rtri
invoke glBegin, GL_LINES

_glColor3f 1.0f, 1.0f, 1.0f
_glVertex3f -100.0f,0.0f ,0.0f ;x
_glVertex3f +100.0f,0.0f ,0.0f

_glColor3f 1.0f, 0.0f, 0.0f
_glVertex3f 0.0f ,-10.0f,0.0f ;y
_glVertex3f 0.0f ,10.0f ,0.0f

_glColor3f 0.0f, 1.0f, 0.0f
_glVertex3f 0.0f ,0.0f ,-100.0f ;z
_glVertex3f 0.0f ,0.0f ,+100.0f

invoke glEnd
ret
DrawGLScene_d_line_xyz endp ;drawing

;glPrint proc thetext:DWORD
; invoke glPushAttrib, GL_LIST_BIT
; mov eax , base
; sub eax, 32
; invoke glListBase, eax
; invoke StrLen, thetext
; invoke glCallLists, eax, GL_UNSIGNED_BYTE, thetext
; invoke glPopAttrib
; ret
;glPrint endp

kat_to_kat2 proc
movebx, offset kat
mov ecx, offset kat2
movedx,0
@@@5:
moveax,[ebx]
mov[ecx],eax
addebx,4
addecx,4
incedx
cmpedx,22
jbe@@@5

invoke gluLookAt ,
kat2, kat2+4, kat2+8, kat2+12 , kat2+16 ,
kat2+20 , kat2+24, kat2+28, kat2+32 , kat2+36,
kat2+40, kat2+44, kat2+48, kat2+52, kat2+56,
kat2+60, kat2+64, kat2+68
; invoke gluLookAt ,
; DWORD PTR kat, DWORD PTR kat+4, DWORD PTR kat+8, DWORD PTR kat+12 , DWORD PTR kat+16 ,\
; DWORD PTR kat+20 ,DWORD PTR kat+24,DWORD PTR kat+28,DWORD PTR kat+32 , DWORD PTR kat+36,\
; DWORD PTR kat+40, DWORD PTR kat+44,DWORD PTR kat+48,DWORD PTR kat+52, DWORD PTR kat+56 \
; DWORD PTR kat+60, DWORD PTR kat+64,DWORD PTR kat+68

ret
kat_to_kat2 endp

; --------------- Resize the scene
ResizeObjectPROC ParentW:DWORD,ParentH:DWORD
invokeglViewport,5,5,ParentW,ParentH
;invokeglViewport,50,50,150,150
invokeglMatrixMode,GL_PROJECTION
invokeglLoadIdentity
;invokegluPerspective,DWORD PTR Value45Dbl,DWORD PTR Value45Dbl+4,DWORD PTR Value1Dbl,DWORD PTR Value1Dbl+4,DWORD PTR Value3Dbl,DWORD PTR Value3Dbl+4,DWORD PTR Value7Dbl,DWORD PTR Value7Dbl+4
invokegluPerspective,DWORD PTR psptv ,DWORD PTR psptv+4 ,DWORD PTR psptv+8 ,DWORD PTR psptv+12 , \
DWORD PTR psptv+16,DWORD PTR psptv+20 ,DWORD PTR psptv+24,DWORD PTR psptv+28


call kat_to_kat2



invokeglMatrixMode,GL_MODELVIEW
invokeglLoadIdentity
ret
ResizeObjectENDP

; --------------- Free the memory allocated for the spheres
DeleteSpheresPROC
invokegluDeleteQuadric,GlSphere1
invokegluDeleteQuadric,GlSphere2
invokegluDeleteQuadric,GlSphere3
invokegluDeleteQuadric,GlSphere4
invokegluDeleteQuadric,GlSphere5
invokegluDeleteQuadric,GlSphere6
invokegluDeleteQuadric,GlSphere7
ret
DeleteSpheresENDP

; --------------- Create a sphere with glu object
CreateSpherePROC ListNumber:DWORD,FillType:DWORD,NormalsType:DWORD,Color:DWORD,Radius:DWORD,Parts:DWORD
LOCALGlSphere:DWORD
invokeglNewList,ListNumber,GL_COMPILE
; Create a template
invokegluNewQuadric
movGlSphere,eax
; Set object draw style
invokegluQuadricDrawStyle,GlSphere,FillType
; Set normals style
invokegluQuadricNormals,GlSphere,NormalsType
; Set object color
invokeglMaterialfv,GL_FRONT,GL_AMBIENT_AND_DIFFUSE,Color
moveax,Radius
; Create a sphere primitive
invokegluSphere,GlSphere,[eax],[eax+4],Parts,Parts
invokeglEndList
moveax,GlSphere
ret
CreateSphereENDP

; --------------- Set a light source
SetLightSourcePROC LtNumber:DWORD,LtPosition:DWORD,LtAmbient:DWORD
invokeglLightfv,LtNumber,GL_POSITION,LtPosition
invokeglLightfv,LtNumber,GL_DIFFUSE,ADDR LightDiffuse
invokeglLightfv,LtNumber,GL_SPECULAR,ADDR LightSpecular
invokeglLightfv,LtNumber,GL_AMBIENT,LtAmbient
invokeglLightfv,LtNumber,GL_CONSTANT_ATTENUATION,ADDR LightConstAtt
invokeglLightfv,LtNumber,GL_LINEAR_ATTENUATION,ADDR LightLinAtt
invokeglLightfv,LtNumber,GL_QUADRATIC_ATTENUATION,ADDR LightQuadAtt
invokeglLightfv,LtNumber,GL_SPOT_CUTOFF,ADDR SpotCut
invokeglLightfv,LtNumber,GL_SPOT_EXPONENT,ADDR SpotExp
invokeglLightfv,LtNumber,GL_SPOT_DIRECTION,ADDR SpotDir
invokeglEnable,LtNumber
ret
SetLightSourceENDP

; --------------- Position and rotate an object
RotateObjectPROC ListNumber:DWORD,XYZPosition:DWORD,XYZRotations:DWORD,XYZAngles:DWORD
LOCALLocXSpd:DWORD
LOCALLocYSpd:DWORD
LOCALLocZSpd:DWORD
LOCALLocXAngle:DWORD
LOCALLocYAngle:DWORD
LOCALLocZAngle:DWORD
moveax,XYZPosition
movecx,[eax]
movebx,[eax+4]
moveax,[eax+8]
invokeglTranslatef,ecx,ebx,eax
moveax,XYZAngles; Rotate X
movebx,XYZRotations
fldDWORD PTR [eax]
faddDWORD PTR [ebx]
fstpDWORD PTR [eax]
invokeglRotatef,[eax],Value0Flt,Value1Flt,Value0Flt
moveax,XYZAngles; Rotate Y
movebx,XYZRotations
fldDWORD PTR [eax+4]
faddDWORD PTR [ebx+4]
fstpDWORD PTR [eax+4]
invokeglRotatef,[eax+4],Value1Flt,Value0Flt,Value0Flt
moveax,XYZAngles; Rotate Z
movebx,XYZRotations
fldDWORD PTR [eax+8]
faddDWORD PTR [ebx+8]
fstpDWORD PTR [eax+8]
invokeglRotatef,DWORD PTR [eax+8],Value0Flt,Value0Flt,Value1Flt
invokeglCallList,ListNumber
ret
RotateObjectENDP


;------------------ LoadBMP ------------ BEGIN -----------------------------------------------
; LoadBMP * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; This procedure only works with 24-bit BMP files.
; But it is small and avoids the use of glaux.
; A check should probably be added here to make sure we're dealing with a 24bit BMP
LoadBMP proc FileName:DWORD
LOCAL FileHandle:DWORD, FileSize:DWORD, BytesRead:DWORD, BMP:DWORD, ImageSize:DWORD

; Open the file
invoke CreateFile, FileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0
mov FileHandle, eax

.IF eax==INVALID_HANDLE_VALUE; get outta here if we failed to open the file
xor eax, eax
ret
.ENDIF

; Determine size of the file
invoke GetFileSize, FileHandle, 0
mov FileSize, eax

; Allocate space in memory for the file.
invoke GlobalAlloc, GPTR, FileSize
mov BMP, eax ; BMP = pointer to allocated space

; Read the file into memory
invoke ReadFile, FileHandle, BMP, FileSize, addr BytesRead, 0
invoke CloseHandle, FileHandle
mov eax, BytesRead
.IF (eax != FileSize); Free memory & exit if the readfile failed
invoke GlobalFree, BMP
xor eax, eax
ret
.ENDIF

; BMP file has the colours as BGR instead of RGB. Swap the R & B colours.
mov ebx, BMP; Pointer to start of BMPFILE structure
mov eax, (BMPFILE PTR [ebx]).info.biWidth; eax = BMPwidth * BMPheight
mul (BMPFILE PTR [ebx]).info.biHeight
lea ebx, (BMPFILE PTR [ebx]).data; ebx = address of BMP data, ie: past the BMP header

mov ecx, eax; Loop thru BMP data, swapping R & G colours
@@:mov al, [ebx]; al = Red value
xchg al, [ebx+2]; Swap Green value with al, and al value with Green
mov [ebx], al; Write back Green value
add ebx, 3; Move to next block
loop @B

; Return a handle to the BMP
mov eax, BMP
ret
LoadBMP endp


LoadGLTextures PROC
;LoadGLTextures PROC

; Load the first texture, "Font.bmp"
invoke LoadBMP, addr txt_Font_BMP
mov BMPTexture, eax
.IF (eax == NULL); Quit if file load failed
ret
.ENDIF

; Load the second texture, "Bumps.bmp"
invoke LoadBMP, addr txt_Bumps_BMP
mov [BMPTexture+4], eax
.IF (eax == NULL); Quit if file load failed
ret
.ENDIF

invoke glGenTextures, 2, addr texture; Create two textures handles

; Build "Font" texture
invoke glBindTexture, GL_TEXTURE_2D, texture[0]
invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
mov eax, BMPTexture
lea ebx, (BMPFILE PTR [eax]).data
invoke glTexImage2D, GL_TEXTURE_2D, 0, 3, (BMPFILE PTR [eax]).info.biWidth, (BMPFILE PTR [eax]).info.biHeight,\
0, GL_RGB, GL_UNSIGNED_BYTE, ebx

; Build "Bumps" texture
invoke glBindTexture, GL_TEXTURE_2D, texture[1]
invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
mov eax, [BMPTexture+4]
lea ebx, (BMPFILE PTR [eax]).data
invoke glTexImage2D, GL_TEXTURE_2D, 0, 3, (BMPFILE PTR [eax]).info.biWidth, (BMPFILE PTR [eax]).info.biHeight,\
0, GL_RGB, GL_UNSIGNED_BYTE, ebx

; Remember to free the memory for the BMPFILE allocated in LoadBMP
; I assume that if we don't need to free it, then the load failed & I set exit flag accordingly.
.IF (BMPTexture != NULL);
invoke GlobalFree, BMPTexture
.IF ([BMPTexture+4] != NULL)
invoke GlobalFree, [BMPTexture+4]
mov eax, 1
.ENDIF
.ELSE
xor eax, eax
.ENDIF

ret
LoadGLTextures endp

BuildFont PROC
;LOCAL charx:GLfloat, chary:GLfloat, temp:UINT, counter:UINT
LOCAL charx:REAL4 , chary:REAL4 , temp:UINT, counter:UINT

invoke glGenLists, 256; Create 256 display lists
mov base, eax

invoke glBindTexture, GL_TEXTURE_2D, [texture]; Select the font texture

mov counter, 0

.WHILE (counter < 256)
mov eax, counter; charx = (temp2 mod 16)/16chary = 1 - int(temp2/16)/16
xor edx, edx
mov ebx, 16
div ebx

mov temp, eax
fild temp
fdiv r4_16_0
fsubr r4_1_0
fstp chary

mov temp, edx
fild temp
fdiv r4_16_0
fstp charx

mov eax, [counter]
add eax, base
invoke glNewList, eax, GL_COMPILE; Start building a list

invoke glBegin, GL_QUADS; Use a quad for each character

fld chary; Texture coord, bottom left
fsub r4_0_0625
fstp chary
invoke glTexCoord2f, charx, chary
invoke glVertex2i, 0, 0

fld charx; Texture coord, bottom right
fadd r4_0_0625
fstp charx
invoke glTexCoord2f, charx, chary
invoke glVertex2i, 16, 0

fld chary; Texture coord, top right
fadd r4_0_0625
fstp chary
invoke glTexCoord2f, charx, chary
invoke glVertex2i, 16, 16

fld charx; Texture coord, top left
fsub r4_0_0625
fstp charx
invoke glTexCoord2f, charx, chary
invoke glVertex2i, 0, 16

invoke glEnd; Done building the quad

invoke glTranslated, (DWORD PTR [gld_10_0]),(DWORD PTR [gld_10_0+4]), \
(DWORD PTR [r4_0_0]),(DWORD PTR [r4_0_0]), (DWORD PTR [r4_0_0]),\
(DWORD PTR [r4_0_0])

invoke glEndList; Done building the display list

inc counter
.ENDW
ret
BuildFont endp

DrawGLScene_texture PROC
;LOCAL red:GLfloat, green:GLfloat, blue:GLfloat; Used for float calculations with colours
LOCAL red:REAL4 , green:REAL4 , blue:REAL4 ; Used for float calculations with colours
LOCAL x:UINT, y:UINT; co-ordinates for printing text

;invoke glClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
invoke glLoadIdentity

invoke glBindTexture, GL_TEXTURE_2D, [texture+1]; Select second texture
;_glTranslatef 0.0f, 0.0f, -5.0f; Move into screen 5 units
_glTranslatef 0.0f, 0.0f, -5.0f; Move into screen 5 units
;_glRotatef 45.0f, 0.0f, 0.0f, 1.0f; Rotate on Z axis 45 degrees clockwise
_glRotatef 89.0f, 1.0f, 1.0f, 1.0f; Rotate on Z axis 45 degrees clockwise
;invoke glRotatef, rotate_bmp2 , rotate_bmp2+4, rotate_bmp2+8 , rotate_bmp2+12; Rotate on X&Y axis by cnt1.

fld r4_30_0
fmul cnt1
fstp red; naughty. red is a bad variable name here.
;_glRotatef red, 1.0f, 1.0f, 0.0f; Rotate on X&Y axis by cnt1.
invoke glRotatef, red, rotate_bmp, rotate_bmp+4 , rotate_bmp+8; Rotate on X&Y axis by cnt1.

invoke glDisable, GL_BLEND; Disable blending
_glColor3f 1.0f, 1.0f, 1.0f; Bright white
invoke glBegin, GL_QUADS
_glTexCoord2f 0.0f, 0.0f
_glVertex2f -1.0f, 1.0f
_glTexCoord2f 1.0f, 0.0f
_glVertex2f 1.0f, 1.0f
_glTexCoord2f 1.0f, 1.0f
_glVertex2f 1.0f, -1.0f
_glTexCoord2f 0.0f, 1.0f
_glVertex2f -1.0f, -1.0f
invoke glEnd

_glRotatef 90.0f, 1.0f, 1.0f, 0.0f
invoke glBegin, GL_QUADS
_glTexCoord2f 0.0f, 0.0f
_glVertex2f -1.0f, 1.0f
_glTexCoord2f 1.0f, 0.0f
_glVertex2f 1.0f, 1.0f
_glTexCoord2f 1.0f, 1.0f
_glVertex2f 1.0f, -1.0f
_glTexCoord2f 0.0f, 1.0f
_glVertex2f -1.0f, -1.0f
invoke glEnd

invoke glEnable, GL_BLEND
invoke glLoadIdentity

fld cnt1
fcos
fstp red
fld cnt2
fsin
fstp green
fld cnt1
fadd cnt2
fcos
fmul r4_0_5
fsubr r4_1_0
fstp blue
;_glColor3f red, green, blue
invoke glColor3f, red, green, blue

fld cnt1
fcos
fmul r4_250_0
fadd r4_280_0
fistp x

fld cnt2
fsin
fmul r4_200_0
fadd r4_235_0
fistp y

invoke glPrint, x, y, addr txt_NeHe, 0; Print NeHe on the screen

fld cnt2
fsin
fstp red; Calc red for OpenGL

fld cnt1
fadd cnt2
fcos
fmul r4_m0_5
fsubr r4_1_0
fstp green; Calc green for OpenGL

fld cnt1
fcos
fstp blue; Calc blue for OpenGl
invoke glColor3f, red, green, blue

fld cnt2
fcos
fmul r4_230_0
fadd r4_280_0
fistp x; X Coord for OpenGL

fld cnt1
fsin
fmul r4_200_0
fadd r4_235_0
fistp y; Y Coord for OpenGL

invoke glPrint, x, y, addr txt_OpenGL, 1; Print OpenGL on the screen

invoke glColor3f, r4_0_0, r4_0_0, r4_1_0; Set the colour to a dark blue
fld cnt1
fadd cnt2
fdiv r4_5_0
fcos
fmul r4_200_0
fadd r4_240_0
fistp x
invoke glPrint, x, 2, addr txt_Giueseppe, 0

invoke glColor3f, r4_1_0, r4_1_0, r4_1_0; Set the colour to a dark blue
add x, 2
invoke glPrint, x, 2, addr txt_Giueseppe, 0

fld cnt1; Increase cnt1
fadd r4_0_01
fstp cnt1

fld cnt2; Increase cnt2
fadd r4_0_0081
fstp cnt2

mov eax, 1
ret
DrawGLScene_texture endp

;glPrint proc x:GLint, y:GLint, string:DWORD, set:UINT
;LOCAL gld_x:GLdouble, gld_y:GLdouble
glPrint proc x:DWORD, y:DWORD, string:DWORD, set:UINT
LOCAL gld_x:REAL8 , gld_y:REAL8

fild x; Convert the GLuint's to GLdoubles for use with glTranslated
fstp gld_x
fild y; Convert the GLuint's to GLdoubles for use with glTranslated
fstp gld_y

.IF (set > 1)
mov set, 1
.ENDIF

invoke glBindTexture, GL_TEXTURE_2D, texture; Select the font texture
invoke glDisable, GL_DEPTH_TEST; Disable depth testing
invoke glMatrixMode, GL_PROJECTION; Select projection matrix
invoke glPushMatrix; Store the projection matrix
invoke glLoadIdentity; Reset projection matrix
_glOrtho 0.0f, 640.0f, 0.0f, 480.0f, -1.0f, 1.0f; Set up an Ortho screen
invoke glMatrixMode, GL_MODELVIEW; Select modelview matrix
invoke glPushMatrix; Store the modelview matrix
invoke glLoadIdentity; Reset the modelview matrix

invoke glTranslated, (DWORD PTR [gld_x]),(DWORD PTR [gld_x+4]), (DWORD PTR [gld_y]),(DWORD PTR [gld_y+4]), \
(DWORD PTR [r4_0_0]),(DWORD PTR [r4_0_0])

mov eax, 128; Choose the font set
mul set; eax= (128*set)+base-32
add eax, base
sub eax, 32
invoke glListBase, eax

invoke StrLen, string
invoke glCallLists, eax, GL_BYTE, string; Write the text to the screen

invoke glMatrixMode, GL_PROJECTION; Select projection matrix
invoke glPopMatrix; Restore the old matrix
invoke glMatrixMode, GL_MODELVIEW; Select modelview matrix
invoke glPopMatrix; Restore the old matrix
invoke glEnable, GL_DEPTH_TEST; Enable depth testing

ret
glPrint endp

;------------------ LoadBMP ------------ endp -----------------------------------------------

;------------- EXAMPLE1\WINENUM ------------------ begin ---------------------------
;------------- EXAMPLE1\WINENUM ------------------ end -----------------------------


;------------- window3 ----------------- code ---------- begin ---------------------------

start3:
;ret
invoke GetModuleHandle, NULL
mov hInstance_3, eax

invoke GetCommandLine
mov CommandLine_3, eax

invoke WinMain_3,hInstance_3,NULL,CommandLine_3,SW_SHOWDEFAULT
ret
invoke ExitProcess,eax

; #########################################################################

WinMain_3 proc hInst :DWORD, ;--------------------------- window 3 begin -----------
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD

;====================
; Put LOCALs on stack
;====================

LOCAL wc :WNDCLASSEX
LOCAL msg :MSG

LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD

;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================

mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW \
or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc_3
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst ;<< NOTE: macro not mnemonic
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName_3
invoke LoadIcon,hInst,500 ; icon ID
mov wc.hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
mov wc.hIconSm, 0

invoke RegisterClassEx, ADDR wc

;================================
; Centre window at following size
;================================

mov Wwd, 470
mov Wht, 285

invoke GetSystemMetrics,SM_CXSCREEN
invoke TopXY_3,Wwd,eax
mov Wtx, eax

invoke GetSystemMetrics,SM_CYSCREEN
invoke TopXY_3,Wht,eax
mov Wty, eax

szText szClassName_3,"Template_Class"

invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
ADDR szClassName_3,
ADDR szDisplayName_3,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd_3 ,eax

invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd_3 ,eax

invoke ShowWindow,hWnd_3 ,SW_SHOWNORMAL
invoke UpdateWindow,hWnd_3

;===================================
; Loop until PostQuitMessage is sent
;===================================

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
;jmp StartLoop
ExitLoop:

return msg.wParam

WinMain_3 endp

; #########################################################################

WndProc_3 proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCALWINRect:RECT
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hwnd:HWND


mov eax,hWin
mov mrmy_hWin,eax
mov eax,uMsg
mov mrmy_uMsg,eax
mov eax,wParam
mov mrmy_wParam,eax
mov eax,wParam
mov mrmy_hWin,eax
mov eax,lParam
mov mrmy_lParam,eax

.if uMsg == WM_COMMAND
;======== menu commands ========
.if wParam == 1000
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.elseif wParam == 1900
szText TheMsg,"Assembler, Pure & Simple"
invoke MessageBox,hWin,ADDR TheMsg,ADDR szDisplayName_3,MB_OK
.endif
;====== end menu commands ======

.elseif uMsg == WM_CREATE
invoke ListBox_3,20,20,200,200,hWin,500
mov hList1_3 , eax

szText Patn,"*.*"
invoke SendMessage,hList1_3 ,LB_DIR,DDL_ARCHIVE or DDL_DRIVES or \
DDL_DIRECTORY,ADDR Patn
invoke SetWindowLong,hList1_3 ,GWL_WNDPROC,ListBoxProc_3
mov lpLstBox1_3, eax

invoke ListBox_3 ,240,20,200,200,hWin,501
mov hList2_3 , eax
invoke SetWindowLong,hList2_3 ,GWL_WNDPROC,ListBoxProc_3
mov lpLstBox1_3, eax

calllItem_SendMessage_to_hList2_3
return 0


.elseif uMsg == WM_CLOSE
szText TheText_3,"Please Confirm Exit"
invoke MessageBox,hWin,ADDR TheText_3,ADDR szDisplayName_3,MB_YESNO
.if eax == IDNO
return 0
.endif
;.endif

.ELSEIF uMsg==WM_LBUTTONDOWN

call LBUTTONDOWN_rou ; left button down ----
return 0
;.endif

.ELSEIF uMsg==WM_MOUSEMOVE

call LBUTTONDOWN_rou ; left button down ----
return 0
;.endif


;----------------------------------------------------------------------
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWin, ADDR ps
mov hdc,eax
;invoke GetClientRect,hWin, ADDR WINRect
;invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
; , DT_SINGLELINE or DT_CENTER or DT_VCENTER
; invokeDrawScene_main
;invoke EndPaint,hWin, ADDR ps

invoke GetClientRect,hWin, ADDR WINRect
invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
, DT_SINGLELINE or DT_CENTER or DT_VCENTER

invoke EndPaint,hWin, ADDR ps
return0
;-------------------------------------------------------------------------




.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif

invoke DefWindowProc,hWin,uMsg,wParam,lParam

ret

WndProc_3 endp


; ########################################################################

TopXY_3 proc wDim:DWORD, sDim:DWORD

shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension

return sDim

TopXY_3 endp

; ########################################################################

ListBox_3 proc a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD

szText lstBox,"ListBox"
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR lstBox,0,
WS_VSCROLL or WS_HSCROLL or WS_VISIBLE or \
WS_BORDER or WS_CHILD or \
LBS_HASSTRINGS or LBS_NOINTEGRALHEIGHT or \
LBS_DISABLENOSCROLL ,
a,b,wd,ht,hParent,ID,hInstance_3,NULL;
; LBS_DISABLENOSCROLL ,

; invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR lstBox,0,
; WS_VISIBLE or WS_CHILDWINDOW or ES_SUNKEN or \
; ES_MULTILINE or WS_VSCROLL or WS_HSCROLL or \
; ES_AUTOVSCROLL or ES_NOHIDESEL,
; a,b,wd,ht,hParent,ID,hInstance_3,NULL

ret

ListBox_3 endp

; #########################################################################

ListBoxProc_3 proc hCtl :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL IndexItem :DWORD
LOCAL Buffer[32] :BYTE

.if uMsg == WM_LBUTTONDBLCLK
jmp DoIt
.elseif uMsg == WM_CHAR
.if wParam == 13
jmp DoIt
.endif
.endif
jmp EndDo

DoIt:

invoke SendMessage,hCtl,LB_GETCURSEL,0,0
mov IndexItem, eax
invoke SendMessage,hCtl,LB_GETTEXT,IndexItem,ADDR Buffer

mov eax, hList1_3
.if hCtl == eax
szText CurSel1,"You selected from hList1_3 "
invoke MessageBox,hWnd_3 ,ADDR Buffer,ADDR CurSel1,MB_OK
.else
szText CurSel2,"You selected from hList2_3 "
invoke MessageBox,hWnd_3 ,ADDR Buffer,ADDR CurSel2,MB_OK
.endif

EndDo:

invoke CallWindowProc,lpLstBox1_3,hCtl,uMsg,wParam,lParam

ret

ListBoxProc_3 endp


lItem_SendMessage_to_hList2_3 proc

invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem1
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem2
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem3
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem1
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem2
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem3
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem1
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem2
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem3
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem1
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem2
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem3
invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4
ret
lItem_SendMessage_to_hList2_3 endp


LBUTTONDOWN_rou proc ; left button down ----

mov eax,mrmy_lParam
and eax,0ffffh
;mov hitpoint.x,eax
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer
print_dos_scr " , Y= " ;,13,10

mov eax,mrmy_lParam
shr eax,16
;mov hitpoint.y,eax
invoke dwtoa,eax,ADDR dos_str_buffer
invoke StdOut,ADDR dos_str_buffer
print_dos_scr " =>",13,10

;mov MouseClick,TRUE


;invoke InvalidateRect,hWnd,NULL,TRUE ;이루틴은 모든윈도의 페인트를 콜하게 한다
; invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR str_mouse_pressed
; print_dos_scr " mouse_pressed ===>",13,10
;invoke StdOut,ADDR dos_str_buffer
; print_dos_scr " =>",13,10

ret
LBUTTONDOWN_rou endp ; ----


;------------- window2 ----------------- code ---------- end -----------------------------

;-------------------------------- window 5 ---------------- begin ------------------

start5:

;call start6
;ret

invokeGetModuleHandle,NULL
movwindow5_hInstance, eax
invokeGetCommandLine
movwindow5_CommandLine,eax

invokewindow5_MainInit,window5_hInstance,NULL,window5_CommandLine,SW_SHOWDEFAULT
;callwindow5_MainInit ;,window5_hInstance,NULL,window5_CommandLine,SW_SHOWDEFAULT
ret
invokeExitProcess,eax
;----------------------------------------------------------------------


; --------------- Program main inits
; --------------- Program main inits
window5_MainInit PROC \ ;--------------- begin window5_MainInit start ------ opengl -------------
hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCALwc:WNDCLASSEX
LOCALWwd:DWORD
LOCALWht:DWORD
LOCALWtx:DWORD
LOCALWty:DWORD
LOCAL msg:MSG


szTextwindow5_szClassName,"Win32SDI_Class"
movwc.cbSize,sizeof WNDCLASSEX
movwc.style,0
mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_OWNDC

movwc.lpfnWndProc,offset window5_MainLoop
movwc.cbClsExtra,NULL
movwc.cbWndExtra,NULL
m2mwc.hInstance,hInst
movwc.hbrBackground,COLOR_WINDOWTEXT+1
movwc.lpszMenuName,NULL
movwc.lpszClassName,offset window5_szClassName
invokeLoadIcon,hInst,2
movwc.hIcon,eax
invokeLoadCursor,NULL,IDC_ARROW
movwc.hCursor,eax
movwc.hIconSm,0
invokeRegisterClassEx, ADDR wc
movWwd,400
movWht,420
invokeGetSystemMetrics,SM_CXSCREEN
invokeCenterForm,Wwd,eax
movdword ptr Wtx,350 ;eax
invokeGetSystemMetrics,SM_CYSCREEN
invokeCenterForm,Wht,eax
movdword ptr Wty, 150 ;eax
invokeCreateWindowEx,0,ADDR window5_szClassName,
ADDR window5_szDisplayName,
WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
Wtx,Wty, Wwd,Wht,\
;window1_width, window1_height, ; dd 100 , 100
NULL,NULL,
hInst,NULL
movwindow5_hWnd,eax
invokeLoadMenu,hInst,600
invokeSetMenu,window5_hWnd,eax
invokeShowWindow,window5_hWnd,SW_SHOWNORMAL
invokeUpdateWindow,window5_hWnd
;callDoEvents
;----------- window out ru.--- begin ---------------------------
;invoke UpdateWindow, window5_hWnd
;.WHILE TRUE
;invoke GetMessage, ADDR msg,NULL,0,0
;.BREAK .IF (!eax)
;invoke TranslateMessage, ADDR msg
;invoke DispatchMessage, ADDR msg
;.ENDW
;mov eax,msg.wParam
ret
;----------- window out ru.--- end -----------------------------
;------------------------------------------------------
;invoke MessageBox, NULL, addr ErrorMsg, addr Caption, 16

ret

window5_MainInit ENDP

; --------------- Program main loop
window5_MainLoop PROC hWin5:DWORD,w5_uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCALWINRect:RECT
LOCALPixFormat5:DWORD

LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC


; mov eax,hWin5
; mov mrmy_hWin,eax
; mov eax,w5_uMsg
; mov mrmy_uMsg,eax
; mov eax,wParam
; mov mrmy_wParam,eax
; mov eax,wParam;
; mov mrmy_wParam,eax
; mov eax,lParam
; mov mrmy_lParam,eax


.if w5_uMsg == WM_COMMAND
.if wParam == 1000
invokeSendMessage,hWin5,WM_SYSCOMMAND,SC_CLOSE,NULL
.endif
return0


.elseifw5_uMsg == WM_CREATE
invokeGetDC,hWin5
movwindow5_MainHDC,eax
movax,SIZEOF window5_PixFrm
movwindow5_PixFrm.nSize,ax
movwindow5_PixFrm.nVersion,1
movwindow5_PixFrm.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
movwindow5_PixFrm.dwLayerMask,PFD_MAIN_PLANE
movwindow5_PixFrm.iPixelType,PFD_TYPE_RGBA
movwindow5_PixFrm.cColorBits,8
movwindow5_PixFrm.cDepthBits,16
movwindow5_PixFrm.cAccumBits,0
movwindow5_PixFrm.cStencilBits,0
invokeChoosePixelFormat,window5_MainHDC,ADDR window5_PixFrm
movPixFormat5,eax
invokeSetPixelFormat,window5_MainHDC,PixFormat5,ADDR window5_PixFrm
oreax,eax
jzNoPixelFmt
invokewglCreateContext,window5_MainHDC
movwindow5_OpenDC,eax
invokewglMakeCurrent,window5_MainHDC,window5_OpenDC
invokeGetClientRect,hWin5,ADDR WINRect
;invokeGlInit,WINRect.right,WINRect.bottom
;invokeGlInit,WINRect.right,WINRect.top
NoPixelFmt:
return0


;.elseifw5_uMsg == WM_SIZE
;invokeGetClientRect,hWin5,ADDR WINRect
;invokeResizeObject,WINRect.right,WINRect.bottom
; invokeDrawScene_main
; invoke SendMessage,hList2_3 ,LB_ADDSTRING,0,ADDR lItem4
;
;return0
;


.elseifw5_uMsg == WM_CLOSE
szText window5_TheText,"Are you sure ?"
invokeMessageBox,hWin5,ADDR window5_TheText,ADDR window5_szDisplayName \
,MB_YESNO+MB_ICONQUESTION
.if eax == IDNO
return0
.endif
moveax,window5_OpenDC
oreax,eax
jzNoGlDC
; Delete our objects
invokeDeleteSpheres
invokewglDeleteContext,window5_OpenDC
NoGlDC:invokeReleaseDC,hWin5,window5_MainHDC
invokeDestroyWindow,hWin5
return0


;--------------------------------------------------------
.ELSEIF w5_uMsg==WM_LBUTTONDOWN
print_dos_scr "window 5 action test",13,10,13,10

call LBUTTONDOWN_rou ; left button down ----
return 0

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



;.ELSEIF w5_uMsg==WM_MOUSEMOVE
;print_dos_scr "window 5 action test",13,10,13,10

; call LBUTTONDOWN_rou ; left button down ----
; return 0
;.endif


.elseifw5_uMsg == WM_SIZE

;invoke ClearScreen
print_dos_scr "window 5 action test",13,10,13,10
;input "Enter Some Text > "
;invoke StdOut,eax ; return address in eax


;invokeGetClientRect,hWnd6,ADDR WINRect6
;invokewglMakeCurrent,w1_HDC,w1_OpenDC
invokewglMakeCurrent,window5_MainHDC,window5_OpenDC
;invokeResizeObject,WINRect6.right,WINRect6.bottom
callDrawScene_w6


return0










.ELSEIF w5_uMsg==WM_PAINT
invoke BeginPaint,hWin5, ADDR ps
mov hdc,eax
;invoke GetClientRect,hWin5, ADDR WINRect
;invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
; , DT_SINGLELINE or DT_CENTER or DT_VCENTER
; invokeDrawScene_main
;invoke EndPaint,hWin5, ADDR ps


;invokeGetClientRect,hWin5,ADDR WINRect
;invokeResizeObject,WINRect.right,WINRect.bottom
; invokeDrawScene_main
invoke GetClientRect,hWin5, ADDR WINRect
invoke DrawText, hdc,ADDR OurText,-1, ADDR WINRect \
, DT_SINGLELINE or DT_CENTER or DT_VCENTER

invoke EndPaint,hWin5, ADDR ps
return0
;-------------------------------------------------------------------------

.elseif w5_uMsg == WM_DESTROY
invokePostQuitMessage,NULL
return0
.endif
invokeDefWindowProc,hWin5,w5_uMsg,wParam,lParam
ret
window5_MainLoopENDP

;-------------------------------- window 5 ---------------- end --------------------


;------------- window6 ----------------- code ---------- begin ---------------------------

start6:

invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain6, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
ret
invoke ExitProcess,eax

WinMain6 proc \;-------------- window6 ---------------------------
hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, 0 ;CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc6
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
m2mwc.hInstance,hInst
;push hInstance
;pop wc.hInstance

mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName6
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc

; WS_OVERLAPPEDWINDOW,\
; CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
; WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN, \
INVOKE CreateWindowEx,NULL,ADDR ClassName6,ADDR AppName6,\
WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN, \
window6_scr , window6_scr+4 ,window6_scr+8, window6_scr+12,
NULL,NULL,\
hInst,NULL
mov hwnd,eax
invokeLoadMenu,hInst,600 ;추가
invoke ShowWindow, hwnd,SW_SHOWNORMAL

invoke UpdateWindow, hwnd
;.WHILE TRUE
;invoke GetMessage, ADDR msg,NULL,0,0
;.BREAK .IF (!eax)
;invoke TranslateMessage, ADDR msg
;invoke DispatchMessage, ADDR msg
;.ENDW
mov eax,msg.wParam
ret
WinMain6 endp

WndProc6 proc hWnd6:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCALPixFormat6:DWORD
LOCALWINRect6:RECT


.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL


.elseifuMsg == WM_CREATE
invokeGetDC,hWnd6 ;-->hWin
movwindow5_MainHDC,eax
movax,SIZEOF window5_PixFrm
movwindow5_PixFrm.nSize,ax
movwindow5_PixFrm.nVersion,1
movwindow5_PixFrm.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
movwindow5_PixFrm.dwLayerMask,PFD_MAIN_PLANE
movwindow5_PixFrm.iPixelType,PFD_TYPE_RGBA
movwindow5_PixFrm.cColorBits,8
movwindow5_PixFrm.cDepthBits,16
movwindow5_PixFrm.cAccumBits,0
movwindow5_PixFrm.cStencilBits,0
invokeChoosePixelFormat,window5_MainHDC,ADDR window5_PixFrm
movPixFormat6,eax
invokeSetPixelFormat,window5_MainHDC,PixFormat6,ADDR window5_PixFrm
oreax,eax
jzNoPixelFmt
invokewglCreateContext,window5_MainHDC
movwindow5_OpenDC,eax
invokewglMakeCurrent,window5_MainHDC,window5_OpenDC
invokeGetClientRect,hWnd6,ADDR WINRect6
invokeGlInit,WINRect6.right,WINRect6.bottom
;invokeGlInit,WINRect6.right,WINRect6.top
NoPixelFmt:
return0


.ELSEIF uMsg==WM_LBUTTONDOWN

call LBUTTONDOWN_rou ; left button down ----
return 0
;.endif

.ELSEIF uMsg==WM_MOUSEMOVE

call LBUTTONDOWN_rou ; left button down ----
return 0
;.endif


.elseifuMsg == WM_SIZE

;invoke ClearScreen
print_dos_scr "window 6 action test",13,10,13,10
;input "Enter Some Text > "
;invoke StdOut,eax ; return address in eax


invokewglMakeCurrent,window5_MainHDC,window5_OpenDC
invokeGetClientRect,hWnd6,ADDR WINRect6
;invokewglMakeCurrent,w1_HDC,w1_OpenDC
;invokewglMakeCurrent,window5_MainHDC,window5_OpenDC
;invokeResizeObject,WINRect6.right,WINRect6.bottom
callDrawScene_w6


return0


.ELSE
invoke DefWindowProc,hWnd6,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc6 endp


;--------------- window 6 -------------- code ------------ end -------------------


;--------------- window 7 -------------- code ------------ begin -----------------


start7:
invoke GetModuleHandle, NULL
mov hInstance, eax

invoke GetCommandLine
mov CommandLine, eax

invoke WinMain7,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
ret
invoke ExitProcess,eax

; #########################################################################

WinMain7 proc hInst :DWORD, ;-------------- window 7 -------------
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD

;====================
; Put LOCALs on stack
;====================

LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD

;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================

invoke LoadIcon,hInst,500 ; icon ID
mov hIcon7, eax

szText szClassName7,"Project_Class"

mov wc.cbSize, sizeof WNDCLASSEX
; mov wc.style, CS_BYTEALIGNWINDOW
mov wc.style, 0 ;CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc7
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName7
m2m wc.hIcon, hIcon7
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
m2m wc.hIconSm, hIcon7

invoke RegisterClassEx, ADDR wc

;================================
; Centre window at following size
;================================

m2m Wtx, window7_xywh
m2m Wty, window7_xywh +4
m2m Wwd, window7_xywh +8
m2m Wht, window7_xywh +12

; mov Wwd, 500
; mov Wht, 350
; invoke GetSystemMetrics,SM_CXSCREEN
; invoke TopXY7,Wwd,eax
; mov Wtx, eax
; invoke GetSystemMetrics,SM_CYSCREEN
; invoke TopXY7,Wht,eax
; mov Wty, eax

invoke CreateWindowEx,WS_EX_LEFT,
ADDR szClassName7,
ADDR szDisplayName7,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax

invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd,eax

invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd

;===================================
; Loop until PostQuitMessage is sent
;===================================
ret

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

return msg.wParam

WinMain7 endp

; #########################################################################

WndProc7 proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL var :DWORD
LOCAL caW :DWORD
LOCAL caH :DWORD
LOCAL Rct :RECT
LOCAL hDC :DWORD
LOCAL hBmp1 :DWORD
LOCAL hBmp2 :DWORD
LOCAL Ps :PAINTSTRUCT
LOCAL buffer1[128]:BYTE ; these are two spare buffers
LOCAL buffer2[128]:BYTE ; for text manipulation etc..


; LOCALWINRect7:RECT


.if uMsg == WM_COMMAND
.if wParam == 500
szText msg1,"Hi, you clicked the bitmap button"
invoke MessageBox,hWin,ADDR msg1,ADDR szDisplayName7,MB_OK
.endif

;======== menu commands ========
.elseif uMsg == WM_CREATE
; ------------------------------------
; the one and only bitmap button call
; ------------------------------------
; invoke BmpButton,hWin,0,0,203,204,500
invokeGetDC,hWin
movw7_HDC,eax
movax,SIZEOF PixFrm7
movPixFrm7.nSize,ax
movPixFrm7.nVersion,1
movPixFrm7.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
movPixFrm7.dwLayerMask,PFD_MAIN_PLANE
movPixFrm7.iPixelType,PFD_TYPE_RGBA
movPixFrm7.cColorBits,8
movPixFrm7.cDepthBits,16
movPixFrm7.cAccumBits,0
movPixFrm7.cStencilBits,0
invokeChoosePixelFormat,w7_HDC,ADDR PixFrm7
movPixFormat7,eax
invokeSetPixelFormat,w7_HDC,PixFormat7,ADDR PixFrm7
oreax,eax
jzNoPixel7Fmt
invokewglCreateContext,w7_HDC
movw7_OpenDC,eax
invokewglMakeCurrent,w7_HDC,w7_OpenDC
invokeGetClientRect,hWin,ADDR WINRect7
;invokeGlInit,WINRect.right,WINRect.bottom
;invokeGlInit,WINRect.right,WINRect.top
NoPixel7Fmt:


;----------------------------------------------
.ELSEIF uMsg==WM_LBUTTONDOWN
print_dos_scr "window 7 action test",13,10,13,10

; call LBUTTONDOWN_rou ; left button down ----
;------------------------------------------------

.elseifuMsg == WM_SIZE
print_dos_scr "window 7 WM_SIZE test",13,10,13,10

invokeGetClientRect,hWin,ADDR WINRect7
invokewglMakeCurrent,w7_HDC,w7_OpenDC
invokeResizeObject,WINRect7.right,WINRect7.bottom
call DrawScene_w7
ret

invokeGetClientRect,hWin,ADDR WINRect7
invokewglMakeCurrent,w1_HDC,w1_OpenDC
;movdword ptr WINRect7.right ,100
;movdword ptr WINRect7.bottom ,100
invokeResizeObject,WINRect7.right,WINRect7.bottom
invokeDrawScene_main


.elseif uMsg == WM_PAINT
invoke BeginPaint,hWin,ADDR Ps
mov hDC, eax
invoke Paint_Proc7,hWin,hDC
invoke EndPaint,hWin,ADDR Ps
return 0

.elseif uMsg == WM_CLOSE

.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif

invoke DefWindowProc,hWin,uMsg,wParam,lParam

ret

WndProc7 endp

; ########################################################################

TopXY7 proc wDim:DWORD, sDim:DWORD

shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension

return sDim

TopXY7 endp

; #########################################################################

Paint_Proc7 proc hWin:DWORD, hDC:DWORD

LOCAL btn_hi :DWORD
LOCAL btn_lo :DWORD
LOCAL Rct :RECT

invoke GetSysColor,COLOR_BTNHIGHLIGHT
mov btn_hi, eax

invoke GetSysColor,COLOR_BTNSHADOW
mov btn_lo, eax

return 0

Paint_Proc7 endp

;--------------- window 7 -------------- code ------------ end -------------------


;--------------- window 8 -------------- code ------------ begin -----------------


start8:
invoke GetModuleHandle, NULL
mov hInstance, eax

invoke GetCommandLine
mov CommandLine, eax

invoke WinMain8,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
ret
invoke ExitProcess,eax

; #########################################################################

WinMain8 proc hInst :DWORD, ;-------------- window 8 -------------
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD

;====================
; Put LOCALs on stack
;====================

LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD

;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================

invoke LoadIcon,hInst,500 ; icon ID
mov hIcon8, eax

szText szClassName8,"Project8_Class" ;이클라스네임이 앞의것과 같다면 이 윈도는
; 작동을 안하고 앞의 윈도우 안에서 프로세스가 수행된다

mov wc.cbSize, sizeof WNDCLASSEX
; mov wc.style, CS_BYTEALIGNWINDOW
mov wc.style, 0 ;CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc8
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName8
m2m wc.hIcon, hIcon8
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
m2m wc.hIconSm, hIcon8

invoke RegisterClassEx, ADDR wc

;================================
; Centre window at following size
;================================

; mov Wwd, 200
; mov Wht, 200
m2m Wwd, window8_xywh +8
m2m Wht, window8_xywh +12

invoke GetSystemMetrics,SM_CXSCREEN
invoke TopXY8,Wwd,eax
mov eax, window8_xywh
mov Wtx, eax

invoke GetSystemMetrics,SM_CYSCREEN
invoke TopXY8,Wht,eax
mov eax, window8_xywh +4
mov Wty, eax

invoke CreateWindowEx,WS_EX_LEFT,
ADDR szClassName8,
ADDR szDisplayName8, \
WS_OVERLAPPEDWINDOW,\
;WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax

invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd,eax

invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd

;===================================
; Loop until PostQuitMessage is sent
;===================================
ret

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

return msg.wParam

WinMain8 endp

; #########################################################################

WndProc8 proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL var :DWORD
LOCAL caW :DWORD
LOCAL caH :DWORD
LOCAL Rct :RECT
LOCAL hDC :DWORD
LOCAL hBmp1 :DWORD
LOCAL hBmp2 :DWORD
LOCAL Ps :PAINTSTRUCT
LOCAL buffer1[128]:BYTE ; these are two spare buffers
LOCAL buffer2[128]:BYTE ; for text manipulation etc..


; LOCALWINRect8:RECT


.if uMsg == WM_COMMAND
.if wParam == 500
szText msg8,"Hi, you clicked the bitmap button"
invoke MessageBox,hWin,ADDR msg8,ADDR szDisplayName8,MB_OK
.endif

;======== menu commands ========
.elseif uMsg == WM_CREATE
; ------------------------------------
; the one and only bitmap button call
; ------------------------------------
; invoke BmpButton,hWin,0,0,203,204,500
invokeGetDC,hWin
movw8_HDC,eax
movax,SIZEOF PixFrm8
movPixFrm8.nSize,ax
movPixFrm8.nVersion,1
movPixFrm8.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
movPixFrm8.dwLayerMask,PFD_MAIN_PLANE
movPixFrm8.iPixelType,PFD_TYPE_RGBA
movPixFrm8.cColorBits,8
movPixFrm8.cDepthBits,16
movPixFrm8.cAccumBits,0
movPixFrm8.cStencilBits,0
invokeChoosePixelFormat,w8_HDC,ADDR PixFrm8
movPixFormat8,eax
invokeSetPixelFormat,w8_HDC,PixFormat8,ADDR PixFrm8
oreax,eax
jzNoPixel8Fmt
invokewglCreateContext,w8_HDC
movw8_OpenDC,eax
invokewglMakeCurrent,w8_HDC,w8_OpenDC
invokeGetClientRect,hWin,ADDR WINRect8
invokeGlInit,WINRect8.right,WINRect8.bottom
;invokeGlInit,WINRect.right,WINRect.top
NoPixel8Fmt:


;----------------------------------------------
.ELSEIF uMsg==WM_LBUTTONDOWN
print_dos_scr "window 8 action test",13,10,13,10

; call LBUTTONDOWN_rou ; left button down ----
;------------------------------------------------

.elseifuMsg == WM_SIZE
print_dos_scr "window 8 WM_SIZE test",13,10,13,10

invokeGetClientRect,hWin,ADDR WINRect8
invokewglMakeCurrent,w8_HDC,w8_OpenDC
invokeResizeObject,WINRect8.right,WINRect8.bottom
call DrawScene_w8
ret

invokeGetClientRect,hWin,ADDR WINRect8
invokewglMakeCurrent,w1_HDC,w1_OpenDC
;movdword ptr WINRect8.right ,100
;movdword ptr WINRect8.bottom ,100
invokeResizeObject,WINRect8.right,WINRect8.bottom
invokeDrawScene_main


.elseif uMsg == WM_PAINT
invoke BeginPaint,hWin,ADDR Ps
mov hDC, eax
invoke Paint_Proc8,hWin,hDC

invokeGetClientRect,hWin,ADDR WINRect8
invokewglMakeCurrent,w8_HDC,w8_OpenDC
invokeResizeObject,WINRect8.right,WINRect8.bottom
call DrawScene_w8


invoke EndPaint,hWin,ADDR Ps
return 0

.elseif uMsg == WM_CLOSE

.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif

invoke DefWindowProc,hWin,uMsg,wParam,lParam

ret

WndProc8 endp

; ########################################################################

TopXY8 proc wDim:DWORD, sDim:DWORD

shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension

return sDim

TopXY8 endp

; #########################################################################

Paint_Proc8 proc hWin:DWORD, hDC:DWORD

LOCAL btn_hi :DWORD
LOCAL btn_lo :DWORD
LOCAL Rct :RECT

invoke GetSysColor,COLOR_BTNHIGHLIGHT
mov btn_hi, eax

invoke GetSysColor,COLOR_BTNSHADOW
mov btn_lo, eax

return 0

Paint_Proc8 endp

;--------------- window 8 -------------- code ------------ end -------------------


; --------------- Program end
end start

//------------------------------------ end of file ---------

Posted by 최명환7
,