The below link shows examples on how the Windows API works:
Module 1. Your First Windows Program
I am quite interested in how the Mac API looks like.
After doing some reading, I read a lot of things like XCode (Environment), Cocoa Framework, etc. However, I dont see any information about something like the Win32 API.
Doesn't Apple have a low level C API that is not based on Obective-C but just plain old C?
Your link points to a tutorial for the GUI components of Windows. In that case, the equivalent for OS X is indeed the Cocoa framework, which consists of the Foundation and AppKit libraries, which are Objective-C libraries.
Cocoa's control drawing is entirely local to the application. Therefore, the only way to build applications using controls is with Objective-C. Nothing stops you from building a C API on top of that; similar tactics have been used to build libraries like Qt or bindings to languages like Python and Ruby.
There is no plain C GUI API in OS X. There are low-level APIs (part of the Quartz graphics framework, aka the Core Graphics API) for dealing with the window manager to open the top-level windows, but these are either very complicated or completely undocumented. And even then, you'd be responsible for doing all the controls and input handling yourself. Update Some of the basic facilities that applications build on top of are also available through C APIs, namely Core Foundation, Core Graphics, Core Text, and Grand Central Dispatch. But these are still not enough to use Cocoa; Cocoa is just built on top of them.
There is also the Carbon API, which is a C API, but was intended for transitioning pre-OS X applications to OS X and is thus not suitable for new application development. In fact, I'm not even sure it is even supported anymore.
So you have two options if you want to write a GUI program for OS X in plain C:
find a wrapper library
give up and learn Objective-C, which sits on top of plain C anyway
If online tutorials, including Apple's official ones, don't suit you, the Big Nerd Ranch books on Cocoa development are good. Note that their beginner-oriented books are transitioning to the Swift language, but they have a separate book dedicated to teaching Objective-C as well.
You'll also need to know that OS X applications almost exclusively design their user interfaces using a graphical designer called Interface Builder, akin to the form designers in Visual Studio. With the Windows API, you can still get away with doing things by code, and a lot of people do so; with OS X, doing everything programmatically is difficult (but still possible).
Related
Compiler is mingw32. Language is C99. OS is windows. Graphics card is Nvidia 260GTX
I can link against opengl32/glu32 and build against it, but nothing from OpenGL 3.x is included... in fact, I would say its probably missing 2.x extensions!
GLEW and GLM are both C++ and doesn't work with straight C. Glee doesn't have any mingw32 binaries (and doesn't build cleanly on my system).
I'm using SDL and that has some OpenGL functions (??), but again, looks way outdated.
I just I don't understand the fundamental problem on why it's so difficult to get C/OpenGL working on windows? Why is is so unique? Why doesn't the Khronos provide an SDK/libraries/headers, etc?
I do OpenGL via Java/lwjgl and takes no time to set it up and get it compiling/running.
In Windows anything above OpenGL-1.1 is only accessible through extensions. This is how it has been designed and how it goes. GLEW works perfectly well with plain C (if I'm not mistaken GLEW is written in plain C).
Khronos cannot provide a SDK because actually providing the OpenGL API is a task left to the operating system vendor and in Windows the graphics drivers are required to provide the implementation. In the case of Windows this is Microsoft, who left the ARB some years ago, in favour of their proprietary Direct3D technology; there used to be heated debates which was the better API, but now that the whole world, except Microsoft settled on OpenGL this time of arguing is over.
Anyway, if you want things to be really easy, instead of GLUT, SDL, etc. use GLFW http://glfw.org, a really excellent OpenGL framework, that does all the hard things for you, does extension loading and OpenGL-3 context setup if you ask it so (you still need some extension wrapper to use extensions in your own code – however creating a pure OpenGL-3 context requires some proxy context, loading a few extensions using that and use the functions obtained to create a real OpenGL-3 context. Just for clarification).
I've been tasked with porting an existing Windows GUI app to Linux. Ideally, I'd like to do this so the same code base can be used to build either the Windows version or the Linux version. I'll be doing my work on Ubuntu 9.04. After searching around, it's unclear to me what tools are best suited to help me with this.
A list of loose requirements would be:
The code is in C, not C++, and should compile to build both Windows and Linux versions. Since it's existing code, and fairly large, converting to a managed language like .NET is out of the question for now.
I would prefer if I can use the same dialogs in both systems. In Windows, putting up a dialog is pretty simple. You build the dialog in the Resource Editor in Visual Studio, then call DialogBox() API, and handle the event messages. I would really like to find something that can do the equivalent on the Linux side.
It would also be nice to have a good IDE similar to Visual Studio.
Any helps or hints would be appreciated.
Thanks,
Winelib should let you compile Win32 code under Linux with only a few modifications.
Since your code base is in C, I'd suggest using GTK+. It's a cross platform GUI toolkit. For instance, Pidgin instant messenger GUI is created with GTK+. Glade user interface designer can be used to graphically design UIs.
If you're on a tight budget, and don't mind taking time to work around a fair number of limitations, Winlib is an option. If you're shorter on time, and have a larger budget, you might want to look into Mainsoft instead. It's not exactly perfect, but I believe it supports a considerably larger part of the Win32 API (at a correspondingly higher price).
i know c and I want to develop applications with GUI for Mac OS. Where do I start?
Learn Objective-C.
Then pick up Cocoa (and all of the Frameworks that go with it)
Buy Apple computer
Install XCode from supplied DVD
Run Software Update from system menu
Run XCode
Select Help menu, select "Developer Documentation"
Click on any of the many things that say things like "Quick Start" or "Getting Started with XCode".
Read
Program
GoTo 7.
Downloading xcode would be your first step. It's the main development environment for mac development and it's free. Then you'd want to get a book on Cocoa w/ Objective-C or Carbon w/ C. Apple is pushing Cocoa more.
The Simple DirectMedia Layer (SDL) library is yet another option. It is a cross-platform development library that can be used to write GUI-based applications for Mac OS in C.
While there is Carbon, it's a framework that's not first-class going forward. If you want to make sure that you can access all of the features of Mac OS X, you'll want to learn Objective-C and use Cocoa.
I believe all Macs nowadays come with a complete set of development tools. They're not pre-loaded on the Mac, but are in the CD-ROM or DVD-ROM package. Alternately, you can go to Apple's site and poke around until you find the development section, and download Xcode. (It'll be the same thing, but possibly a newer version.)
Mac OSX uses a language called Objective-C, which is C extended with OO abilities that are more like Smalltalk than the more usual Simula type (in C++, say). While you don't actually have to use it much, it is how you'll be writing interface code.
Further, it uses the Cocoa framework. There was a framework called Carbon, which was a cleanup and redesign of the pre-Mac OSX Macintosh system facilities, but it's being left behind.
You can find free information on either if you look, or you can buy books on them. Books are probably a better resource to learn from.
You can also try with QT and C++. Try here:
http://qt.nokia.com/products/platform/qt-for-mac
is it possible to develop a GUI in linux c??
how can be do that??
If you want to develop GUI applications for Linux with pure C you can use GTK+. IF C++ is an option you also have Qt.
There are many graphical toolkits for linux such as GTK, Qt, wxWidgets, and FLTK. They have bindings for many languages such as C and Python. I suggest you google around to see what you like. If you want a RAD you may want to check out things like glade and qt creator.
Yes. Use a GUI toolkit such as GTK+ that uses C, or find a wrapper for one of the various C++ toolkits.
XForms is a graphical user interface toolkit for X based on the X11 Xlib library. I.e., it allows you to create windows, containing all kinds of widgets (buttons, sliders, browsers, menus etc.) with a few lines of code and then attach actions to the widgets, i.e., have some function called when a button is pressed. To make this even easier XForms comes with a program called fdesign that allows you to design a GUI for a program directly on the screen and which then writes out the necessary C code for it.
XForms is written in C and has a C API, i.e., you can use it directly from a C program. It should work with X11 R4, R5, R6 & R7 and under all kinds of operating systems of the UNIX family (including MacOS X) as well as at least OpenVMS, OS/2 und Windows NT 4.0. In addition, the library is extensible and new objects can easily be created and added to the library.
http://xforms-toolkit.org
I would recommend FLTK. It may be difficult to write complex interface with it. But FLTK, as its name implies, is very small and fairly fast. What is more important, it is cross-platform, working nicely on the three major OS: linux, windows and mac. In my view, GTK/Qt/wxWidgets are far too heavy. If you statically link to these library, you will end up with a huge executable which eat up the memory; if you dynamically link to them, users have to install the library before hand, which is always troublesome.
EDIT: I just realize that this is a "C" question. Then the best choice should be GTK. If you need graphics but not interface/widgets (e.g. menu, scrollbar and so on), opengl is also nice.
Until now I've been only writing console applications but I need to write a simple window application for a school assignment.
Could somebody point me to a good tutorial how to create windows and other ordinary windows elements such as buttons, 2d graphs etc in ANSI C? is there some good library I should use?
I tried googling but there are no tutorial websites devoted to C.
If you can, I would also appreciate some example code.
Thank you.
By the way, I use Dec C++.
GTK is a good library to use, but may provide non-native looks under Windows. It looks great under GNU/Linux, especially using GNOME.
It is implemented in just C (Using the GObject Type System, part of the GLib library), so it will work great for your needs. There is also a RAD tool called Glade.
There's nothing in the ANSI C standard about windows. If you want to make a windowed application, you'll have to use platform-specific libraries (e.g. Win32, Cocoa, or X11), or some sort of cross-platform library that encapsulates that (e.g. SDL, wxWidgets, or many more).
Common places to start are Charles Petzold's Programming Windows and theForger's Win32 API Programming Tutorial.
However in most cases C is no longer the preferred language for Windows development. Object oriented technology is far better suited to GUI development, and with the introduction of MFC, C++ became the preferred language, and later with .Net, C# and C++/CLI.
The Win32 API can be hard work, much of MFC is little better than a Win32 API wrapper, the .Net framework however was designed from the ground up, and is less encumbered by the legacy of the Win32 API monster, and working with it tends to result in far greater productivity.
Either way, Dev-C++ is not a great tool for GUI development.
http://support.microsoft.com/kb/829488 which also talks how to create
Windows application: Creates a simple
Microsoft Windows-based application.
The application files include a
ProjectName.cpp file that contains a
_tWinMain function. You can use this type of application to perform
graphical user interface (GUI) based
programming.
As for tutorials... use MSDN. Win32 API is C. You don't need "Win32 ANSI C tutorial" - you need Win32 tutorial (for example http://www.winprog.org/tutorial/start.html, http://www.functionx.com/win32/Lesson01.htm) - unless, of course, you don't know ANSI C but then you just look for ANSI C tutorial. These subjects are independent.
There are lots of good libraries—too many for there to be an obvious choice without starting a religious war. I recommend that for your first library you learn something that will work on Windows, Linux, or OSX. Here are two good choices, not necessarily the best, but widely used and personal favorites:
Tcl/Tk. You write most of your application in the Tcl scripting language, but you can easily integrate your own ANSI C code into Tcl, which was designed from the beginning with such integration in mind. The Tk toolkit is very easy to learn, and you can write many simple GUIs in pure Tcl when you are getting started. Interactive, easy, and very well supported.
If you want to write everything in ANSI C, I don't know of any really simple choices, but I've been fairly happy with wxwidgets. All these tools have a pretty steep learning curve, however.
There are not many plain C GUI libraries as the strengths of the language lie elsewhere. Perhaps you should think about using a language with C bindings so you can still do the number crunching in C, but use something less painful for GUI development?
If you really want to stick to C, you can either use the OS' native API or the only current cross-platform C GUI lib I'm aware of: GTK+. If you don't really need a GUI but just graphical output, I'd go with SDL.
I suggest you download Microsoft Visual Studio 2008 Express Edition and use C#.Net.
As has been said, I suggest you use Winforms and switch to a .Net environment. It's 2009, and I think there are more suitable solutions to GUI's :P
Edit: Nvm, didn't see it was a school assignment.
However, here is a C++ guide on the Win32 API: http://www.relisoft.com/win32/index.htm