Sign in to follow this  
phil67rpg

drawing a sprite

Recommended Posts

phil67rpg    443
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"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] render_frame([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"])

{

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

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

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

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]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);



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

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

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

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

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]}

any help would be appreciated.?


[/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
RoyCHill    92
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this