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 .NET / Draw sprite over 3d object ?

Author
Message
jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 16th Oct 2011 00:42
I've been trying to draw a simple cross on screen in my game. However either the 2d completely blocks out the 3d or the 3d blocks out the 2d. I've used drawspritelast , drawspritefirst , drawtoback , drawtofront and several other combinations of these commands with no luck. Anyone know how to do this ? Thanks for any help

" The best slaves are the ones who think they are free. "
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 17th Oct 2011 01:36
Can you post up a small sample of what your code looks like because the DrawSpritesLast function should prevent what you're seeing, but I cannot determine whether this is the cause, or something else.

Paul.

jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 17th Oct 2011 16:26
Here is the code. As you see I draw one sprite with a simple square image and one cube. I set drawspritelast and it completely draws over the cube. Also how do I get the screen size with 2d images. I notice using display.screenwidth / 2 and display.screenheight / 2 will draw the sprite way off the screen. y



" The best slaves are the ones who think they are free. "
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 22nd Oct 2011 00:33
jojoofu,

Ok, figured what was happening. First, in order to draw 3D objects over Sprites, you must call the DrawSpritesFirst.

You also must call the BackdropOff function for your camera which prevents the sprite layer from being wiped by the backdrop flood.

This example here I've posted can be run by creating a default DarkGDK.NET project, (reset your three references) and run the program. It will render a cube with the standard GDK texture with the same image being rendered as a sprite in the top left corner. The sprite should appear behind the cube.



jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 22nd Oct 2011 01:32
Oh that example works great but I think you misunderstood my original question.

I want the sprite to appear in front of the 3d objects. The problem I have is when I call drawspritelast none of the 3d objects render. Basically I want the 3d objects to render then the sprites to be drawn over. I am trying to draw a simple cross hair on the screen for a first person shooter.

" The best slaves are the ones who think they are free. "
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 22nd Oct 2011 01:35 Edited at: 22nd Oct 2011 01:35
With the above sample, change the DrawSpritesFirst to DrawSpritesLast. The sprite image should appear above the cube.

Paul.

jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 22nd Oct 2011 05:16
So that does work. There appears to be a problem with the 2010 template setup. I've been looking through and haven't found what would cause this behavior.

" The best slaves are the ones who think they are free. "
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 22nd Oct 2011 16:03
I'll have to look at the template to see what could cause this. One thing you must do, is change the platform from 'Any CPU' to 'x86'. This is because the main core of the engine is compiled for 32bit processors. If you're having trouble running your projects from the basic template, change the platform type and this should sort out the problem.

Paul.

jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 22nd Oct 2011 16:51 Edited at: 22nd Oct 2011 16:52
The template runs fine with the exception that the 2d won't draw over the 3d correctly. The template I am using was made by another user here is a link to it http://www.megaupload.com/?d=0DBKSGPO

I haven't been able to find what would cause this odd behavior. Basically the 2d when drawn last completely blocks out the 3d. I would like to continue to use this template. If you find out what is wrong send it my way and I will modify the template.

Thanks my friend

" The best slaves are the ones who think they are free. "
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 22nd Oct 2011 17:02
No problem bud, I'll take a peek and see what gives.

Paul.

aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 16th Nov 2011 16:05
Why not simply use the crosshair for your mouse cursor?

I do that, and here is my code for it.



The .SetPriority command makes sure it appears in front of everything.

Russell B. Davis/aerostudios
jojoofu
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 16th Nov 2011 17:07
I also want to use the 2d sprite class to make some basic menus. I'm going to take a look at the template when I get some free time and see if I can't figure out what is causing the bug.

" The best slaves are the ones who think they are free. "

Login to post a reply

Server time is: 2024-04-23 15:21:14
Your offset time is: 2024-04-23 15:21:14