Jump to content
  • Advertisement
Sign in to follow this  
borysson

New to C need some graphics advice

This topic is 2596 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 have been unable to find much in the way of getting a picture onto the screen with C programming language. Also how to set the screen size (and perhaps how many colours).

I did google search, perhaps I just need to have an indepth look at a game library such as Allegro?

Share this post


Link to post
Share on other sites
Advertisement
The C programming language knows nothing about graphics.

However, your operating system provides a variety of services that allow a programmer to utilize the graphics device (and also the sound and input devices). These operating systems typically provide a library that will allow a programmer to access these services, usually though a C-interface. In Windows, this is typically done through the win32's GDI. Third party libraries, such as Allegro, SDL, and HGE, typically wrap these system calls and provide a variety of additional functionalities, such as cross-platform support, resource management, window management, or basic scene management. For instance, you can pickup SDL and build your own Final Fantasy style RPG from scratch, or you could use a library that provides the sprite loading, tilemap rendering, event handling.

To answer your question, you will need to learn an API in order to do any sort of functionality outside of file input and output.

Share this post


Link to post
Share on other sites
Thank you.
No wonder I was confused (java knows a little bit about graphics and thats where I was for a bit before focusing on C).
(think Pokemon) I choose Allegro! or SDL, which is better? Just kidding.

Share this post


Link to post
Share on other sites
On a window's machine you have two choices, OpenGL or DirectX when choosing how to render graphics. You can write the code yourself, or using an engine to do it for you.

Share this post


Link to post
Share on other sites

On a window's machine you have two choices, OpenGL or DirectX when choosing how to render graphics.
[/quote]
There are other choices. You can use the GDI, as fastcall22 mentioned.


I choose Allegro! or SDL, which is better?
[/quote]
I personally prefer SDL, but Allegro seems fine from snippets I've seen people use here. Either will suffice for what you want to do. In computer science, there is rarely an unambiguous "better" option. Every option has a set of costs and benefits, and one must weigh them before deciding.

Share this post


Link to post
Share on other sites
If you are doing 3D and want hardware acceleration, and you're using plain C, I would strong recommend OpenGL with either freeglut, or SDL to set up the window for you. The plus here, these are portable, well documented, and fairly easy to use. If you use SDL, you'll also have sound support.



I haven't used DirectX myself, but from what I've heard, if you're coding in C and not C++, DirectX is a nightmare.

If you want just basic software drawing, bitblt, etc, you can also go with SDL. You can do all of that in win32 GDI as well, but I think that's my last choice just because its non-portable, and sometimes a bit weird.

Is there any reason you would choose C over C++? Using C++ opens up more options. I use C myself for all my hobby projects, but that's more for a 'because I can' reason. I know your post says you're new to C, but there's a big overlap of C and C++. You can write a 'C++' application that makes use of external C++ libraries' objects like SFML or DirectX, but write your own code in a C style. C++ also has a stronger type system, so a few d'oh mistakes that go by in C with just a compiler warning won't fly on C++.

Share this post


Link to post
Share on other sites
Well there is also the super old graphics.h used with Turbo C :P
I've never used it but from what I've heard it is used in old borderland compiler and allows basic graphics functions
I dont think that a game is possible with it though

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!