Jump to content
  • Advertisement
Sign in to follow this  
nickme

xna 4.0:learning xna 4.0 chapter 15 problem.

This topic is 2338 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

hi,

i am currently reading the book:Learning xna 4.0. i downloaded the files from the author's site and everything run fine until i reached chapter 15. the 3D game in ch 15 compiled and run but it just show a black screen and did nothing more. does anyone know what the problem is?

any help will be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
hi,

i finally located the problem. when i get rid of the following statements from Game1.cs, the program works as expected:

#if !DEBUG
graphics.IsFullScreen = true;
#endif

but i still do not know why it is. maybe someone can enlighten me. apparently, this happened to all the projects that i build, not just chapter 15.

Share this post


Link to post
Share on other sites
hi Bayinx

yes, i downloaded from that site.
apparently, when i do the same thing to all my xna program, it did not run also.
i am just do not know what happened

thanks

Share this post


Link to post
Share on other sites
Hi nick me.

Try adding this to your program:


//After initializing the graphics.
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(OnPrepareDevice);

//Add this method also
private void OnPrepareDevice(object sender, PreparingDeviceSettingsEventArgs args)
{
args.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = 60;
/ if you are running the game at 30 fps use 30 instead of 60.
}



Try adding and tell if it works ;)

Share this post


Link to post
Share on other sites
hi Bayinax:

i did what you suggested. but there is one error, the 'FullScreenRefreshRateInHz' is not recognized by the program.

why add the method if you are not going to call it?

thanks

the error output is follow:

Error 1 'Microsoft.Xna.Framework.Graphics.PresentationParameters' does not contain a definition for 'FullScreenRefreshRateInHz' and no extension method 'FullScreenRefreshRateInHz' accepting a first argument of type 'Microsoft.Xna.Framework.Graphics.PresentationParameters' could be found (are you missing a using directive or an assembly reference?) C:\Users\rob\DevC++ source\C#\LearningXNA4.0 - Copy\Chapter 15\3D Game\3D Game\3D Game\Game1.cs 87 64 3D Game

Share this post


Link to post
Share on other sites
hi

when i include the method but comment out the

args.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = 60;

statement, it worked. basically, it is just an empty method but it works.

thank you very much.

can you explain to me what you just did?

Share this post


Link to post
Share on other sites
The reason you had this problem was because when you make the game full screen in XNA, the graphics device will look at the list of refresh rate available in your graphics card, (you can check in in GraphicsAdapter.SuportedDisplayModes). Sometimes in older graphics cards the result will be ambiguous and it will present the screen black.

Using the method above you are forcing XNA to use your predefined refresh rate and not the one in the graphics card ;).
Also the "args.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz" was discontinued in XNA 4.0. sorry about that :X .
My guess is that the graphics device now sets automatically when it triggers that event based on the value you have set in the initialization. =X

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!