Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualbelfegor

Posted 30 May 2013 - 09:30 AM

3000 textures OMG blink.png

 

I see you load whole file in memory, that is not good idea as you will run out of memory fast.

Read one in buffer fill texture then discard that buffer.

 

...i couldnt get the loading of the D3DXIMAGE_INFO from memory working...

 

You are doing it all wrong, "graphic_buffer" holds "file in memory" not "d3d_info_buffer" so:

 

result = D3DXGetImageInfoFromFileInMemory((LPCVOID)&graphic_buffer[0], graphic_buffer.size(), &info);

 

but you dont even need that since you read that info from file already. Code is a big mess now for quick solution.

It should be read and then discarded:

 

//temp_item.info_buffer.resize(sizeof(D3DXIMAGE_INFO)); // NO!
//is.read( (char*) &temp_item.info_buffer[0], sizeof(D3DXIMAGE_INFO) );// NO!
...
D3DXIMAGE_INFO info;
is.read( (char*) &info, sizeof(D3DXIMAGE_INFO) );
 
result = D3DXCreateTextureFromFileInMemoryEx(
        ...,...,,....,
        &info, 
        NULL, //color palette
        &texture ); 
 

 

Let me setup project and i will write whole code sample for you.


#1belfegor

Posted 30 May 2013 - 09:17 AM

3000 textures OMG blink.png

 

I see you load whole file in memory, that is not good idea as you will run out of memory fast.

Read one in buffer fill texture then discard that buffer.

 

...i couldnt get the loading of the D3DXIMAGE_INFO from memory working...

 

You are doing it all wrong, "graphic_buffer" holds "file in memory" not "d3d_info_buffer" so:

result = D3DXGetImageInfoFromFileInMemory((LPCVOID)&graphic_buffer[0], graphic_buffer.size(), &info);

 

but you dont even need that since you read that info from file already. Code is a big mess now for quick solution.

It should be read and then discarded:

//temp_item.info_buffer.resize(sizeof(D3DXIMAGE_INFO)); // NO!
//is.read( (char*) &temp_item.info_buffer[0], sizeof(D3DXIMAGE_INFO) );// NO!
...
D3DXIMAGE_INFO info;
is.read( (char*) &info, sizeof(D3DXIMAGE_INFO) );
 
result = D3DXCreateTextureFromFileInMemoryEx(
        ...,...,,....,
        &info, 
        NULL, //color palette
        &texture ); 
 

PARTNERS