Using only C (no C++) for OpenGL? [duplicate] - c

This question already has an answer here:
How to learn OpenGL 3.x using C? [closed]
(1 answer)
Closed 9 years ago.
I want to know if there is a possibility of using OpenGL in C without even scratching c++, tutorials or basic source codes are most welcome!
And if it is possible, how deep would my C skills have to be to understand and use it? I'm currently still mostly learning, and I like to do that by biting off more than I can chew.

OpenGL is a C library, not a C++ one.
The only thing why almost all programs use C++ for OpenGL is there is a higher and simpler level manipulating it through some wrappers, libraries or frameworks. It's just more comfortable.
Here are some good examples which were distributed along with the OpenGL "Redbook" (version 2.0).
However, those examples use old-style OpenGL (rendering through functions), which is deprecated, you should always use shaders and buffers instead. Although I think for beginning it can help.
Here on StackOverflow was also discussed where to find new OpenGL examples.

Related

C data structure libraries [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Generic data structure libraries for C?
Starting off in C programming and wondering if anyone is aware of any library containing implementations of data structures such as linked list, hash maps etc ?
glib. Hard to use if you're just-starting-off because you actually have to know how to get around in pointers.
It's reasonably standard for applications that want to use that sort of thing (excuse the wishy-washy opining).
An option I usually prefer is to wrap C++ STL with C APIs myself. I don't know if there's a standard converter for this. But this is because most developers I work with understand C++-to-C APIs (part of the corporate code landscape at my firm) and STL much better than glib, in which client code tends to be egregiously error prone.

Is there a repository of C libraries? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Why there is not a comprehensive c archive network?
Like Python has a Cheeseshop and Perl has CPAN?
Google results have a lot of C++ results and I am looking for purely C libraries.
PS: Looking for *nix libraries
Yep. SourceForge, Codeplex, Github, and Google. Also, your distro's packages, if you are on Linux.
Not really, no. Google is really your best friend. Since C doesn't have a standardized body running the language in the same way as, say, Python, there is no central place for packages and marketing material.
Your best bet really is your local Linux distribution - Linux applications generally make heavy use of many layers of libraries, which you can use as a reference.
Well, there's CCAN (although I'm not sure how good it is - never really used it).

Object oriented programming in C [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Can you write object oriented code in C?
Hi, can someone point me to a tutorial explain me how OOP concepts can be implemented in ANSI C:
virtual functions
inheritance
best practice
A book about OOP programming ANSI C would be great too.
Here is the link of a book on this topic: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf (Object Oriented Programming in Ansi-C - exacty what you were looking for).
Good luck and have patience. Writing OOP in C is not an easy task, but can be somewhat rewarding if you like extreme things !
Another starting point will be to check GObject: http://library.gnome.org/devel/gobject/ and as #unwind said GTK is a good example of how to use OOP concepts in C. You can also take at GLib, is a nice library that will certainly make your C programming life a lot more easier, it is programmed in OOP manner, and as a plus is portable!
Objective-C isn't C - it's a different language.
C isn't an object-oriented language. It's possible to do some OO-style stuff, but it's not what it's built for.
Best practices in C are procedural.
I would recommend looking at the internals of the GTK+ GUI toolkit. It's an object-oriented system written in C, showing off the techniques you're after. It is open source, so there's nothing stopping you from reading it and learning.
Object-oriented mechanisms aren't defined as features of the C language. You'll have to emulate object-orientation by adding your own logic on top of the procedural nature of C.
I wouldn't recommend applying every aspect of OOP in C. While encapsulation is relatively easy to achieve, implementing inheritance would be really ugly in a language that wasn't made for that.
A good tutorial on that: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf

Is there a good collection library for C-language? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Container Class / Library for C
We have to maintain and even develop C-code of our legacy system. Is there good collection library that would support Java/C# (new versions) style collections. Hashtable, HashSet, etc. Of course without objects, but with structs. The HashTable key limitations to "strings" and ints is not a problem. It wouldn't be bad if it's free even for commercial use. I'm back to C from C# and I must say i'm depressed using our own libraries and the language in general. We're using VS2005 and MS C-compiler if that has nothing to do with anything.
Thanks & BR -Matti
I warmly recommend glib, the general-purpose library that lies underneath the GTK+ widget toolkit. It's excellent.
Here is a hashtable in C, and a more general library here

Cross Platform C library for GUI Apps? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
Free of charge, simple to learn/use, Cross Platform C library for GUI Apps? Am I looking for Qt?
Bonus question: Can I develop with the said library/toolkit on Mac then recompile on PC/Linux?
Super Bonus Question: Link to tutorial and/or download of said library.
The truth is that I'm in the process of catching up on the C family (coming from web development - XHTML/PHP/MySQL) to learn iPhone development.
I do understand that C is not C++ or ObjectiveC but I want to keep the learning curve as simple as possible. Not to get too off topic, but I am also on the lookout for good starter books and websites. I've found this so far.
I'm trying to kill many birds with one stone here. I don understand that there are platform specific extensions, but I will try to avoid those for porting purposes
The idea is that I want to write the code on one machine and just compile thrice. (Mac/Win/Linux) If Objective C will compile on Windows and Linux as well as OS X then that's good. If I must use C++, that's also fine.
If you are looking for a C++ library, then Qt basically does what you are looking for. If you want to stick to pure C, then Qt is not an option.
As a C framework you could use GTK+, it works on Linux, Windows and OS X.
Take a look at the IUP Toolkit. It is written largely in C, and is also easily bound to Lua.
To complete this post Allegro has to be here =)
http://www.talula.demon.co.uk/allegro/
Allegro Game Library, have many graphics functions and a basic GUI library
And an explicit gui (and very simple) Allegro based library
http://cgui.sourceforge.net/index.html
Both multi-platform
Another option is Tk, which is a GUI library written in C. It comes with Tcl, a scripting language also written in C. These were designed from the ground up to be embedded in C programs.
One that I have considered using was the EFL, as it's quite fast, simple, small, but powerful. I would recommend diving into Elementary, their simplest GUI toolkit, and then later on, once you get comfortable with it, move to EDJE, which is not as simple, but much more powerful.
Qt is a C++ library. Other cross platform libraries that you might consider are wxWidgets (C++), and GTK (C).
All three of the presented libraries are fully cross platform. You can also look at Tcl/Tk, but that's a toolkit :).
You tagged this question about qt, which is a tag I follow. However, you are also asking with regards to c programming.
If for some strange (or domain-enforced) reason you feel you must use C and not C++, then Qt is not for you. It was designed from the ground-up as a C++ library.
Yet I'd strongly suggest questioning why your project would need to be in C. There are many benefits to C++, and the idea that C performs intrinsically better is mostly a myth. For some hard data on that, check out Bjarne Stroustrup's Learning C++ as a New Language.
If you must stick to C then there's always GTK. The underlying API of GTK+ is C, but bindings also exist for C++ called GTKmm. I'm not a big fan of it from a design perspective, but historically powered the Gnome desktop (Ubuntu's default)...and Google chose it for their version of Chrome for Linux. So it has some cred and support there.
But do note that Ubuntu is choosing Qt5 to implement their next version of "Unity" in the desktop:
https://askubuntu.com/questions/281092/why-is-canonical-choosing-qt-over-gtk-for-unitys-next-generation
EDIT: You added:
If I must use C++, that's also fine.
"Must" is a strong word, but there is practically no comparison between C++/Qt vs. C/GTK. And the latter is becoming a thing of history.
Take a look at the Ecere SDK. It offers a cross-platform GUI toolkit, and gives you eC, an object-oriented language derived from C (with all of its functionality) that is just great for building GUIs.

Resources