• Advertisement
Sign in to follow this  

release surface

This topic is 4177 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having troubloes when tying to free a LPDIRECT3DSURFACE9 surface. I'm using visual c++ express. I'm hoping some one nows what is the problem. The code and errors are: //the line marked with the "//error" is the one #include "mapADT.h" #include <string.h> #include "d3dx9tex.h" #include "d3dx9.h" #include "d3d9.h" typedef struct{ LPDIRECT3DSURFACE9 surface; int x_position; int y_position; long graphic; int blocked; int navigable; int mov_dif; int extra; }tileStruct; struct mapCDT{ char* tiles_path; long map_width; long map_hieght; int num_tiles_x; int num_tiles_y; long tile_width; long tile_hieght; LPDIRECT3DDEVICE9 d3ddev; LPDIRECT3DSURFACE9 tilesSurf; tileStruct** tileMatrix; }; tileStruct** setTileMatrix(mapADT map); LPDIRECT3DSURFACE9 getTiles(char* tile_images, LPDIRECT3DDEVICE9 d3ddev); char* getPath(const char* p); mapADT NewMap(const char* tile_images, int num_tiles_x, int num_tiles_y, long tile_width, long tile_hieght, LPDIRECT3DDEVICE9 d3ddev) { mapADT map; if ((map = malloc(sizeof(mapADT))) == NULL) return NULL; if (((char*)map->tiles_path = (char*)getPath(tile_images)) == NULL) { free(map); return NULL; } map->tile_hieght = tile_hieght; map->tile_width = tile_width; map->num_tiles_x = num_tiles_x; map->num_tiles_y = num_tiles_y; map->map_hieght = (long)num_tiles_y * tile_hieght; map->map_width = num_tiles_x * tile_width; map->d3ddev = d3ddev; map->tilesSurf = (LPDIRECT3DSURFACE9)getTiles(tile_images, d3ddev); if((map->tileMatrix = (tileStruct**)setTileMatrix(map)) == NULL) { map->tilesSurf->Release(); //error free(map->tiles_path); free(map); return NULL; } return map; } //Errors: /* 1>.\mapADT.c(64) : error C2039: 'Release' : is not a member of 'IDirect3DSurface9' 1> C:\Program Files\Microsoft DirectX SDK (June 2006)\Include\d3d9.h(1537) : see declaration of 'IDirect3DSurface9' 1>Build log was saved at "file://c:\Documents and Settings\German\My Documents\Visual Studio 2005\Projects\a_game\a_game\Debug\BuildLog.htm" 1>a_game - 1 error(s), 0 warning(s) */

Share this post


Link to post
Share on other sites
Advertisement
The error is pretty self explanatory, IDirect3DSurface9 doesn't have any methods by the name of "Release" [smile]

If you have a look at the documentation on msdn, you can see it has a method called "ReleaseDC", is this what you are after?

All the best,
ViLiO

Share this post


Link to post
Share on other sites
Hmmm... Currently I'm reading a book (begining game programming by jonathan s. harbour). In one of the chapters he makes the same. Well I just realise that example programs don't include that method, must be some mistake. Anyway, how can I free the resources the surfaces take? Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement