Questions about C

Non-platform specific questions.

Questions about C

Postby j2graves » Sat Oct 22, 2011 10:37 am

Hi all.
I've been learning C this year by reading "Teach Yourself C in 21 Days"
The material in the book is great, and all the info I'm getting is fascinating. However, there's one thing that bugs me. All that I'm learning pretty much boils down to different methods of storing and accessing data of numeric and character types. This means I'm pretty much limited to console applications. So far I have learned nothing about graphics programming, and it makes me wonder, is C even capable of graphics programming, or do you need C++ for that? After I finish C in 21 days, I intend to move on to C++ anyway, but I'm kinda wondering if learning C first is a waste of time. Could someone with a bit more experience tell me whether there's any advantage to learning both C and C++?
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Questions about C

Postby Game A Gogo » Sat Oct 22, 2011 3:30 pm

Of course C is capable of graphical interface, but you won't learn that in 21 days ;)
Try visual C, books for visual C can cost pretty a lot.
I have a book of C++ and of visual C++ and they cost me like 300$, but it was for my college.

to use visual in C you need an API, or one you build yourself, something like Direct X and OpenGL

And the advantage of knowing more language is in the workplace, you can get employed more easily if you know more languages, because that means you know the fundamentals of programming
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Questions about C

Postby j2graves » Sat Oct 22, 2011 5:13 pm

Ah, so programming visual programs is pretty much its own field? Okay. I will continue reading the C book I have, but I think I'll go with Visual C++ because it looks like the college course I'm looking at will focus mostly on C++.
I've searched on Amazon for "Visual C++" and I've found some books pretty cheap. I'd like to know if you think this may be a good resource:
http://www.amazon.com/Ivor-Hortons-Begi ... 428&sr=1-1
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Questions about C

Postby Game A Gogo » Sat Oct 22, 2011 5:40 pm

looks pretty complete, but I wouldn't even be able to tell you, as to do it is the best experience. And I'm sure your college will require you to buy specific books, and will teach you as if you knew nothing at first
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Questions about C

Postby EvanBlack » Sat Oct 22, 2011 8:43 pm

To explain why your book doesn't tell you anything about graphic programming is because your learning the C standard library. Programming languages are just compiled functions that break down into machine code. The compiler see the C code and converts it into machine code (binary) the binary code and be read one level up at Assembly code. Binary code is considered lowest level, then assembly, then you can consider C being the next. C and C++ are essentially the same. But C++ has a more extensive library but practically the same rules.

Learning C or C++ alone won't teach you how to send video commands to your video card. You need to learn an another library. I had the same misunderstanding when I first tried to learn programming. But soon found out that its not because C/C++ doesn't do graphics programming, its because you need a library linked to your code and use the functions in the library which compile to video commands, such as setting pixels onto your screen. Library's make it where you don't have to write a stack of functions to do everything you want to do with the graphics.

Some graphics libraries include, as Game a gogo stated, "OpenGL, DirectX, SDL, SFML, and ALLEGRO." If you want to learn to put graphics on the screen you have to learn to use one of these.

SFML (Simple Fast Media Library) is a great start if you want to learn graphics programming.

SDL (Simple DirectMedia Layer) is another good one for beginners but first you would have to learn WIN32 API programming. If you are working with windows. Otherwise you have to know how to use the programming for your OS to open a window, same for the rest below.

After you understand the basics of graphics programming or feel you rather start with the most powerful set available then you can choose between, DirectX (windows) or OpenGL (cross platform).

I personally only like OpenGL, its free, its open source, and its fast. The PS3 uses OpenGL. Of course they modified it for their needs.

I would say that learning C from a book that promises learning a programming language in 21 or 30 or any days won't teach you properly and from personal experience with those types of books, often what they teach you is wrong or outdated.

For a good book on learning C/C++ pick up a Primer. Its everything you need to know about the C/C++ Standard libraries. Its a very thick book and should be used as a reference manual.


As I was saying, learning graphics programming is more then learning to display graphics, you also have to know how to access your OS layer to open and handle a window.

Visual C++ doesn't actually teach you that stuff as so much as it does it for you. Visual C++ uses built in functions that are different from the standard libraries of C/C++ to build forms and applications quickly. My friend programs with Visual C++ only using the drag and drop methods and when I show him source code written in C he has no idea what it is. Even though C and C++ are practically the same language.

Visual C++ programmers often don't understand REAL C++ programming unless they work directly with the source. I use Visual C++ and its a great program, but if you want to learn how to actually write code then you should try learning actual C/C++ code. Learn the functions of the libraries your using by dissecting them. Open up the .lib files and headers and explore them until you understand them.

Get the Red Book. (Open GL API)The Red Book
Get a Primer. (The Reference Manual) C++ Primer
Learn your OS. (look up documentation online)
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: Questions about C

Postby j2graves » Sat Oct 22, 2011 9:00 pm

Thank you for that valuable information. I'll look into that. +1 for you.
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Questions about C

Postby j2graves » Sun Oct 23, 2011 4:00 pm

I looked up the OpenGL book on Amazon, and to my surprise, it had a 3 star rating. This is what one of the reviews had to say about it:

Don't buy this book. It is simply an accumulation and rehash of all the previous versions lacking the grace of somebody editing out things that have become, to all practical purposes, obsolete.

It will have you believe that certain features of OpenGL are alive and well, when in fact they are archaic, and have been replaced by new facilities in the language. This is not a book that will assist a beginner, it may be of use to a technical historian.

As an example, extensive sample code is provided to illustrate gluBuild2DMipmaps() but no code is provided for the more uptodate GL_GENERATE_MIPMAPS and there is no explanation of it's use with borders...

If you are beginning OpenGL look elsewhere.


Should I pay attention to this, or would you say the book is reliable?
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Questions about C

Postby EvanBlack » Sun Oct 23, 2011 8:36 pm

Yeah, the red book isn't really for beginners. There are many other books that provide beginners guide to OpenGL but the red book is the OpenGL tech manual provided by OpenGL and its an old version. But if you want to master it then The Red Book is a must read.

Try using the documentation on the OpenGL website as it is more updated than any book will be. Also, its free.

OpenGL Reference pages:
http://www.opengl.org/documentation/

Books on OpenGL:
http://www.opengl.org/documentation/books/


Also, I recommend, if this is your first time trying graphics, don't rush straight to OpenGL. Get a feel for it with SFML that uses OpenGL and provides easier to learn functions, but also allows OpenGL commands. Or if this is your first time programming ever, even though I say starting with C++ is easy, you might learn faster if you try using python and pygame, but I don't like how python doesn't provide good habit building.

The best thing you can do for yourself when learning to program is to first try to understand how programs work, learning both python and C++ wasn't a difficult task for me but it can be for some people.

Writing a program is like using building blocks. You have a bunch of different blocks of different colors and shapes, you need to learn how they fit together, eventually you can make your own blocks.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest