Thread: Same C graphic libraries for both windows & Macs?

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    31

    Same C graphic libraries for both windows & Macs?

    Greetings,
    I have a need to learn "C programming language".
    Which I will probably use on win7, Arduino, and Mac.
    C on Arduino is a tiny subset of regular C, so I can scratch that off.
    I would like to learn one language that runs on all three platforms.
    I think C is that language. But I will need to use windows-like graphic controls.
    I have completed the 15 C Tutorials here:
    C Programming Tutorial - 15 - Simple Arrays - YouTube

    I think i need to stay away from win32API, because it is specific to windows.
    What C-libraries would you folks recommend?
    Something that can run on both windows & Macs?
    And has good, all purpose, graphics libraries.

    Thanks...vmars316
    Last edited by vmars316; 02-18-2012 at 12:28 PM.
    Win7x64, HotBasic, 'Beginning C programming', 'Arduino Uno R3'.
    "All things in moderation, except for love and forgiveness"... www.vmars316.com

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You need to understand the difference between a language and a library.

    C (and C++) don't give a damn about graphics (or networking, file systems, keyboards, mice, etc etc).

    The steps you need are
    - Learn how to program (largely independent of any given language)
    - Learn a programming language (largely independent of any specific platform)
    - Learn platform specific API's

    The first will last you a lifetime, the second will last a decade or two (or more).

    As for libraries, they come and go, and are updated pretty regularly. Picking the right APIs is a skill in itself, so feel free to try several and learn what each can do.

    But if you want to write GUI programs without worrying too much about the OS underneath, then here's a list.
    List of widget toolkits - Wikipedia, the free encyclopedia

    There's plenty to choose from, so perhaps look at this one first -> wxWidgets
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    WxWidgets does not have a C interface.

    GTK has a C API and works on Mac and windows.

    GTK+ 3 Reference Manual
    Last edited by MK27; 02-18-2012 at 01:16 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Hope is the first step on the road to disappointment.

  5. #5
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    I'd say you need to learn much more of C ..and programming in general, than watching videos upto "Simple Arrays" before thinking about any kind of graphics programming.
    Consider reading up on Algorithms and Data Structures, some Design Patterns and of course a good book on the language of your choice.

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    31
    Quote Originally Posted by Salem View Post
    But if you want to write GUI programs without worrying too much about the OS underneath, then here's a list.
    List of widget toolkits - Wikipedia, the free encyclopedia

    There's plenty to choose from, so perhaps look at this one first -> wxWidgets
    Thanks...
    Win7x64, HotBasic, 'Beginning C programming', 'Arduino Uno R3'.
    "All things in moderation, except for love and forgiveness"... www.vmars316.com

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    31
    Quote Originally Posted by MK27 View Post
    WxWidgets does not have a C interface.

    GTK has a C API and works on Mac and windows.

    GTK+ 3 Reference Manual
    Great info, Thanks...vmars
    Win7x64, HotBasic, 'Beginning C programming', 'Arduino Uno R3'.
    "All things in moderation, except for love and forgiveness"... www.vmars316.com

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #9
    Registered User
    Join Date
    Jan 2010
    Posts
    31
    Quote Originally Posted by MK27 View Post
    WxWidgets does not have a C interface.

    GTK has a C API and works on Mac and windows.

    GTK+ 3 Reference Manual
    This is looking pretty good.
    GTK+ - Wikipedia, the free encyclopedia
    Here they show some C code:
    #include <gtk/gtk.h>

    Code:
    int main (int argc, char *argv[])
    {
        GtkWidget *window;
        GtkWidget *label;
     
        gtk_init(&argc, &argv);
     
        /* Create the main, top level window */
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     
        /* Give it the title */
        gtk_window_set_title(GTK_WINDOW(window), "Hello, world!");
     
        /*
        ** Map the destroy signal of the window to gtk_main_quit;
        ** When the window is about to be destroyed, we get a notification and
        ** stop the main GTK+ loop by returning 0
        */
        g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
     
        /*
        ** Assign the variable "label" to a new GTK label,
        ** with the text "Hello, world!"
        */
        label = gtk_label_new("Hello, world!");
     
        /* Plot the label onto the main window */
        gtk_container_add(GTK_CONTAINER(window), label);
     
        /* Make sure that everything, window and label, are visible */
        gtk_widget_show_all(window);
     
        /*
        ** Start the main loop, and do nothing (block) until
        ** the application is closed
        */
        gtk_main();
     
        return 0;
    }
    This code seems understandable, something I can work with.
    (The "GTK+ example using Vala instead of C" looks even better,
    but its an extra layer to deal with.)
    What I am not clear about is will GTK+ also need "X Window System",
    and/or "GLib Object System, or GObject"?

    What I need the graphics for is mostly for VisualControls(form,buttons,listbox,etc.),
    and maybe a little bit of pixel tweaking(replace one color with another).

    Thanks...vm
    Win7x64, HotBasic, 'Beginning C programming', 'Arduino Uno R3'.
    "All things in moderation, except for love and forgiveness"... www.vmars316.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding libraries in Windows
    By SterlingM in forum C++ Programming
    Replies: 1
    Last Post: 08-17-2011, 03:32 PM
  2. Graphic Libraries for C++
    By CrazyJohn66 in forum Game Programming
    Replies: 15
    Last Post: 07-22-2008, 02:59 PM
  3. C++ and Macs
    By DominicTrix in forum C++ Programming
    Replies: 3
    Last Post: 06-14-2005, 08:39 PM
  4. Linux Graphic Libraries You Use?
    By drdroid in forum Linux Programming
    Replies: 2
    Last Post: 10-06-2003, 07:34 PM
  5. macs are for druggies?
    By ZerOrDie in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-20-2002, 11:38 PM

Tags for this Thread