Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3D 9 problem

Started by XenoG Jan 4, 2009 at 3:07 AM 1 replies 1k views
Original Post
XenoG
XenoG
I'm trying to load and draw a bitmap using DirectX 9 but am having problems. I can get the image to load and draw the image to the screen but the image is stretched and bigger than the area that I am trying to draw to. Below is the code I am using to load and draw the image. void LoadImage(IMAGE *pImage,LPCTSTR file) { D3DXCreateTextureFromFileEx(gd3ddev,file,D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT, NULL,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT, D3DCOLOR_XRGB(255,0,255),NULL,NULL,&pImage->tex); return; } void DrawImage(IMAGE *pImage,float x,float y, float z) { D3DXVECTOR3 position(x,y,z); gd3dspt->Draw(pImage->tex,NULL,NULL,&position,D3DCOLOR_XRGB(255,255,255)); return; } I want to load the whole image which is a 1280x800 bitmap and print that image to the screen. D3D is set up to full screen at a 1280x800 resolution but the bitmap is drawn huge so only part of the left hand corner of the image is seen. Anyone have any advise?
undead
undead
I never used d3dx sprites but I wonder if this could have something to do with your z coordinate. Have you tried adjusting it to see it the image is drawn bigger/smaller?

Another idea is d3dx is rounding your texture to the closer power of two (2048x1024?).
Have you tried using Width and Height with D3DX_DEFAULT_NONPOW2 instead of D3DX_DEFAULT?
MJP
MJP
Quote:
Original post by undead
Another idea is d3dx is rounding your texture to the closer power of two (2048x1024?).
Have you tried using Width and Height with D3DX_DEFAULT_NONPOW2 instead of D3DX_DEFAULT?


Yes, do this. D3DXCreateTextureFromFileEx will round up the width and height unless you specify D3DX_DEFAULT_NONPOW2.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.