look at where you load bitmap to surface ;

after getting dc with IDirectDrawSurface7_GetDC method, you can call any gdi-functions (like textout).

just write your text on dds_back surface after all of the balls are
painted and before you blt it to primary surface.
Posted on 2001-12-11 18:07:19 by kamilh
ok,

now nearly everything is clear. thank you again for your help. but there is still the slow loop, it is the same slow as with gdi. as i told you, the only thing that has changed is, that the program reacts much faster on mouse or keyboard input.

btw: i could imagine, that TextOut is pretty slow, too, but i need to call it everytime the loop ends as it seems. because the screen is deleted after all balls have been painted (after every main loop). am i right, or doesn't textout affect the speed much? is there perhaps a directdraw textout function?

nop
Posted on 2001-12-12 14:20:18 by NOP-erator
nop erator , it think you should separate your kugproc and drawball procs (just calculate all balls positions first and draw balls later) and we can se how much time takes ball painting , how often wm_paint message received, etc.

no textout is not so slow, i did a teletext prg with textout to write chars : 40*25 times textout called 50 times per second, it takes %1 of cpu time on my athlon1.4, now i'm doing samething with same method you are using (every char is a rect on bitmap, and i blt them to offscreen surface), i cant see any speed difference.

try to make a separate thread for kugproc and do the job without waiting for paint message.. i think it will be much more faster.
Posted on 2001-12-12 16:57:14 by kamilh
nop-erator here is modified version of you testdcc project (use thread for kugproc), it shows 420 fps on my system , what do you want more from God:)

i found a small bug in your kugproc ; sometimes kugproc gives -1 as y coordinate (possibly a mistake when converting from center coords to rect coords) and in this case blt operation fails.
i got this result after setting initial velocity to 10x then yours. i dont know if it can be the reason of the bug or not.
Posted on 2001-12-12 17:57:44 by kamilh
yeah, the bug seems to be the high velocity. but anyways, thanks for this thread stuff. unfortunately it is not much faster than the normal method. i know changed the message loop, and will change the thing you told me: first calculating, then drawing everything.

btw: is there really no possibility to kind of split the window up, where on the one part there is the directx window, and on the lower part, there are controls like buttons and stuff......


nop
Posted on 2001-12-13 09:30:01 by NOP-erator
dest rect used by blt is ps.rcPaint ; so if you insert a line (before blt line) like
sub ps.rcPaint.bottom,n ; n=height of the bottom part of window where you put controls
you'll see controls on screen.
but it will change aspect-ratio of the balls, increase your window size (where you call createwindowex) by n to prevent this.
Posted on 2001-12-13 11:23:05 by kamilh
sorry, what is the aspect-ratio?
Posted on 2001-12-13 11:30:11 by NOP-erator
i always forget to ask something else: if i would use directinput for a game, is it then possible that two players on one keyboard press two or more keys at the same time, and my program will get them all? if yes, who to initialize direct input? what include files do i need? perhaps some code examples?

thanks
Posted on 2001-12-13 11:33:39 by NOP-erator
nop.. i dont know anything about direct input..

and here is last improvement for testdcc ;
your window size is 640*480 (including border and caption), so client size is 640-sx,480-sy (s=some) , offscreen surface size is 640*480 : blt from 640*480 offscreen to 640-sx,480-sy clientrect becomes non arithmetic stretched blt.
so try to make your window clientrect size 640*480 (look adjustwindowrectex on win32hlp)

and an important thing from ddraw.hlp :

RECT structures are defined so that the right and bottom members are exclusive?therefore, right minus left equals the width of the rectangle, not 1 less than the width.

that's why i commented "dec eax" lines in putball proc.
Posted on 2001-12-13 14:40:00 by kamilh
Yes, using DirectInput 2 players can use the same keyboard, Directinput will (using GetDevice State for a simple example) return you a 256 bytes vector with a byte representing status for each key on the keyboard...

But There can be another problem:

NOT all keyboards allow safe pressing of more then 3 keys at the same time....this can disturb your gameplay a lot...because one player will simulate keypress for the other player.

Some keyboards have this proble and some do not...this is the quiz :(

some code example



;********************************
; Direct Input Init
; and CORE functions
;********************************

.data
ALIGN 4

;==========================================
; static guids for expected devices
;==========================================
GUID_SysMouse dd 06F1D2B60h
dw 0D5A0h
dw 011CFh
db 0BFh
db 0C7h
db 044h
db 045h
db 053h
db 054h
db 000h
db 000h

GUID_SysKeyboard dd 06F1D2B61h
dw 0D5A0h
dw 011CFh
db 0BFh
db 0C7h
db 044h
db 045h
db 053h
db 054h
db 000h
db 000h

.code



extern DirectInputCreateA:PROC


;***************************************
; Main Direct Input Initializations
;****************************************
Direct_Input_Init:

Call Create_Direct_Input_Object
; [b] ... ignore mouse [/b]
call Create_Direct_Input_Device_Mouse
call Set_Data_Format_Mouse
call Set_Cooperative_Level_Mouse
call Acquire_Mouse


call Create_Direct_Input_Device_Keyboard
call Set_Data_Format_Keyboard
call Set_Cooperative_Level_Keyboard
call Acquire_Keyboard

;-----------------------------
; do this at exit
;-----------------------------
; call Release_Direct_Input_Object
ret

.data
ALIGN 4
;
lp_di_main_object dd 0

szDirectInputCreateFail db ' Direct Input Create Failed! ',0

DI_object_OK db 'DI CREATE OBJECT OK!',0
.code

Create_Direct_Input_Object:
;============================

mov eax,0 ;null not used
push eax

mov eax,offset lp_di_main_object
push eax

mov eax,DirectInputVersion3
; mov eax,DirectInputVersion5
push eax

mov eax,[hinstmain]
push eax

call DirectInputCreateA

.IF eax!=DI_OK
Call OutputDebugValue,eax
Call OutputDebugStringA,offset szDirectInputCreateFail
call Fail, hwndmain, offset szDirectInputCreateFail
jmp end_loop
.ENDIF

Call OutputDebugStringA,offset DI_object_OK

ret

;[b].... some code missing here [/b]

Read_Keyboard:
;=============

call save_to_old_state_key


;===========================================
;acquire
; mov eax,[lp_di_keyboard_device]
; push eax
; mov eax,[eax]
; call [eax+DID_Acquire]
call Acquire_Keyboard
;============================================



mov eax, offset keyboard_state01
push eax

mov eax,256
push eax

mov eax,[lp_di_keyboard_device]
push eax
mov eax,[eax]
call [eax+DID_GetDeviceState]

.IF eax!=DI_OK
Call OutputDebugValue,eax
Call OutputDebugStringA,offset szDIKeyboardGetDeviceStateFail
call Fail, hwndmain, offset szDIKeyboardGetDeviceStateFail
jmp end_loop
.ENDIF

; Call OutputDebugStringA,offset szDIKeyboardGetDeviceStateOK

ret



Posted on 2001-12-13 18:02:17 by BogdanOntanu