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.

DarkBASIC Professional Discussion / 2D clipping rectangle

Author
Message
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 16:54
I've got a large overlay image which I need to paste to a certain part of the screen through a clipping rectangle. Is there a way of doing this without grabbing another image then pasting?

Warning! May contain Nuts!
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 20th Aug 2011 18:02 Edited at: 20th Aug 2011 18:21
I don't think it is possible without involving other images.
But you can use the image kit commands, they are pretty fast.
Try using something like this:

edit If this doesn't work, try using a white triangle and blend mode 4. Not sure about the blend mode to use
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 18:27
That's what I was afraid of... Darn it... I might try a 3D plain and switch of the UV wrapping and stretch the UV coords just to show a portion of the overlay...

Warning! May contain Nuts!
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 20th Aug 2011 18:53 Edited at: 20th Aug 2011 18:55
Just did a little test for you and it can clip a 512x512 image at a little above 3000 fps.
edit 4096x4096 runs at the same speed
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 19:23
Thanks Max P, I've just downloaded IK and installed it. It's the last thing I need to do before I can get back onto another project.

Warning! May contain Nuts!
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 20th Aug 2011 19:40
Here are some functions you can use for the clipping:

Use them like this:
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 20th Aug 2011 22:46
http://forum.thegamecreators.com/?m=forum_view&t=69221&b=5&msg=2206101#m2206101

I added a few commands to the d3d_func dll. I think this is what you want

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 23:28
Image Kit has some amazing features that I will be using in the very near future. Especially when adding bullet holes, paste image to image, etc... Thanks Max...

@GIDustin - Just what I needed and the one basic thing missing from DBPro. I only have one question though... What's the difference between the link you sent me (47K) and the main download (216k zip)...

Gonna try this out right now before my brain starts to fry...

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 00:28
Trying to locate a help file for Cloggy's dll commands...

Warning! May contain Nuts!
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 21st Aug 2011 00:49
http://www.dbdepot.co.uk/d3dfunc.html

That is his help file. The Viewport commands are my own addition and are not included in the help files, but the two in the above example are pretty much all that I added.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 01:15
I put the 47k dll, and the other dll into the plugins-user folder, restarted, and when I compile I get "Could not understand command at line xxx". Most dll's usually come with a keywords ini file.

Just to get this d3d plugin working. I must be doing something daft.

Warning! May contain Nuts!
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 21st Aug 2011 02:27
I reuploaded the file with my keywords file.

If you still cant get it to work, post some code and I can run through it.

https://forumfiles.thegamecreators.com/download/2206101
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 04:05 Edited at: 21st Aug 2011 04:12
Give me a mo... I'll upload the project... (I'm using Matrix1 and Sparkys)

http://csnorwood.site40.net/_Misc_Media/LevGenV3.1.zip

Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Aug 2011 16:01
You could of course make a 3D object with a hole in the middle, then texture it. That would be faster.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 17:05 Edited at: 21st Aug 2011 17:10
I've almost got it working, but the d3d viewport doesn't seem to be doing anything. It compiles and runs, the overlay map is created. It draws it to the screen using transparency, but not clipped although the clipping viewport is set up...

Here's the two functions that create the overlay map, and one to draw it to the screen...



EDIT: I probably need to initialise the D3DFunc dll but I don't know how to...

EDIT2: Got it sussed... I put D3D_init at the beginning of my code...

Warning! May contain Nuts!
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 21st Aug 2011 19:45
Quote: "EDIT2: Got it sussed... I put D3D_init at the beginning of my code..."


Ah yeah, sorry about that. d3d_init is automatically called by the DLL but if you change resolution, which you do, it needs to be called again afterwards.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 19:51
I'm now hoping that Mistrel will be able to wrap the D3DFunc for PureGDK. The viewport clipping is a handy addition to the D3DFunc. I'm also going to have a look at some of the code to see what I can learn from it about D3D itself.

Thanks so much GIDustin...

Warning! May contain Nuts!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Aug 2011 20:49
Advanced 2D has direct support for 2D clipping. a2SetClip will let you choose a clipping region which will apply to all of a2's drawing commands including a2DrawImage.

[b]
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Aug 2011 21:14
I believe that's already a part of the PureGDK too. I also can't believe I missed that from the start.

Looking over both D3DFunc and Advanced 2D there's a hell of a lot of useful fast functions.

Thanks Diggsey...

Warning! May contain Nuts!

Login to post a reply

Server time is: 2026-07-11 03:38:15
Your offset time is: 2026-07-11 03:38:15