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

Problem with D3DXCreateTextureFromFile

Started by Corrosive Sep 21, 2002 at 4:33 PM 11 replies 600+ views
Original Post
Corrosive
Corrosive
Hi everyone, im with DX7 and doing some ersearch code, just to know how it works.. well, i want to load a TGA file and Im trying to do this with that function but wht i get is a D3DERR_TEXTURE_NO_SUPPORT error!! what can i check? I tought that maybe its a problem in the declaration of the surfaces when i create a surface and a backbuffer, but i tried a lot of parameters and it didnt work! Someone can help me out with this??? To code is to make things come to life
To code is to make things come to life ;)
Corrosive
Corrosive
Just to update the post!!! Still without any result...

To code is to make things come to life
To code is to make things come to life ;)
Corrosive
Corrosive
Thank´s for your interest...

well, here we go:


  
//My GameMain looping call

G.d3dval = D3DXInitialize();
if (G.d3dval != S_OK)
erro("Erro ao inicializar D3DX!");
G.d3dval = D3DXCreateTextureFromFile(G.lpdeviced3d,
NULL, NULL, NULL, NULL, NULL, &G.lpddBack2,
NULL, "teste.bmp", D3DX_FT_DEFAULT);
if (!S_OK)
erro("Não foi possível ler o arquivo TGA!");


Render();
G.d3dval = D3DXUninitialize();
if (G.d3dval != S_OK)
erro("Erro ao finalizar D3DX!");

//my DDrawInit

G.ddrval = DirectDrawCreateEx(NULL, (void**)&G.lpdd, IID_IDirectDraw7, NULL);
if(G.ddrval != DD_OK)
{
erro("DDrawInit Falhou!");
}


G.ddrval = G.lpdd->SetCooperativeLevel(G.hwnd, DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN);
if(G.ddrval != DD_OK)
{
erro("SetCooperativeLevel Falhou!");
}

G.ddrval = G.lpdd->SetDisplayMode(800, 600, 32, NULL, NULL);
if(G.ddrval != DD_OK)
{
erro("SetDisplayMode Falhou!");
}

memset(&G.ddsd, 0, sizeof(G.ddsd));
G.ddsd.dwSize = sizeof(G.ddsd);
G.ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
G.ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP | DDSCAPS_COMPLEX ;

G.ddsd.dwBackBufferCount = 1;

G.ddrval = G.lpdd->CreateSurface(&G.ddsd, &G.lpddPrimary, NULL);
if(G.ddrval != DD_OK)
{
erro("CreateSurface Falhou!");
}

G.ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
G.ddrval = G.lpddPrimary->GetAttachedSurface(&G.ddsd.ddsCaps, &G.lpddBack);
if(G.ddrval != DD_OK)
{
erro("GetAttachedSurface Falhou!");
}

//My Direct3D Init

G.d3dval = G.lpdd->QueryInterface( IID_IDirect3D7, (void **) &G.lpd3d);
if(FAILED( G.d3dval))
{
End();
erro("QueryInterface para D3D falhou!");
}

G.lpd3d->CreateDevice(IID_IDirect3DTnLHalDevice, G.lpddBack2,
&G.lpdeviced3d);


thats it, i just put the code i tought will be relevant to the point of the question!!!

*Someone put the scroll tags for me, i dunno how its done(sorry)*

To code is to make things come to life

[edited by - Jim Adams on September 24, 2002 5:36:15 PM]
To code is to make things come to life ;)
Corrosive
Corrosive
Just to get up to date, i still didnt found a solution...

To code is to make things come to life
To code is to make things come to life ;)
Gilzu
Gilzu
its the first time that i see it,
weird coz i found your problem.

youre loading your texture, sending G.lpdeviced3d
as a parameter, where it initialized only after!
G.lpdeviced3d doesnt exist (=NULL) when
u get the texture.

solution (as it isnt obvius enough):
move texture related code after you create
all d3d devices.

Gil.
[email=gil@gilzu.com]Gil Zussman[/email]Check out Goose Chase, Coming this fall!http://www.gilzu.com
Corrosive
Corrosive
I will see the order in my home later, but i think you are wrong because in my post i just put the code together, but in my real program, its subdivided in header files and the order you saw in my post is not the real order of the program!!! In fact, i think that if i pass a NULL pointer to that function, it will return an error... but thankyou very much for your help! Keep trying guys because i still havent found a solution

To code is to make things come to life
To code is to make things come to life ;)
Corrosive
Corrosive
I still havent found a solution!!! need help...

To code is to make things come to life
To code is to make things come to life ;)
cliffski
cliffski
heh. D3DX can be a pain. I don''t know the answer but go here:

http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?S1=directxdev

and search for D3dX and maybe post a question there. Its is THE best place to get answers to things like this, sometimes even the microsoft directx team post replies.

http://www.positech.co.uk

coder_x
coder_x
1. You said you''re trying to load a TGA file but your code is loading "teste.bmp". Just curious. 2. Is G.lpddBack2 your backbuffer surface ? I haven''t used DirectDraw in a while but, don''t you get the backbuffer interface pointer by calling GetAttachedSurface from the primary surface ?
Corrosive
Corrosive
Sorry, there is some errors on the code above, but i modified it and still dont work... G.lpddBack2 is wrong, correct is G.lpddBack! and i get it with GetAttachedSurface from the primary buffer. And teste.bmp is just a test i was doing to see if the problem was only with TGA files... assume that the file name is a TGA one!!!

To code is to make things come to life
To code is to make things come to life ;)
Corrosive
Corrosive
Sorry, still without any solution!!!

To code is to make things come to life
To code is to make things come to life ;)
coder_x
coder_x
You don''t want to pass in the backbuffer interface pointer to the D3DXCreateTextureFromFile. You need to pass in another interface pointer and then blt it to the backbuffer.

Topic Locked

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

Sign in to reply to this topic.