Archived

This topic is now archived and is closed to further replies.

lubby

directx8 textures

Recommended Posts

lubby    290

      

typedef struct{
 LPDIRECT3DTEXTURE8	*texture;
}tex_t;
tex_t tex;
//=========================

void createtexture(char *filename, LPDIRECT3DTEXTURE8 tex)
{
 if (D3D_OK != D3DXCreateTextureFromFile( g_pd3dDevice, filename, &tex)){
 // handle error

}
}
//=========================

void render(void)
{
 for (int i=0;i<10;i++){
  g_pd3dDevice->SetTexture(0, tex.texture[i]);
  rendermodel(i);
 }
}
//=========================

void main(void)
{

 tex.texture = (LPDIRECT3DTEXTURE8 *) malloc(sizeof(LPDIRECT3DTEXTURE8) * 10);

 for (int i=0;i<10;i++){
  createtexture("tex.bmp", tex.texture[i]);
 }

 while(display){
  render();
 }

}

      
can anyone tell me this does not work please :D All seems ok but as soon as i bind the texture with device->SetTexture() the app exits. Even using debug directx no errors are shown. Just a nasty exit. Ive checked result of D3DXCreateTextureFromFile and it it returning D3D_OK so i guess that it is working up till that far. [edited by - lubby on October 19, 2002 1:45:51 PM] [edited by - lubby on October 19, 2002 2:15:06 PM]

Share this post


Link to post
Share on other sites
Draigan    130
Change your function to pass the address of the pointer, not the pointer itself... as in....


  
void createtexture(char *filename, LPDIRECT3DTEXTURE8* tex)
{
if(D3D_OK != D3DXCreateTextureFromFile(g_pd3dDevice, filename, tex)) { // handle error

}
}

//=========================

void main(void)
{
tex.texture = (LPDIRECT3DTEXTURE8 *) malloc(sizeof(LPDIRECT3DTEXTURE8) * 10);
for(int i=0; i<10; ++i) {
createtexture("tex.bmp", &tex.texture[i]);
}
while(display) {
render();
}
}


At least that''s what looks like the problem off hand.

Share this post


Link to post
Share on other sites