Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- format PE GUI 4.0
- entry start
- include 'win32w.inc'
- include 'egna\opengl32_equate.inc'
- ;include 'egna\glu32_equate.inc'
- ;---------------------------------------
- section '.data' data readable writeable
- _class du 'FASMWIN32',0
- _title du 'title',0
- _error du 'error',0
- hwnd dd ?
- clock dd ?
- theta GLfloat 0.6
- hdc dd ? ;device context handle
- hrc dd ?
- pfd PIXELFORMATDESCRIPTOR
- rc RECT
- wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
- msg MSG
- ;---------------------------------------
- ;section '.rsrc' resource data readable
- ;
- ; directory 24,manifests
- ; resource manifests,1,LANG_NEUTRAL,manifest
- ;
- ; resdata manifest
- ; file 'include\egna\manifest.xml'
- ; endres
- ;---------------------------------------
- section '.text' code readable executable
- start:
- invoke GetModuleHandle,0
- mov [wc.hInstance],eax
- invoke LoadIcon,0,IDI_APPLICATION
- mov [wc.hIcon],eax
- invoke LoadCursor,0,IDC_ARROW
- mov [wc.hCursor],eax
- invoke RegisterClass,wc
- test eax,eax
- jz error
- invoke CreateWindowEx,NULL,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_MINIMIZEBOX+WS_SYSMENU,500,250,640,640,NULL,NULL,[wc.hInstance],NULL
- mov [hwnd],eax
- test eax,eax
- jz error
- msg_loop:
- invoke GetMessage,msg,NULL,0,0
- or eax,eax
- jz end_loop
- invoke TranslateMessage,msg
- invoke DispatchMessage,msg
- jmp msg_loop
- error:
- invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK
- end_loop:
- invoke ExitProcess,[msg.wParam]
- ;---------------------------------------
- proc WindowProc uses ebx esi edi,hwnd,wmsg,wparam,lparam ;windows procedure. ebx,esi,edi modifieras aldrig av windås API
- cmp [wmsg],WM_CREATE
- je .wmcreate
- ; cmp [wmsg],WM_SIZE
- ; je .wmsize
- cmp [wmsg],WM_PAINT
- je .wmpaint
- ; cmp [wmsg],WM_COMMAND
- ; je .wmcommand
- cmp [wmsg],WM_KEYDOWN
- je .wmkeydown
- cmp [wmsg],WM_DESTROY
- je .wmdestroy
- .defwndproc:
- invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
- jmp .finish
- .wmcreate:
- invoke GetDC,[hwnd]
- mov [hdc],eax
- mov edi,pfd
- mov ecx,sizeof.PIXELFORMATDESCRIPTOR shr 2
- xor eax,eax
- rep stosd
- mov [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR
- mov [pfd.nVersion],1
- mov [pfd.dwFlags],PFD_SUPPORT_OPENGL+PFD_DOUBLEBUFFER+PFD_DRAW_TO_WINDOW
- mov [pfd.iLayerType],PFD_MAIN_PLANE
- mov [pfd.iPixelType],PFD_TYPE_RGBA
- mov [pfd.cColorBits],16
- mov [pfd.cDepthBits],16
- mov [pfd.cAccumBits],0
- mov [pfd.cStencilBits],0
- invoke ChoosePixelFormat,[hdc],pfd
- invoke SetPixelFormat,[hdc],eax,pfd
- invoke wglCreateContext,[hdc]
- mov [hrc],eax
- invoke wglMakeCurrent,[hdc],[hrc]
- invoke GetClientRect,[hwnd],rc
- invoke glViewport,0,0,[rc.right],[rc.bottom]
- invoke GetTickCount
- mov [clock],eax
- xor eax,eax
- jmp .finish
- ; .wmsize:
- ; invoke GetClientRect,[hwnd],rc
- ; invoke glViewport,0,0,[rc.right],[rc.bottom]
- ; xor eax,eax
- ; jmp .finish
- .wmpaint:
- ;invoke ValidateRect,[hwnd],NULL
- invoke GetTickCount
- sub eax,[clock]
- cmp eax,10
- jb .animation_ok
- add [clock],eax
- invoke glRotatef,[theta],0.1,0.5,0.7
- .animation_ok:
- invoke glClear,GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
- invoke glEnable,GL_DEPTH_TEST
- invoke glEnable,GL_LIGHTING
- invoke glEnable,GL_LIGHT0
- invoke glDisable,GL_COLOR_MATERIAL
- invoke glBegin,GL_QUADS
- invoke glNormal3f,0.0,0.0,1.0
- invoke glColor3f,1.0,0.6,0.4
- invoke glVertex3f,-0.5,0.5,0.5
- invoke glColor3f,0.4,1.0,0.6
- invoke glVertex3f,-0.5,-0.5,0.5
- invoke glColor3f,0.6,0.4,1.0
- invoke glVertex3f,0.5,-0.5,0.5
- invoke glColor3f,1.0,0.6,0.4
- invoke glVertex3f,0.5,0.4,0.3
- invoke glNormal3f,1.0,0.0,0.0
- invoke glColor3f,1.0,0.6,0.4
- invoke glVertex3f,0.5,0.5,0.5
- invoke glColor3f,0.4,1.0,0.6
- invoke glVertex3f,0.5,-0.5,0.5
- invoke glColor3f,0.6,0.4,1.0
- invoke glVertex3f,0.5,-0.5,-0.5
- invoke glColor3f,1.0,0.6,0.4
- invoke glVertex3f,0.5,0.5,-0.5
- invoke glNormal3f,-1.0,0.0,0.0
- invoke glColor3f,0.3,0.7,1.0
- invoke glVertex3f,-0.5,0.5,-0.5
- invoke glColor3f,1.0,0.3,0.7
- invoke glVertex3f,-0.5,-0.5,-0.5
- invoke glColor3f,0.7,1.0,0.3
- invoke glVertex3f,-0.5,-0.5,0.5
- invoke glColor3f,0.3,0.7,1.0
- invoke glVertex3f,-0.5,0.5,0.5
- invoke glNormal3f,0.0,0.0,-1.0
- invoke glColor3f,0.3,0.7,1.0
- invoke glVertex3f,0.5,0.5,-0.5
- invoke glColor3f,1.0,0.3,0.7
- invoke glVertex3f,0.5,-0.5,-0.5
- invoke glColor3f,0.7,1.0,0.3
- invoke glVertex3f,-0.5,-0.5,-0.5
- invoke glColor3f,0.3,0.7,1.0
- invoke glVertex3f,-0.5,0.5,-0.5
- invoke glNormal3f,0.0,-1.0,0.0
- invoke glColor3f,1.0,0.0,0.0
- invoke glVertex3f,0.5,0.5,0.5
- invoke glColor3f,0.0,1.0,0.0
- invoke glVertex3f,0.5,0.5,-0.5
- invoke glColor3f,0.0,0.0,1.0
- invoke glVertex3f,-0.5,0.5,-0.5
- invoke glColor3f,1.0,0.0,0.0
- invoke glVertex3f,-0.5,0.5,0.5
- invoke glNormal3f,0.0,-1.0,0.0
- invoke glColor3f,0.0,0.0,1.0
- invoke glVertex3f,-0.5,-0.5,0.5
- invoke glColor3f,0.0,1.0,0.0
- invoke glVertex3f,-0.5,-0.5,-0.5
- invoke glColor3f,1.0,0.0,0.0
- invoke glVertex3f,0.5,-0.5,-0.5
- invoke glColor3f,0.0,0.0,1.0
- invoke glVertex3f,0.5,-0.5,0.5
- invoke glEnd
- invoke SwapBuffers,[hdc]
- xor eax,eax
- jmp .finish
- ; .wmcommand:
- ; jmp .finish
- .wmkeydown:
- cmp [wparam],VK_ESCAPE
- jne .defwndproc
- .wmdestroy:
- invoke wglMakeCurrent,0,0
- invoke wglDeleteContext,[hrc]
- invoke ReleaseDC,[hwnd],[hdc]
- invoke PostQuitMessage,0
- xor eax,eax
- .finish:
- ret
- endp
- ;---------------------------------------
- section '.idata' import data readable writeable
- library kernel32,'KERNEL32.DLL', user32,'USER32.DLL',\
- shell32,'SHELL32.DLL', gdi32,'GDI32.DLL',\
- opengl32,'OPENGL32.DLL';,comctl32,'comctl32.dll',\
- ;glu32,'GLU32.DLL'
- include 'api\kernel32.inc'
- include 'api\user32.inc'
- include 'api\shell32.inc'
- include 'api\gdi32.inc'
- ; include 'api\comdlg32.inc'
- include 'egna\opengl32.inc'
- ; include 'egna\glu32.inc'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement