News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

directx crash

Started by ragdog, October 28, 2007, 09:11:04 PM

Previous topic - Next topic

ragdog

hi

i have problem with my directx9  app i compile my app and it crash by createdevice
can your help me by solve my problem please


InitD3D PROC WindowHandle:DWORD
   
   invoke LoadLibrary,addr d3d9      
mov h_d3d9_dll,eax               
invoke GetProcAddress,h_d3d9_dll,addr szD3DCreate   
mov ecx,eax                  

push D3D_SDK_VERSION            
                     
call ecx                  
.if eax == 0               
    ret                     
.endif                     
mov pd3d,eax                  

push offset pd3d_device               
                     
push offset g_pp               
push D3DCREATE_SOFTWARE_VERTEXPROCESSING      
push WindowHandle               
push D3DDEVTYPE_HAL               
push D3DADAPTER_DEFAULT               
mov eax,pd3d
push eax
mov ecx,[eax]
call dword ptr [ecx+CreateDevice]         

.if pd3d_device == 0               
    xor eax,eax                  
    ret                     ;
.endif

;invoke LoadLibrary,addr d3dx9
;invoke GetProcAddress,eax,addr szD3DXCreateSprite
;mov ecx,eax

;invoke D3DXCreateSprite,pd3dDevice,offset LPD3DXSPRITE
;invoke texture,offset D_BEGIN,SjZE,addr sprt,D3DCOLOR_ARGB(255, 4, 254, 252)

   ret

InitD3D endp

thanks in forward
ragdog

gabor

Hi ragdog!

Have you tried to determine the crash reason using a debugger?
I can think of 2 things since your call seems okay:
1. Some of the parameters are not valid. Only the D3DPRESENT_PARAMETERS structure pointed by g_pp could be incorrect.

mov pd3d,eax
push offset pd3d_device
push offset g_pp ; <== DOES THIS REFER TO AN INITIALIZED STRUCT?

Is this D3DPRESENT_PARAMETERS structure pointed by g_pp initialized?
I think it must specify a valid BackBufferFormat, and whether the app should run windowed or full-screen.
g_pp->Windowed and g_pp->BackBufferFormat, I also set the g_pp->SwapEffect member.


2. Can you be 100% sure that the CreateDevice symbol in your call adds the correct offset value?
(Offset to the member method in the DIRECT3D9 struct?)

push D3DCREATE_SOFTWARE_VERTEXPROCESSING
push WindowHandle
push D3DDEVTYPE_HAL
push D3DADAPTER_DEFAULT
mov eax,pd3d
push eax
mov ecx,[eax]
call dword ptr [ecx+CreateDevice] ; <== I MEAN THIS CALL

Maybe this would be better (IDirect3D9 is the structure name of the D3D object):

call dword ptr [ecx+IDirect3D9.CreateDevice]


I hope I was able to help :)

Greets, Gábor


ragdog

#2
thanks for your help

i have a another problem with D3DXCreateTextureFromFileExA using png files
this png indicated however my CpU rises to 100% :'(

    invoke GetProcAddress,hd3dx9,addr szD3DXCreateTextureFromFileExA
       mov ecx,eax   
      push pTexture
      push 0
      push 0
      push text_color
      push D3DX_DEFAULT
      push D3DX_FILTER_NONE
      push D3DPOOL_MANAGED
      push D3DFMT_A8R8G8B8
      push 0
      push 1
      push 0
      push 0
      push offset fl
      push pd3d_device
      call ecx
   
        comment # 
     invoke D3DXCreateTextureFromFileExA,pd3dDevice,addr fl,0,0,1,0,\
     D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE,D3DX_DEFAULT,\
     text_color,0,0,pTexture
#


sorry for my english :wink

greets
ragdog