DirectDraw : Hilfe
-
Ich erhalte folgende Fehlermeldung:
--------------------Konfiguration: Catch - Win32 Debug-------------------- Kompilierung läuft... main.cpp Linker-Vorgang läuft... main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _DirectDrawCreateEx@16 main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _IID_IDirectDraw7 Debug/Catch.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise Fehler beim Ausführen von link.exe. Catch.exe - 3 Fehler, 0 Warnung(en)
Ich habe beim Linker ddraw.lib und dxguid.lib sowie als Header <windows.h> und <ddraw.h> eingebunden.Also wo liegt der Fehler?
Ich sag schonmal danke im Voraus!Hier der gesamte Quellcode(nur ca. 350 Zeilen bis jetzt):
main.cpp:
#include <windows.h> #include <stdio.h> #include "adx.h" // Grafik-Lib AnimaDirectX HWND hWnd; HINSTANCE hInstance; bool Keys[256]; bool Done = false; const int FrameRate = 40; int GameState = 1; const int G_MENU = 1; const int G_GAMESETUP = 2; const int G_OPTIONS = 3; const int G_PAUSE = 4; const int G_SHUTDOWN = 5; const int G_INGAME = 6; // === globale Funktionen === int GameInit(); void GameExit(); void GameMain(); // === Hauptfunktionen === LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) { switch(message) { case WM_DESTROY: { PostQuitMessage(0); return 0; } break; case WM_KEYDOWN: { Keys[wparam] = true; } break; case WM_KEYUP: { Keys[wparam] = false; } break; default:break; } return (DefWindowProc(hwnd,message,wparam,lparam)); } int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hprevinst,LPSTR lpcmdline,int ncmdshow) { WNDCLASSEX wc; MSG message; const char szclassname[] = "CCatch"; DWORD loop_start_time; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinst; wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szclassname; wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION); if(!RegisterClassEx(&wc)) { return 0; } if(!(hWnd = CreateWindowEx(NULL, szclassname, "Catch", WS_POPUPWINDOW | WS_VISIBLE, 0,0, 400,300, NULL, NULL, hinst, NULL))) { return 0; } ShowWindow(hWnd,ncmdshow); UpdateWindow(hWnd); // Spiel initialisieren und Fehler prüfen if(GameInit() > 0) { while(!Done) { loop_start_time = GetTickCount(); // Nachrichten verarbeiten if(PeekMessage(&message,NULL,0,0,PM_REMOVE)) { if(message.message == WM_QUIT) Done = true; TranslateMessage(&message); DispatchMessage(&message); } // Hauptfunktion des Spiels abarbeiten GameMain(); // Prüfen ob Benutzer das Spiel beenden will if(Keys[VK_ESCAPE]) PostQuitMessage(0); // Framerate bremsen while( (GetTickCount() - loop_start_time) < FrameRate); } } // Spiel beenden GameExit(); return message.wParam; } int GameInit() { return 1; } void GameMain() { switch(GameState) { case G_MENU: break; case G_OPTIONS: break; case G_INGAME: break; case G_GAMESETUP: break; case G_PAUSE: break; case G_SHUTDOWN: break; default:break; } } void GameExit() { }
adx.h:
#include <ddraw.h> // ADX - AnimaDirectX Grafik Bibliothek // globale Variablen,Strukturen,Klassen und Makros : const int ANIMM_ONEIMAGE = 0; const int ANIMM_LOOP = 1; const int ANIMM_NORMAL = 2; const int ANIMM_STOP = 3; typedef LPDIRECTDRAWSURFACE7 DDSURF; typedef DDSURFACEDESC2 DDSD; typedef COLORREF RGB; #define adxStructInit(st) ZeroMemory(&st,sizeof(st)); st.dwSize = sizeof(st) class CVertex { public: CVertex(); void SetPos(float nx,float ny); float x; float y; }; class CPolygon { public: CPolygon(int num_verts); ~CPolygon(); RGB line_color; RGB fill_color; float x; float y; CVertex* verts; void SetPos(float nx,float ny); void SetLColor(RGB ncolor); void SetFColor(RGB ncolor); }; class CAnimation { public: CAnimation(int num_frames); ~CAnimation(); DDSURF Frames[256]; int x,y; int num_frames; int width,height; void LoadFrame(int frame,char* file); int cur_frame; int mode; }; int adxScreenWidth = 1024; // Standarteinstellung für Breite int adxScreenHeight = 768; // Std-Einstellung für Höhe int adxScreenBpp = 32; // Std-Einstellung für Farbtiefe bool adxWindowed = false; // Std-Einstellung für Fenstermodus RGB adxFontColor = RGB(0,0,0); // Standartschriftfarbe int adxGLTransp = 0; // Globaler Draw-Transparency-Faktor int adxFontFamily = 0; int adxFontSize = 0; LPDIRECTDRAW7 lpDD7 = NULL; LPDIRECTDRAWCLIPPER lpDDClipper = NULL; DDSURF lpDDSPrimary = NULL; DDSURF lpDDSBack = NULL; DDSURF lpDDSCurSurf = NULL; DWORD* curRamDevice = NULL; int adxPitch = 0; int adxDDSWidth = 0; int adxDDSHeight = 0; int adxInit(int scrwidth,int scrheight,int scrbpp,bool windowed,HWND* hwnd); // ADX init void adxShutdown(); // ADX uninit void adxBegin(DDSURF surf = lpDDSBack); // Surface verriegeln zum zeichnen void adxEnd(DDSURF surf = lpDDSBack); // Surface wieder entriegeln void adxClear(RGB color,DDSURF surf = lpDDSBack); // Surface füllen void adxRender(); // Backbuffer in FrontBuffer kopieren void adxSetCurrentDevice(DDSURF surf = lpDDSBack); // Aktuelles Surface festlegen void adxSetGlobalTransparency(int transfactor=0); void adxSetFontSize(int size=1); void adxSetFontFamily(int family=0); void adxSetFontColor(RGB color); void adxDrawPixel(int x,int y,RGB color,bool clipped=true); void adxDrawLine(int x0,int y0,int x1,int y1,RGB color,bool clipped=true); void adxDrawRect(int x,int y,int width,int height,RGB color,bool filled,bool clipped=true); void adxDrawRoundRect(int x0,int y0,int x1,int y1,RGB color,bool filled,bool clipped=true); void adxDrawEllipse(int x0,int y0,int x1,int y1,RGB color,bool filled,bool clipped=true); void adxDrawPolygon(CPolygon* poly,bool filled,bool clipped=true); void adxTranslatePolygon(CPolygon* poly,int vx,int vy); void adxRotatePolygon(CPolygon* poly,float factor); void adxScalePolygon(CPolygon* poly,float factor); void adxCopySurface(DDSURF source,DDSURF dest,RECT rsrc,RECT rdest,DWORD flags,DDBLTFX* fx); void adxDrawImage(DDSURF image,int x,int y); void adxPlayAnimation(CAnimation* anim); DDSURF adxLoadImage(char* file,int width,int height); int adxError(char* msg); // === Definitionen === DDSURF adxLoadImage(char* file,int width,int height) { HDC hBmDC, hSurfDC; HBITMAP hBM; DDSD SurfDesc; DDSURF lpDDSurface; hBM = (HBITMAP)LoadImage(0,file,IMAGE_BITMAP,width,height,LR_LOADFROMFILE); if(NULL == hBM) return NULL; adxStructInit(SurfDesc); SurfDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; SurfDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; SurfDesc.dwWidth = width; SurfDesc.dwHeight = height; if(FAILED(lpDD7->CreateSurface(&SurfDesc,&lpDDSurface,NULL))) return NULL; lpDDSurface->GetDC(&hSurfDC); hBmDC = CreateCompatibleDC(hSurfDC); SelectObject(hBmDC,hBM); BitBlt(hSurfDC,0,0,width,height,hBmDC,0,0,SRCCOPY); lpDDSurface->ReleaseDC(hSurfDC); DeleteDC(hBmDC); DeleteObject(hBM); return lpDDSurface; } void adxClear(RGB color,DDSURF surf) // Surface füllen { DDBLTFX fx; adxStructInit(fx); fx.dwFillColor = color; surf->Blt(NULL,NULL,NULL,DDBLT_WAIT | DDBLT_COLORFILL,&fx); } int adxInit(int scrwidth,int scrheight,int scrbpp,bool windowed,HWND* hwnd) { adxScreenWidth = scrwidth; adxScreenHeight = scrheight; adxScreenBpp = scrbpp; adxWindowed = windowed; DDSD ddsd; DDSCAPS2 ddscaps; if(DD_OK != DirectDrawCreateEx(NULL,(LPVOID*)&lpDD7,IID_IDirectDraw7,NULL)) { return 0; MessageBox(*hwnd,"ADX - Error 001","error",MB_OK | MB_ICONERROR); } if(DD_OK != lpDD7->SetCooperativeLevel(*hwnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)) { return 0; MessageBox(*hwnd,"ADX - Error 002","error",MB_OK | MB_ICONERROR); } if(DD_OK != lpDD7->SetDisplayMode(adxScreenWidth,adxScreenHeight,adxScreenBpp,0,0)) { return 0; MessageBox(*hwnd,"ADX - Error 003","error",MB_OK | MB_ICONERROR); } adxStructInit(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; if(DD_OK != lpDD7->CreateSurface(&ddsd,&lpDDSPrimary,NULL)) { return 0; MessageBox(*hwnd,"ADX - Error 004","error",MB_OK | MB_ICONERROR); } ZeroMemory(&ddscaps,sizeof(ddscaps)); ddscaps.dwCaps = DDSCAPS_BACKBUFFER; if(DD_OK != lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack)) { return -1; MessageBox(*hwnd,"ADX - Error 005","error",MB_OK | MB_ICONERROR); } // Clipper anlegen if(FAILED(lpDD7->CreateClipper(NULL,&lpDDClipper,NULL))) { return adxError("Fehler beim anlegen des Clipper"); } // Clipper mit dem Fenster verbinden if(FAILED(lpDDClipper->SetHWnd(0,*hwnd))) { return adxError("Fehler bei SetHWnd"); } // Clipper mit der Oberfläche verbinden if(FAILED(lpDDSPrimary->SetClipper(lpDDClipper))) { return adxError("Fehler beim Verbinden des Clippers"); } adxClear(RGB(255,255,255),lpDDSPrimary); adxClear(RGB(255,255,255),lpDDSBack); return 1; } int adxError(char* msg) { MessageBox(0,msg,"ADX - Error",MB_OK | MB_ICONERROR); return -1; } void adxRender() { HRESULT res; res = lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); if(DD_OK != res) adxError("ADX - Error 007"); else if(DDERR_SURFACELOST == res) { if(DD_OK != lpDDSPrimary->Restore()) adxError("ADX - Error 008"); if(DD_OK != lpDDSPrimary->Flip(NULL,DDFLIP_WAIT)) adxError("ADX - Error 009"); } } void adxShutdown() { /* LPDIRECTDRAW7 lpDD7 = NULL; LPDIRECTDRAWCLIPPER lpDDClipper = NULL; DDSURF lpDDSPrimary = NULL; DDSURF lpDDSBack = NULL; DDSURF lpDDSCurSurf = NULL; */ if(lpDDSCurSurf!=NULL) lpDDSCurSurf->Release(); if(lpDDSBack!=NULL) lpDDSBack->Release(); if(lpDDSPrimary!=NULL) lpDDSPrimary->Release(); if(lpDDClipper!=NULL) lpDDClipper->Release(); if(lpDD7!=NULL) lpDD7->Release(); } void adxBegin(DDSURF surf) { DDSD ddsd; adxStructInit(ddsd); surf->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL); adxPitch = ddsd.lPitch; adxDDSWidth = ddsd.dwWidth; adxDDSHeight = ddsd.dwHeight; curRamDevice = (DWORD*)ddsd.lpSurface; } void adxEnd(DDSURF surf) { surf->Unlock(NULL); }
-
Hast du das Verzeichniss, in dem die SDK-Dateien sind, ganz nach oben geschoben.
Sonst nimmt VC die alten DXSDK Dateien.
-
Yep,habe ich gemacht...ich verstehe das nicht!
-
bei mir klappt der code. hast vielleicht die libs vergessen?
ddraw.lib and dxguid.lib
-
Hast du auch beide Pfade (für Header und libs) ganz oben stehen?
-
Bei mir tritt genau der gleiche Fehler auf. Aber ich habe echt keine Idee, was ihr mit dem Verzeichniss, dass nach ganz oben geschrieben werden soll meint.
Wäre euch bei Hilfe wirklich dankbar!