Probleme mit Spritedarstellung DX8



  • Hi leute, ich weiss auch nicht warum das Bild nicht gezeichnet wird, es kommt keine Fehlermeldung vom compiler oder linker, das Fenster wird erstellt und bleibt einfach weiss. Hier mal der Code:

    #include <windows.h>
    #include <d3d8.h>
    #include <d3d8types.h>
    #include <D3dx8core.h>
    #include "main.h"
    
    //Globals
    
    //Fenstervariablen
    HINSTANCE W_Hi;
    HWND W_Hwnd;
    
    //Überprüfungsvariablen
    HRESULT W_rval;
    
    bool B_done;
    bool ini =false;
    
    //Direct X Typen
    LPDIRECT3D8        X_d3d8;
    LPDIRECT3DDEVICE8  X_d3dd8;
    LPD3DXSPRITE       X_sprite;
    LPDIRECT3DTEXTURE8 X_textur;
    LPDIRECT3DSURFACE8 X_backBuffer;
    D3DFORMAT X_format;
    //////////////////////////////////////////////////////////////
    
    //Prototypen
    
    bool XXX_Initalisieren(void);
    bool XXX_Release(void);
    void XXX_Render(void);
    //////////////////////////////////////////////////////////////
    
    // Funktionen und Methoden
    
    bool XXX_Initalisieren(void)
    
    {
     D3DPRESENT_PARAMETERS X_presparams;
     D3DDISPLAYMODE        X_display;
    
     	if( (X_d3d8 = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)
    
    	{
    
    		MessageBox(NULL,"Fehler beim erstellen des Direct3D Objektes","Fehler!",0);
      		return false;
     	}
    
    	ZeroMemory(&X_presparams,sizeof(D3DPRESENT_PARAMETERS));
    
    	if(!(X_d3d8->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &X_display)==D3D_OK))
    
    		{
            MessageBox(NULL,"Fehler beim herausfinden des Displayformates","Fehler!",0); 
    		return false;
    		}
    
    	X_presparams.Windowed=true;
    	X_presparams.BackBufferFormat = X_display.Format;
    	//X_presparams.BackBufferCount  = 0;
    	X_presparams.BackBufferWidth  = 800;
    	X_presparams.BackBufferHeight = 600;
        X_presparams.SwapEffect       = D3DSWAPEFFECT_COPY;
    	X_presparams.hDeviceWindow    = W_Hwnd;
    
    	X_format = X_display.Format;
    
    	W_rval = X_d3d8->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,W_Hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&X_presparams,&X_d3dd8);
    
    	if(!W_rval==D3D_OK)
    		{  
    		MessageBox(NULL,"Fehler beim erstellen des Devices.","Fehler!",0);
    		return false;
    		}
    
    	X_d3dd8->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &X_backBuffer);
    
       W_rval=D3DXCreateSprite(X_d3dd8,&X_sprite);
    
       if(!W_rval==D3D_OK)
          {
    	   MessageBox(NULL,"Fehler beim erstellen des Sprite Interfaces.","Fehler!",0);
    	   return false;
    	  }
    
       W_rval = D3DXCreateTextureFromFileEx(X_d3dd8,
    										"surface.bmp",
    										100,
    										100,
    										1,
    										0,
    										D3DFMT_A8R8G8B8,
    										D3DPOOL_DEFAULT,
    										D3DX_FILTER_NONE,
    										D3DX_FILTER_NONE,
    										0x00000000,
    										NULL,
    										NULL,
    										&X_textur);
       if(!W_rval==D3D_OK)
    		{
    		 MessageBox(NULL,"Fehler beim Laden der Textur.","Fehler!",0);
    	     return false;
    		}
    
    void XXX_Render(void);
    
    B_done = false;
    ini=true;
    return true;
    }
    
    //////////////////////////////////////////////////////////////
    
    bool XXX_Release(void)
    {
    if(X_textur!=NULL)
       X_textur->Release();
    
     X_sprite->Release();
     X_backBuffer->Release();
     X_d3dd8->Release();
     X_d3d8->Release();
     return true;
    }
    
    //////////////////////////////////////////////////////////////
    void XXX_Render(void)
    {
    
    	X_d3dd8->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(255,255,255),1.0f,0);
    
    	X_d3dd8->BeginScene();
    
    	X_sprite->Begin();
    	X_sprite->Draw(X_textur,NULL,NULL,NULL,0.0f,&D3DXVECTOR2(50,50),0xFFFFFFFF);
    	X_sprite->End();
    
    	X_d3dd8->EndScene();
    	X_d3dd8->Present(NULL,NULL,0,NULL);
    
    }
    //////////////////////////////////////////////////////////////
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
     switch(message)
    				{
    
    					case WM_DESTROY:
    						XXX_Release();
    						PostQuitMessage(0);
    						return 0;
    
    					case WM_PAINT:
    						if(ini){XXX_Render();}
    					 ValidateRect(W_Hwnd, NULL);
    					 return 0;
    
    				}	
    
     return(DefWindowProc(hwnd,message,wParam,lParam));  
    }
    //////////////////////////////////////////////////////////////
    WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nShowCmd)
    {
     MSG msg;
     char classname[] = "Fenster";
    
     WNDCLASSEX W_wndCl;
    
     W_wndCl.cbClsExtra = 0;
     W_wndCl.cbSize     = sizeof(WNDCLASSEX);
     W_wndCl.cbWndExtra = 0;
     W_wndCl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
     W_wndCl.hCursor       = LoadCursor(NULL,IDC_ARROW);
     W_wndCl.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
     W_wndCl.hIconSm       = LoadIcon(NULL,IDI_APPLICATION);
     W_wndCl.hInstance     = hInstance;
     W_wndCl.lpfnWndProc   = WndProc;
     W_wndCl.lpszClassName = classname;
     W_wndCl.lpszMenuName  = NULL;
     W_wndCl.style         = CS_HREDRAW | CS_VREDRAW;
    
     W_Hi = hInstance;
    
     if(!RegisterClassEx(&W_wndCl))
    	 return 0;
    
     W_Hwnd=CreateWindowEx(NULL,
    					   classname,
    					   "DXFENSTER",
    					   WS_POPUPWINDOW | WS_CAPTION,
    					   100,
    					   100,
    					   800,
    					   600,
    					   NULL,
    					   NULL,
    					   W_Hi,
    					   NULL);
    
     if(W_Hwnd==NULL)
    	return 0;
    
     ShowWindow(W_Hwnd,nShowCmd);
     UpdateWindow(W_Hwnd);
    
     XXX_Initalisieren();
     B_done=false;
     while(!B_done)
    
      {
       if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    		{ 
    			if (msg.message == WM_QUIT)
    				break;
    
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    
      }
    
     return (msg.wParam);
    }
    

    Die Prototypern für die Funktionen stehen da nur noch weil ich den Header code in den anderen code eingefügt habe. Mit seperaten dateien gings auch net 😞
    Könnt ihr mir nen Tipp geben? Wäre wirklich dankbar.

    Mfg Christian



  • Bitte noch die Ausgaben der Debug Runtimes angeben.

    Bye, TGGC \-/


Log in to reply