Jump to content
  • Advertisement

Archived

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

errand

DirectX8 and "animated" texture

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

Hello! I have just started coding Direct3D and I got into some trouble when I wanted a texture maped cube to have a texture that changes 5 times/sec. It loads all the textures (32 ones) and draws the cube (with a background picture among other things) but no matter what it won''t change the texture. I know it updates what texture to set and ->SetTexture returns ok but I can''t seem to find out what to do to make it work. Here is the code snippet that selects the texture and render the cube
  
// Just my timing class and when I debug it really updates the frame variable

		anim += timer.TimePassed();
		if (anim >= 0.2f) {
			anim -= 0.2f;
			frame++;
			if (frame > 31) {
				frame = 0;
			}
		}

		HRESULT hr = d3dDevice->SetTexture(0, g_pTexture[frame]);

		d3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
		d3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
		d3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
		d3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

// Rendering of scene objects happens here.

		d3dDevice->SetVertexShader( D3DFVF_MYVERTEX );
		d3dDevice->SetStreamSource( 0, g_pCubeVB, sizeof(CUSTOMVERTEX) );

		d3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 12);

  
Any help would be appriated and if someone want more info just ask and I will provied it.

Share this post


Link to post
Share on other sites
Advertisement
Maybe I will start with the obvious here, sorry if questions seem very "simple."

1) Are you sure that "frame" is not always one value? Have you tried debugging it to see the values of it alternate?

2) Are you sure that each texture in the array is different, i.e. manually set texture to be [1], [2], etc. to insure they are really different.

LostLogic

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes frame changes overtime. Have written it to a logfile as well as using debuging.

Damn.... Something went wrong with the loading of the textures. Didn''t update the filename inside the loop. =(

Thanks

Share this post


Link to post
Share on other sites
Yes frame changes overtime. Have written it to a logfile as well as using debuging.

Damn.... Something went wrong with the loading of the textures. Didn''t update the filename inside the loop. =(

Thanks

Share this post


Link to post
Share on other sites

  • 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!