开发者

Is there a simple library for C++ to draw to the screen?

开发者 https://www.devze.com 2023-01-04 18:05 出处:网络
I\'m just starting out in C++ programming and I want to try creating a space invaders clone in C++, I want to avoid using game libraries and things that would solve a lot of the problems (like game lo

I'm just starting out in C++ programming and I want to try creating a space invaders clone in C++, I want to avoid using game libraries and things that would solve a lot of the problems (like game loop and vector maths etc) so I can tackle these myself, but, I have no idea how to begin drawing things to a screen.

I was wondering if there's a good library I should use to simply allow myself to draw lines or graphics to the screen or whether开发者_开发百科 I can do this without the use of a library?

I'd appreciate any advice,

Thanks.


I recommend either Allegro or SDL, even though they are mostly 2D:

Allegro:
http://alleg.sourceforge.net/

SDL:
http://www.libsdl.org/


Check out SDL.


I would check SDL or Allegro


I guess SDL is the simple library you're looking for. If you want you can work pretty much with the screen as a framebuffer where you modify pixel by pixel if you really want. It's a C library, but it's quite object oriented, so it's nice to work with in C++ as well.


PixelToaster (was OpenPTC/TinyPTC) is one of my favorites. It's fairly minimalistic and very easy to get started with.


There are a lot of simple libraries. SDL and Allegro have gotten a lot of mentions already, but there are several others as well:

  • OpenGL
  • DirectX (yes, yes, I know, not "simple," but certainly gets the job done)
  • Cairo (for vector drawing)
  • SFML (an SDL-alike that has some drawing primitives)
  • GGI
  • Qt (which does a lot more than widgets and is highly modular)
  • DirectFB (which works without a host GUI like X.org)

And many others I'll be kicking myself for forgetting.


In my opinion, starting right away with a GUI library like wxWidgets (www.wxwidgets.org) is a good idea because they are often platform-independent and provide good drawing mechanisms -- plus all that other GUI stuff you might find useful later on.


Wouldn't it be more interesting to do it by printing 80x?? ascii characters on the screen every .x seconds?

0

精彩评论

暂无评论...
验证码 换一张
取 消