Archived

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

Loading large images on a Voodoo card

This topic is 5970 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

Splitting is the optimal answer. You could also just load it onto a surface and use CopyRects but that it slow. For the texture splitting here is what I do.

1. Read image size
2. Create surface that size
3. D3DXCheckTextureRequirements() to get max texture size
LOOP through as many tiles as needed
{
4. Create texture
5. GetSurfaceLevel() to get top surface
6. CopyRects from image surface to texture
7. Release texture surface
}

8. Release image surface

Jack

Share this post


Link to post
Share on other sites
I used a fixed value to load the surface and it loads the image properly now. This is what i did :


lpD3DDevice->CreateImageSurface(800,600,D3DFMT_R8G8B8,&tempSurf);

res = D3DXLoadSurfaceFromFile(tempSurf,NULL,NULL,filename,
NULL,D3DX_FILTER_NONE,0xFFFFFFFF,&info);
if (FAILED(res)) return res;

pSprite->height = info.Height;
pSprite->width = info.Width;
pSprite->tex_row = INT(info.Width / 256)+1;
pSprite->tex_num = (INT(info.Height / 256)+1) * pSprite->tex_row;
pSprite->pTex = (LPDIRECT3DTEXTURE8 *)malloc(sizeof(LPDIRECT3DSURFACE8)*pSprite->tex_num);

for (int i=0;itex_num;i++)
{
res = D3DXCreateTexture(lpD3DDevice,256,256,1,0,info.Format,D3DPOOL_MANAGED,&tempTex);
if (FAILED(res)) return res;

tempTex->GetSurfaceLevel(0,&texSurf);
if (FAILED(res)) return res;

rc.left = (i % pSprite->tex_row) * 256;
rc.top = (i / pSprite->tex_row) * 256;
rc.right = rc.left + 255;
rc.bottom = rc.top + 255;

res = lpD3DDevice->CopyRects(tempSurf,&rc,0,texSurf,&point);
if (FAILED(res)) return res;

texSurf->Release();
}

Share this post


Link to post
Share on other sites
If the video card only supports 256x256 textures, then you should resize any textures to those dimensions. If your doing 2D blitting with a large texture, then do just that, a DirectDraw blit, and video cards can hold anysize 2D image (including voodoos). If you trying to load a large texture to put on a polygon, then limit the textures to the cards maximum size, otherwise for example, say you want to load a 512x512 texture, that would require it be split into 4 256x256 textures, and thus you would need to break up your polgon into 4 seperate polygons and call 4 DrawPrimitives, instead of just 1 as you intended with the 512x512 texture.

Possibility

Share this post


Link to post
Share on other sites
Yeah thats exactly what I''m planning to do. I posted my splitting routine, but it doesnt work atm. I cant use a DD Blit anymore b/c I''m using DX8 now and DX8 doesn''t support DDraw routines any longer. So I need to load the files as textures.

Share this post


Link to post
Share on other sites
I couldn''t find anyway to read the dimensions either so I create a small temp surface, then load the image onto it, read the param that shows the original image file size, release the temp surface and go from there.

As for CopyRects, one problem is your third param is 0 when it should be one for the number of rectangles -- I also don''t see you setting the points structure to x = 0; y = 0;


Possibility: the only way to do 2d bltting with DX8 is CopyRects and it is very slow. How I know: I tried it this week. My fps went from 36 to 30 with one 800x128 surface. When done as textures it has no noticable cost. In addition it is totally lacking in rotation, scaling, color format conversion, alpha, and just about everything else.

Jack

Share this post


Link to post
Share on other sites
Yeah, I know that
I''m using CopyRects only to split up the large images into smaller ones. Then I draw them with ID3DXSprite.Draw. This function is really good.
I tried to set the 3.parameter to 1 and I defined point but still it doesn''t work. Someone who posted in this forum had the same problem and he said that ( in his opinion ) Voodoo cards do not allow CopyRects() and so they always return D3DERR_INVALIDCALL. I can''t think of anything else. Maybe you do.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Biberpelztrompete: I got your email but I''ll respond here so if we come up with a solution all can benefit.


Ok, first I''m not sure what to tell you about the CopyRects not working... if it works on my banshee it should work on your Voodoo3. I haven''t actually tried transparency on a banshee, but it should work... make sure your texture format supports an alpha channel. I request D3DFMT_A8R8G8B8 format and validate with D3DXCheckTextureRequirements and use the format it spits out for my textures...

Oh and I''m guessing the texture format might have something to do with CopyRects failing if D3DXLoadSurfaceFromSurface works, as D3DXLoadSurfaceFromSurface does format conversion automatically.


Jack

Share this post


Link to post
Share on other sites
ITS WORKING NOW !!!!!!!!!!!!
YYYYYEEEEEEHHHHHHHHHAAAAAAAAAAAAAAAAAAAAAAAAA

it was simple : instead of creating a 256x256 I loaded the image with a 256x256 rectangle and then I replaced the surface with the correct one. KKKKEEEEEEEEEEWWWWWLLLLLL.
Thanx @ everybody who helped me

Share this post


Link to post
Share on other sites
@Biberpelztrompete:
Well sorry, I wasn''t on this site the last two days. That''s the reason why I couldn''t respond to your question. But it seems that you don''t need the answer anymore.
But anyway, I used this method only to render a background image that is 1024x768 pixels in size. So I didn''t tried it with transparency yet.

Sorry for answering so late.


- LongingForDeath

Share this post


Link to post
Share on other sites