flat assembler
Message board for the users of flat assembler.
Index
> Windows > DirectDraw in windowed mode |
Author |
|
vid 24 Jul 2004, 14:58
problem might be that you created window of bad size. Depending on drawing method, client window sizes must be same as sizes of backbuffer, otherwise directdraw performs stretching (slow).
Check client window sizes. |
|||
24 Jul 2004, 14:58 |
|
proveren 25 Jul 2004, 05:58
Actually I had a very stupid syntax error where I forgot to put the [] around a variable and instead of creating a backbuffer in windowed mode with dimensions 320/240 it creates a surface with size dword addresses like 40040444/40040448 for example.
Anyway, I am almost finished with my ddraw code and I want to upload it here as a template to end any ddraw difficulties for fasm coders. It is very flexible as it supports changing of modes, automatically restoring of surfaces, clean message pump etc. However, I would like it if you could tell me how I can make the client rect the size of my backbuffer in windowed mode. This is important in some applications(and for some speed issues?) .There isn't a function SetClientRect after all. |
|||
25 Jul 2004, 05:58 |
|
vid 25 Jul 2004, 12:50
There is API sunc GetSystemMetrics, which reads some parameters (size of window border, height of caption etc.) You can use these to get these sizes (the vary with different windows styles, like "windows classic" or "window XP") If you have DirectX SDK (i quess you have) take a look at windowed mode example, and at "DDutil" common include it uses.
|
|||
25 Jul 2004, 12:50 |
|
S.T.A.S. 25 Jul 2004, 19:14
The simplest way to set client rect size I've found is using of WM_WINDOWPOSCHANGING message.
This works well when user changes XP styles etc, while app is running. Code: ;; [Height] & [Width] - client rect size ...... CreateWindow(Ex) with [Height] & [Width] ....... ;; WM_WINDOWPOSCHANGING handler mov edx, [lParam] ;; Pointer to a WINDOWPOS structure test byte[edx+WINDOWPOS.flags], SWP_SHOWWINDOW jz @f sub esp, sizeof.RECT ;; local var invoke GetClientRect,[hwnd], esp mov edx, [lParam] ;; Pointer to a WINDOWPOS structure mov eax, [Width] add eax, eax sub eax, [esp+RECT.right] mov [edx+WINDOWPOS.cx], eax mov eax, [Height] add eax, eax sub eax, [esp+RECT.bottom] mov [edx+WINDOWPOS.cy], eax and [edx+WINDOWPOS.flags],NOT SWP_NOSIZE add esp, sizeof.RECT ;; release stack @@: |
|||
25 Jul 2004, 19:14 |
|
proveren 28 Jul 2004, 09:17
hmm, S.T.A.S. , I neither understand what exactly your code does and when it does it, and where I should include it in my source. I put it in a the message handler when the message WM_WINDOWPOSCHANGING was met but it didn't do anything. Could you explain it please!
|
|||
28 Jul 2004, 09:17 |
|
S.T.A.S. 29 Jul 2004, 02:01
Ok, here's quick example of use.
Idea is very simple, when window is about to be displayed, we just override cx & cy members of WINDOWPOS structure. MSDN wrote: While this message is being processed, modifying any of the values in WINDOWPOS affects the window's new size, position, or place in the Z order. So, when windows is being created and this message is processed first time, cx = width of window (250). But we want client rect's whidth to be 250, so we need to modify cx. New value is calculated this way: desired client whidth + dx dx = 250 - currend client width ;; left + right border or: 2*250-currend client width Try to comment "je .WM_WINDOWPOSCHANGING" line and se the difference Code: include '%fasminc%\WIN32AX.INC' IMAGE_BASE = 400000h start: xor ebx, ebx mov esi, IMAGE_BASE mov edi, wc invoke LoadCursor, ebx,IDC_ARROW mov [edi+WNDCLASSEX.hCursor], eax invoke LoadIcon, esi,IDI_APPLICATION mov [edi+WNDCLASSEX.hIcon], eax mov [edi+WNDCLASSEX.hIconSm],eax invoke RegisterClassEx, edi add edi, sizeof.WNDCLASSEX ;; = wc.Name invoke CreateWindowEx,ebx,edi,caption,\ WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE,\ CW_USEDEFAULT,CW_USEDEFAULT,[Width],[Height],ebx,ebx,esi,ebx msg_loop: invoke GetMessage,msg,ebx,ebx,ebx or eax,eax jz end_loop invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc WndProc, hwnd,wmsg,wparam,lparam mov dx,word[wmsg] cmp dx,WM_PAINT je .WM_PAINT cmp dx,WM_WINDOWPOSCHANGING je .WM_WINDOWPOSCHANGING cmp dx,WM_DESTROY je .WM_DESTROY .def: leave jmp [DefWindowProc] .WM_PAINT: invoke BeginPaint, [hwnd],ps invoke GetClientRect, [hwnd], rect invoke wsprintf, txt,form,[rect.right],[rect.bottom] ;add esp,4*4 invoke TextOut, [ps.hdc],0,0,txt,eax invoke EndPaint, [hwnd],ps jmp .def .WM_WINDOWPOSCHANGING: mov edx,[lparam] ;; Pointer to a WINDOWPOS structure test byte[edx+WINDOWPOS.flags], SWP_SHOWWINDOW jz .def push edx invoke GetClientRect,[hwnd], rect pop edx mov eax, [Width] add eax, eax sub eax, [rect.right] mov [edx+WINDOWPOS.cx], eax mov eax, [Height] add eax, eax sub eax, [rect.bottom] mov [edx+WINDOWPOS.cy], eax and [edx+WINDOWPOS.flags],NOT SWP_NOSIZE jmp .def .WM_DESTROY: invoke PostQuitMessage, 0 jmp .def endp align 4 msg MSG ps PAINTSTRUCT rect RECT Width dd 250 Height dd 200 wc dd sizeof.WNDCLASSEX,0,WndProc,0,0,IMAGE_BASE,0,0,\ COLOR_WINDOW+1,0,.Name,0 .Name db 'MyWndClass',0 caption db 'Just some window',0 form db 'client rect size: x=%04ld, y=%04ld',0 txt rb 20 .end start |
|||
29 Jul 2004, 02:01 |
|
proveren 29 Jul 2004, 09:26
Hey, that's nice, now I got it, thanks. However, I am using another method because I want the user to be able to resize it and set the client are to the desired one from the menu.
|
|||
29 Jul 2004, 09:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.