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();
}
}
directx8 textures
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....
At least that''s what looks like the problem off hand.
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
Popular Topics
Advertisement