|
-
November 2nd, 2009, 05:09 AM
#1
Direct3D9 2d draw image
when i want to draw 2d image, no locking, no update of image, which method is fastest, is there faster way that i don't yet know ?
when i use an image with format D3DFMT_A8R8G8B8, is it slower than D3DFMT_X8R8G8B8 ?
is D3DDevice->StretchRect() faster to use it instead of D3DDevice->DrawPrimitiveUP() ?
is LPD3DXSPRITE faster than all ?
which is fastest, i just want to know.
and i want to load huge images faster, D3DXLoadSurfaceFromFile seems fast but when i load 1920x1080 images, it can't reach even 25 fps,
which is similar to a video playing and i don't want to use a video file format.
i used dds image file format recently, it seems fastest format, but its uncompressed file size is very large.
is there an image file format that have compression, good quality and small file size ?
Creating texture:
Code:
char FileName="sample.jpg";
LPDIRECT3DTEXTURE9 tex;
LPDIRECT3DSURFACE9 surf;
D3DXIMAGE_INFO imginfo;
void InitIt(){
D3DDevice->CreateTexture(550,400,1,0,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&tex,0);
D3DXGetImageInfoFromFile(FileName,&imginfo);
tex->GetSurfaceLevel(0,&surf);
D3DXLoadSurfaceFromFile(surf,0,0,FileName,0,D3DX_FILTER_NONE,0,0);
surf->Release();
D3DDevice->SetTexture(0,tex);
D3DDevice->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
}
Drawing method 1:
Code:
struct TVERTEX{float x,y,z,rhw,u,v;};
TVERTEX vert[4];
void DrawIt(const float x,const float y){
vert[0].x=x;
vert[0].y=y;
vert[0].z=0;
vert[0].rhw=1;
vert[0].u=0;
vert[0].v=0;
vert[1].x=x+(float)imginfo.Width;
vert[1].y=y;
vert[1].z=0;
vert[1].rhw=1;
vert[1].u=1;
vert[1].v=0;
vert[2].x=x;
vert[2].y=y+(float)imginfo.Height;
vert[2].z=0;
vert[2].rhw=1;
vert[2].u=0;
vert[2].v=1;
vert[3].x=x+(float)imginfo.Width;
vert[3].y=y+(float)imginfo.Height;
vert[3].z=0;
vert[3].rhw=1;
vert[3].u=1;
vert[3].v=1;
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,vert,24);
}
-
November 4th, 2009, 11:48 AM
#2
Re: Direct3D9 2d draw image
I would suggest using the ID3DXSprite interface for rendering the images.
I don't know about the spped of loading images but what you are doing seems to be fine. Have you tried the D3DXLoadTextureFromFileEx function, don't know how it will compare.
About your .dds format, if you open up the directX texture tool go to:
Format->Change Surface Format... and select one of the "Four CC" formats, they are compressed.
Let me know how that helped.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|