Jump to content
  • Advertisement
Sign in to follow this  
Pianka

[.net] Super Laggy

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

I'm learning about game development and a project that I'm starting is going to have a title screen that has a jpg sprite. So I'm using the Sprite class to draw the image and I'm encountering some odd problems. I've already setup some classes to draw Sprites for text boxes and buttons...and it all works fine. The smaller images for the textbox and buttons draw without lag and it has no problems, but when I try to draw a 1024x768 image for my background it lags like crazy but still runs. The amount of lag is also proportional to the size of the image, I tried drawing only 300x300 of my background image and it was still pretty laggy, but quite noticably less than when drawing the 1024x768. Has anyone encountered this before or might have ideas on what I can do to fix this? Thanks in advance. edit: I figured I'd show you some code so here goes: Loading the sprite and texture:
Quote:
titleScreen = TextureLoader.FromFile(device, "menu.jpg", 1024, 768, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default, Filter.None, Filter.None, 0); titleSprite = new Sprite(device);
What is called on each render loop:
Quote:
titleSprite.Begin(SpriteFlags.DoNotSaveState); titleSprite.Draw2D(titleScreen, new Point(0, 0), 0f, new Point(0, 0), Color.White); titleSprite.End();

Share this post


Link to post
Share on other sites
Advertisement
Most likely choppy, low FPS count..

What card are you using, are you running fullscreen, how do you setup your device, what resolution is your game, what's your desktop resolution and what's your desktop color setting? Also, what OS is it?

Perhaps you are using the REF rasterizer(sp?)? Perhaps your backbuffer has another bit-depth than your texture/sprite? Are you using anti-aliasing?

Share this post


Link to post
Share on other sites
For a titlescreen your better off just loading the picture as a suface and copying it to the backbuffer.

Loading the background..
m_background = device.CreateOffscreenPlainSurface( 640, 480, m_adapterformat, Pool.Default );
SurfaceLoader.FromFile( m_background, Utility.GetMediaFile( "background.jpg" ), Filter.None, 0 );


In your render loop...
using(Surface backbuffer = device.GetBackBuffer( 0, 0, BackBufferType.Mono ))
{
device.StretchRectangle( m_background, new Rectangle( 0, 0, 640, 480 ), backbuffer,
new Rectangle( 0, 0, backbuffer.Description.Width, backbuffer.Description.Height ),
TextureFilter.None );
}

Share this post


Link to post
Share on other sites
Here's two questions:

1) What video card?
2) Is the texture itself 1024x768 as well, or just the sprite? If the texture has those dimensions, that can cause that problem with some video cards. As a general rule, non power of two textures = bad.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!