Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Blit only parts of an image?

Author
Message
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 11th Jan 2008 11:02
Hi, I'm writing a wee robotron clone.

In the arcade game, when the robot is hit, it "explodes", basically a blitter effect where the lines of pixels that comprise the "robot" are staggered N lines, where N increases each frame.


How can I, in DarkGDK.NET, blit individual lines of an image to the screen, quickly?

Blitzatron (a game by Mark Incitti) does it, so I know it is possible in DirectX - but how?

Thanks for any advice.

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 11th Jan 2008 11:55
I don't think it's possible in GDK. And if that's so, you are very unlucky, since it's a lot of work if you want to do it in DirectX (I can explain it to you, but you would have to be really desperate to take this way for a single effect).
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 11th Jan 2008 17:25
OK, I still want to do it - what do I need to do?

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 11th Jan 2008 17:29
It doesn't involve locking the main surface and individual pixel writes does it?

Hmm there must be a faster way.

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 11th Jan 2008 23:09
Quote: "It doesn't involve locking the main surface and individual pixel writes does it?"


No, that would be really slow.

So, just technically using DirectX:

1) You need to create a texture with your image (D3DXLoadTextureFromFile or something like that, don't have time to search that right now)

2) Create a quad (rectangle if you want) out of two triangles which you will use to render the image (using Direct3DDevice9::CreateVertexBuffer call - or some similar)

3) Create a shader in which you place the quad vertices to exact screen coordinates (you can set those coordinates as a shader constants) - unfortunately, in DX9 you must obey specific rules for pixel perfect matching (but you can start out without that and add that later) .. here you can use GDK stuff for loading the shader, but you have to write it on your own

4) Set up your shader (in GDK or Direct3D), the texture (in Direct3D) and render the quad (using Direct3DDevice9:rawPrimitive)

You are almost done, but it is possible that you will have to experiment a bit so that your image is not hidden by sprites rendered by GDK.

Hope this helps, I can't elaborate more right now, ask if you need, but you can find most info in DirectX documentation which you installed with the SDK.
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 12th Jan 2008 11:39
Thanks for the reply but that sounds more complex than it needs to be... hmm I think there must be a more elegant way.

I got it!

How's about this? I create a temporary image in memory.

When I want to "explode" the image, robotron style, I memcpy() the individual lines of the image I want to "explode" across to the 1 pixel high temp image, and then paste the temp image repeatedly at staggered points.

I reckon that would work, and work well.

What do you think? I don't have to create and delete the image all the time, I can keep the image in memory forever.

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 12th Jan 2008 13:07
Sure, you can do this, but you were asking for fast method

But for a simple 2d arcade this should be fast enough, that's for sure

Login to post a reply

Server time is: 2024-10-08 15:53:37
Your offset time is: 2024-10-08 15:53:37