Jump to content
  • Advertisement
Sign in to follow this  
pleaselouis

How to paste texture

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

I just use D3DXCreateTextureFromFile() to create a sphere. But i can`t paste a picture on my sphere. I don`t know , what`s wrong with my code. Please help me , Thanks... And , That is my code : //inital area LPDIRECT3DDEVICE9 m_pDevice; LPD3DXMESH m_meshSphere; LPDIRECT3DTEXTURE9 m_pMyTexture; D3DMATERIAL9* m_sphereMaterials; ............ D3DXCreateSphere(m_pDevice, 200.0f, 20, 10, &m_meshSphere, NULL); D3DXCreateTextureFromFile(m_pDevice , L"XXX.jpg" , &m_pMyTexture); m_sphereMaterials = new D3DMATERIAL9; m_sphereMaterials->Diffuse.r=1.0; m_sphereMaterials->Diffuse.g=1.0; m_sphereMaterials->Diffuse.b=1.0; m_sphereMaterials->Diffuse.a=1; m_sphereMaterials->Ambient = m_sphereMaterials->Diffuse; m_sphereMaterials->Power=1; m_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE); m_pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255, 255, 255)); m_pDevice->SetRenderState(D3DRS_ZENABLE ,TRUE); //render area m_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); m_pDevice->SetTexture( 0 , (IDirect3DBaseTexture9*)m_pMyTexture ); m_pDevice->SetMaterial(m_sphereMaterials); m_meshSphere->DrawSubset(0);

Share this post


Link to post
Share on other sites
Advertisement
I am not familiar with the fixed pipeline functions, but isn't lighting supposed to be off when you have no lights in your scene? I've seen a couple of questions passing by lately about people not seeing anything rendered and it turned out to be the lighting parameter.

Share this post


Link to post
Share on other sites
I thought the same thing at first, but the ambient color is set to maximum (which should kind of nulify the lighting effect).

Share this post


Link to post
Share on other sites
just out of curiousity, did you try rendering it with just an ambient color, no texture? Is there no output at all? Are you sure the texture get's loaded properly (and is not a null parameter)?

Share this post


Link to post
Share on other sites
Quote:
Original post by FeverGames
just out of curiousity, did you try rendering it with just an ambient color, no texture? Is there no output at all? Are you sure the texture get's loaded properly (and is not a null parameter)?


D3DXCreateTextureFromFile() and SetTexture() return S_OK ...

And,the parameter(LPDIRECT3DTEXTURE9 m_pMyTexture;) in break point mode ,it`s seem has a correct address ( 0x4b6932b8 ).

Finaly, I don`t understand how the texture link to mesh.

My example code in book just show me put SetTexture() before DrawSubset().

Somebody help me , please ......QQ

[Edited by - pleaselouis on April 21, 2009 10:51:52 PM]

Share this post


Link to post
Share on other sites
Here are some steps to follow when debugging these types of problems.
1. Check if you can render the sphere without any materials/lighting/textures applied to it.
2. Apply some directional (best debugging light) lighting to the sphere and see if that works.
3. Apply a texture without any lighting (turn lighting off, because this mostly just confuses things when working with too many variables).

Other than that, what you need to be aware of is the following.
When rendering an object with lights the following variables need to be correct.
1. Material
2. Lighting setup correctly.

I hope this helps!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!