directx8 textures

Started by
1 comment, last by lubby 21 years, 6 months ago

      

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]
Advertisement
you''re passing in a copy of your texture pointer to the create function, not the actual address of your texture object.
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.

This topic is closed to new replies.

Advertisement