Sign in to follow this  
RolanDParijs

'bitmap_surface' : undeclared identifier

Recommended Posts

RolanDParijs    122
Hello, I have just started to program with directx7. I used and simple example from a book. It only puts a bitmap image on a primarry surface an shows it on screen. I got the errors down to just two, but I cannot figure out what goes wrong, I have included all the necesarry includes. I also cannot find a solution of the error on the web. I got these errors ============================================================================== --------------------Configuration: DIRX7H2 - Win32 Debug-------------------- Compiling... dirxH2.cpp E:\MyCProj\CPLUS\DX1\DXH2\dirxH2.cpp(180) : error C2065: 'bitmap_surface' : undeclared identifier E:\MyCProj\CPLUS\DX1\DXH2\dirxH2.cpp(180) : error C2440: '=' : cannot convert from 'int' to 'struct IDirectDrawSurface *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe. dirxH2.obj - 2 error(s), 0 warning(s) ============================================================================== Here is the whole code ============================================================================== #include <windows.h> #include "stdafx.h" #include "resource.h" #define INTGUID #define SaveRelease(x) if (x) {x->Release();x=NULL;} #include <ddraw.h> //----Laden van afbeeldingen ein initialisatievlaggen-----------// BOOL bInit=FALSE; LPDIRECTDRAW7 lpDD=NULL; LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL; LPDIRECTDRAWCLIPPER lpClip=NULL; LPDIRECTDRAWSURFACE lpBmp=NULL; static char szClass[]="XmplHr2Class"; static char szCaption[]="Example - Hour2"; const char *ErrStr=NULL; const char Err_Reg_Class[]="Foutje in het raampje"; const char Err_Create_Win[]="Foutje in het maken van het raampje"; const char Err_DirectDrawCreate[]="Directdraw heeft gefaald"; const char Err_Query[]="Query gefaald"; const char Err_Coop[]="Wordt niet meegewerkt"; const char Err_CreateClip[]="Kan niet klippen"; const char Err_CreateSurf[]="Geen oppervlakte"; const char Err_LoadBmp[]="Kan het plaatje niet laden"; void Cleanup(void) //64 redefinition; different type modifiers<<<<<<<<<<<<<<<<<<<<<<<<<<< { SaveRelease(lpBmp); SaveRelease(lpDDSPrimary); SaveRelease(lpClip); SaveRelease(lpDD); if (ErrStr) //70 redefinition; different type modifiers<<<<<<<<<<<<<<<<<<<<<<<<<<< MessageBox(NULL, ErrStr, szCaption,MB_OK); } void DrawImage() //76 redefinition; different type modifiers<<<<<<<<<<<<<<<<<<<<<<<<<<< { if(!lpBmp||!bInit) return; lpDDSPrimary->Blt(NULL,NULL,NULL,DDBLT_WAIT,NULL); //80 cannot convert parameter 2 from 'struct IDirectDrawSurface *' to 'struct IDirectDrawSurface7 *' } //Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_EXIT: DestroyWindow(hWnd); break; } break; case WM_PAINT: PAINTSTRUCT ps; BeginPaint(hWnd,&ps); DrawImage(); //45 undeclared identifier <<<<<<<<<<<<<<<<<<<<<<<<<<< EndPaint(hWnd,&ps); break; case WM_DESTROY: Cleanup(); //50 undeclared identifier <<<<<<<<<<<<<<<<<<<<<<<<<<< PostQuitMessage(1); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; } static BOOL Init(HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wc; HRESULT hRet; DDSURFACEDESC2 ddsd; // The size of the windowclass wc.style=CS_HREDRAW|CS_VREDRAW; // The style of the window wc.lpfnWndProc=(WNDPROC) WindowProc; // a long pointer to the function WnProc wc.cbClsExtra=0; // Extra memmory for the Class wc.cbWndExtra=sizeof(DWORD); // Extra memmory for the Window wc.hInstance=hInstance; // the handle to the instance wc.hIcon=NULL; // the big icon (32x32) associated with the window wc.hCursor=LoadCursor(NULL,IDC_ARROW); // the mouse cursor wc.hbrBackground=(HBRUSH)(COLOR_WINDOW-3); // backgroundcolor wc.lpszMenuName=MAKEINTRESOURCE(IDR_MENU); // long pointer to the menu function wc.lpszClassName=szClass; // longpointer to the zero terminated string Class Name if(!RegisterClassEx(&wc)) //105 cannot convert from 'const char [22]' to 'int' { ErrStr=Err_Reg_Class; return FALSE; } int ScreenWidth=GetSystemMetrics(SM_CXSCREEN); int ScreenHeight=GetSystemMetrics(SM_CYSCREEN); HWND hWnd; hWnd=CreateWindow( szClass, // The class or feel of the window szCaption, // the name of teh class defined wit const above WS_VISIBLE|WS_POPUP, // The class of the window, in this case it will overlapp any other window 0, // 0, // ScreenWidth, // The width of the window ScreenHeight, // The height of the window NULL, // NULL, // hInstance, // Th handle to the window NULL); // if(!hWnd) { ErrStr=Err_Create_Win; return FALSE; } ShowWindow(hWnd,nCmdShow); UpdateWindow(hWnd); hRet=DirectDrawCreateEx(NULL,(LPVOID*)&lpDD,IID_IDirectDraw7,NULL); if(hRet != DD_OK) { ErrStr=Err_DirectDrawCreate; return FALSE; } hRet=lpDD->SetCooperativeLevel(hWnd,DDSCL_NORMAL); if(hRet != DD_OK) { ErrStr=Err_Coop; return FALSE; } hRet=lpDD->CreateClipper(NULL,&lpClip,NULL); if(hRet != DD_OK) { ErrStr=Err_CreateClip; return FALSE; } lpClip->SetHWnd(0,hWnd); ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize=sizeof(ddsd); ddsd.dwFlags=DDSD_CAPS; ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; hRet=lpDD->CreateSurface(&ddsd,&lpDDSPrimary,NULL); if(hRet != DD_OK) { ErrStr=Err_CreateSurf; return FALSE; } lpDDSPrimary->SetClipper(lpClip); bInit=TRUE; lpBmp=bitmap_surface("mijn.bmp"); //175 'bitmap_surface' : undeclared identifier DrawImage(); return TRUE; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG uMsg; if(!Init(hInstance,nCmdShow)) { Cleanup(); } while(GetMessage(&uMsg,NULL,0,0)>0) { TranslateMessage(&uMsg); DispatchMessage(&uMsg); } return uMsg.wParam; } ============================================================================== Can someone help me to find and correct this error, I would b grateful. Greetings and happy gaming Roland Parijs

Share this post


Link to post
Share on other sites
Dave Hunt    4872
The compiler is looking for a function called bitmap_surface(). However, you have not provided that function, so it can't find it. Check your book and make sure you didn't miss it.

Share this post


Link to post
Share on other sites
adam23    164
I've only used DirectX 9.0, and maybe you should try doing your code the same way. If you need any help don't be afraid to ask?

Try doing this:

//Background image
LPDIRECT3DSURFACE9 bitmap_surface = NULL;

//load the background image
bitmap_surface = LoadSurface("background.bmp", NULL);

The problem is you did not declare a surface called bitmap_surface. I'm not sure how to do this using DX7, I would guess just replace the 9 with a 7, but I hope this helps. Maybe you just missed something in your book.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this