Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

drawing a sprite

This topic is 2495 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 am using c++ and directx9 to draw a single space ship sprite to the screen.I am kind of stuck.here is some of my code.
[font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]void[/font][/font][/font][font="Consolas"][font="Consolas"] render_frame([/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]void[/font][/font][/font][font="Consolas"][font="Consolas"])

{

[/font][/font][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"]// clear the window to a deep blue

[/font][/font][/font][font="Consolas"][font="Consolas"]d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

d3ddev->BeginScene(); [/font][/font][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"]// begins the 3D scene

[/font][/font][/font][font="Consolas"][font="Consolas"]D3DXCreateSprite(d3ddev,&spriteobj);

spriteobj -> Begin(D3DXSPRITE_ALPHABLEND);

RECT rct;

rct.left = 0;

rct.right = 48;

rct.top = 0;

rct.bottom = 50;

spriteobj -> Draw(texture,&rct,NULL,NULL,0xFFFFFFFF);



[/font][/font][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"]// do 3D rendering on the back buffer here

[/font][/font][/font][font="Consolas"][font="Consolas"]spriteobj -> End();

d3ddev->EndScene(); [/font][/font][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"]// ends the 3D scene

[/font][/font][/font][font="Consolas"][font="Consolas"]d3ddev->Present(NULL, NULL, NULL, NULL); [/font][/font][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"][font="Consolas"][color="#008000"]// displays the created frame on the screen

[/font][/font][/font][font="Consolas"][font="Consolas"]}

any help would be appreciated.?


[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
If I remember correctly, there is a renderer block code that has to keep flipping or refreshing the graphics buffer because Direct Graphics and OpenGL have the same style of rendering. If it is done one time then I think it renders one time only. Try to make your little sprite move in a position and render it in each frame.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!