Jump to content
  • Advertisement
Sign in to follow this  
Fragsta

OpenGL SDL (.NET) & Hardware Acceleration

This topic is 3471 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 making a simple 2D representation of a game (at some point I'd like to make it 3D), and as it gets more complex I'm going to be needing a bit more smoothness when it comes to that representation. I had a look at SDL and found SDL.NET since I'm using C# .NET. Now, am I right in assuming that SDL will allow smoother animations than GDI+ (what I'm currently using)? I understand that it uses OpenGL for hardware-accelerated 3D graphics, but what about with 2D? I'm a bit of a newbie when it comes to graphics, so that probably is a stupid question, but there you go. It's certainly a better way to animate a 2D game than using GDI+, anyway, right?

Share this post


Link to post
Share on other sites
Advertisement
Yeah I wouldn't recommend GDI+, it's generally too slow for animations. Honestly I'm not sure whether the current version of SDL still supports hardware acceleration for 2D...I know it used to but it's been a long time since I kept tabs on the project.

You might want to consider checking out XNA though...the framework is very robust with a lot of neat and useful features (not to mention a ton of [tutorials and samples as well as starter kits) that I don't think SDL can really compare with.

Share this post


Link to post
Share on other sites
Hi MJP, thanks for the suggestion :)

Well, I'd quite like to do something with 2D Graphics which doesn't take a huge amount of time to learn*, because I find Direct3D stuff to be quite a lot more time-consuming to get one's head around, what with that irritating extra dimension.

XNA is very intriguing though. Developing for the 360 as well as the PC would certainly add a bit of flair to the process.

Having said that, XNA doesn't make it too easy does it? I don't want to end up with a graphics system which is identical to every other game developed with XNA out there.

Furthermore I'm making an RTS, the mechanics of which I'm building from the ground-up. It's not as simple as saying Game rts = new RTSGame(); is it?

* At university, and unfortunately this stuff doesn't really line up with what they want to teach me - therefore time is limited, but I still want to make something fun =(

Share this post


Link to post
Share on other sites
Well the nice thing about XNA is that it has some really useful and convenient components like the Game class, the GraphicsDeviceManager, and the Content Pipeline, but they're all 100% optional. If you do decide to use them, they can help you get going quickly and are flexible enough to handle non-trivial games. But if you want to ditch them all, you can just go straight for the stuff in the Graphics class which isn't much more than a wrapper around D3D9 (on the PC, anyway). So if you decide to make something like say a map editor, you can skip the Game class and just make a WinForms app that uses an XNA GraphicsDevice to do the drawing.

As far as 2D goes, you have the SpriteBatch class which is typically all you need. It lets you draw sprites and specify the position, rotation, scale, and even a color to modulate with it. It also handles the drawing in a efficient manner (by batching multiple sprites together when it can). If you're using this then your game's "look" is going to be completely defined by your artwork, so it'll be as unique as you want it to be. Then if you do decide to get into 3D stuff at some point, you can do whatever you can do with Direct3D/OpenGL.

For an RTS game specifically, of course there's not going to be something available specifically for that. However the components available are meant to be useful for any time of game. For instance the Game class creates a window for you, manages it, and manages a game loop: this is stuff any game can use. Same for the Content Pipeline, which is a method for importing things like images and models and then processing them to get them into format useful for your game.

Share this post


Link to post
Share on other sites
I suppose it wouldn't hurt to try out the Game class then - currently I'm just using a timer to do the loop, which I've heard is a pretty antiquated method of doing it, there must be more to it than that.

I downloaded XNA and had a play around with some of the samples. I like the way primitives work in this, but I suppose for a 2D game, sprites would be better as you say. Though, I was hoping most of the units would be built out of vectors so perhaps I will try that instead. In the meantime I am just trying to figure out how to get anti-aliasing to work - I've set the parameters but it's not liking it :P

Thanks for the advice MJP :)

Share this post


Link to post
Share on other sites
Thanks MJP! I think I figured out my problem though - is it just me, or is there no -official- way to draw a polygon out in XNA, in the same way that there is in GDI+? For 2D, you need to use sprites generally, right? So what if I want to just draw one point to another, to another and so on, like the DrawPolygon method in GDI?

Share this post


Link to post
Share on other sites
No, there's no way to just draw a polygon from a list of points like you could in GDI+. This is because the graphcis API is meant to to be a more low-level and direct way of talking to the graphics hardware, and so you pretty much have to do everything with either lines or triangles. Unfortunately it's the price you pay for vastly improved performance.

There is a "How To" section on drawing points, lines, and triangles that you might find useful.

Share this post


Link to post
Share on other sites
Well I suppose it does allow things to be tailored directly to my needs. I'll give it a shot, thanks again MJP - you've been a great help :)

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!