 |
|
 |
|
Next: Tools: Objective C, Java, and Cocoa
|
| Author |
Message |
External

Since: Dec 13, 2003 Posts: 120
|
(Msg. 1) Posted: Sat Nov 22, 2003 2:45 am
Post subject: What's a simple C programming environment on Mac OS X? Archived from groups: comp>sys>mac>programmer, others (more info?)
|
|
|
I need the ability to write some simple C code which would create a window
and fill it with dots of different colors (basically, I need to be able to
call plot_dot(x,y,c) where x,y are the coordinates of pixel (x,y) in the
window, and c is the color. I'm happy programming from the shell, using
emacs; I don't need a fancy IDE. I want a nice simple cc compiler, and a
library which can just draw some graphics (I do simple scientific
programming from time to time). I've checked out the Apple developers kit on
their website, and it looks like total overkill for me - I don't need (or
have time to delve into) all the fancy stuff for making cool-looking user
interfaces etc. On the other hand, maybe the basics are easier than I think.
Could someone give me some advice: what's the simplest way to write a simple
C program to draw some color dots on a 2D square of the screen? Do I use the
Apple kit (if so, is there a primer somewhere) or can I just get a C
compiler which would run from the shell (I need executables, maybe for gcc
or something like this)? Any suggestions for a simple graphical library
which can be used? Please cc: any replies to mlevin77.TakeThisOut@comcast.net. Thank you
in advance!!
Mike
--
Mike Levin
mlevin77.TakeThisOut@comcast.net >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: May 10, 2004 Posts: 973
|
(Msg. 2) Posted: Sat Nov 22, 2003 2:45 am
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <BBE40DD8.C43%mlevin77@comcast.net>,
Michael Levin <mlevin77.DeleteThis@comcast.net> wrote:
> I need the ability to write some simple C code which would create a window
> and fill it with dots of different colors (basically, I need to be able to
> call plot_dot(x,y,c) where x,y are the coordinates of pixel (x,y) in the
> window, and c is the color. I'm happy programming from the shell, using
> emacs; I don't need a fancy IDE. I want a nice simple cc compiler, and a
> library which can just draw some graphics (I do simple scientific
> programming from time to time). I've checked out the Apple developers kit on
> their website, and it looks like total overkill for me - I don't need (or
> have time to delve into) all the fancy stuff for making cool-looking user
> interfaces etc. On the other hand, maybe the basics are easier than I think.
> Could someone give me some advice: what's the simplest way to write a simple
> C program to draw some color dots on a 2D square of the screen? Do I use the
> Apple kit (if so, is there a primer somewhere) or can I just get a C
> compiler which would run from the shell (I need executables, maybe for gcc
> or something like this)? Any suggestions for a simple graphical library
> which can be used? Please cc: any replies to mlevin77.DeleteThis@comcast.net. Thank you
> in advance!!
I would recommend using OpenGL and its GLUT toolkit, which lets you create
simple applications with a window to draw in.
hth
meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Nov 18, 2003 Posts: 2
|
(Msg. 3) Posted: Sat Nov 22, 2003 3:30 am
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <BBE40DD8.C43%mlevin77@comcast.net>, Michael Levin
<mlevin77 DeleteThis @comcast.net> wrote:
> I need the ability to write some simple C code which would create a window
> and fill it with dots of different colors (basically, I need to be able to
> call plot_dot(x,y,c) where x,y are the coordinates of pixel (x,y) in the
> window, and c is the color. I'm happy programming from the shell, using
> emacs; I don't need a fancy IDE. I want a nice simple cc compiler, and a
> library which can just draw some graphics (I do simple scientific
> programming from time to time). I've checked out the Apple developers kit on
> their website, and it looks like total overkill for me - I don't need (or
> have time to delve into) all the fancy stuff for making cool-looking user
> interfaces etc. On the other hand, maybe the basics are easier than I think.
> Could someone give me some advice: what's the simplest way to write a simple
> C program to draw some color dots on a 2D square of the screen? Do I use the
> Apple kit (if so, is there a primer somewhere) or can I just get a C
> compiler which would run from the shell (I need executables, maybe for gcc
> or something like this)? Any suggestions for a simple graphical library
> which can be used? Please cc: any replies to mlevin77 DeleteThis @comcast.net. Thank you
> in advance!!
>
> Mike
the apple developer sw is free, last time i checked anyway.
when you install it, it also installs all the traditional
command line tools like cc (gcc), linker, standard libraries, etc.
you also want to make sure you install the BSD subsystem so
you get all the man entries.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Aug 16, 2003 Posts: 18
|
(Msg. 4) Posted: Sat Nov 22, 2003 12:26 pm
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Fri, 21 Nov 2003 23:45:46 GMT, Michael Levin
<mlevin77 DeleteThis @comcast.net> wrote:
> I need the ability to write some simple C code which would create a window
> and fill it with dots of different colors
Can I ask why it needs to be C code?
While it is possible to do what you want in C it sounds like a
higher level language like Tcl or Python (andm maybe even
Applescript) would be much easier and faster to use.
Unless you are doing a ton of number crunching as well C is an
awful lot of hard work to throw up a canvas and draw some
graphics!
> programming from time to time). I've checked out the Apple developers kit on
> their website, and it looks like total overkill for me
If your prograqms are similar creating one template and then copy
and modifying it shouldn't be too hard. But the Dev kit does make
life easy even for plain C programming.
> Could someone give me some advice: what's the simplest way to write a simple
> C program to draw some color dots on a 2D square of the screen?
The simplest way is to join the program and use the Apple tools.
But you can do it by hand if you really want.
> can I just get a C compiler which would run from the shell
> (I need executables, maybe for gcc or something like this)?
gcc and the other tools are all there, just open a terminal
session, start vi or emacs and hack away. You need to find the
right libraries and include them of course but they too are there
to use.
But for casual use I'd almost never use C, it's the kind of task
scripting languages were made for!
Alan G.
Author of the Learn to Program website
<a style='text-decoration: underline;' href="http://www.freenetpages.co.uk/hp/alan.gauld" target="_blank">http://www.freenetpages.co.uk/hp/alan.gauld</a><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Dec 13, 2003 Posts: 120
|
(Msg. 5) Posted: Sat Nov 22, 2003 2:46 pm
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 11/22/03 4:26 AM, in article 3fbf2a6e.651846786 RemoveThis @news.blueyonder.co.uk,
"Alan Gauld" <alan.gauld RemoveThis @btinternet.com> wrote:
> Can I ask why it needs to be C code?
> While it is possible to do what you want in C it sounds like a
> higher level language like Tcl or Python (andm maybe even
> Applescript) would be much easier and faster to use.
> Unless you are doing a ton of number crunching as well C is an
> awful lot of hard work to throw up a canvas and draw some
> graphics!
I already have a bunch of C code which does quite a bit of number
crunching (I'm moving from a different platform). I'd rather not change all
of it...
> The simplest way is to join the program and use the Apple tools.
> But you can do it by hand if you really want.
is this the Xcode package, or have I got the wrong thing?
Thanks for the help!
Mike
--
Mike Levin
mlevin77 RemoveThis @comcast.net<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Jul 28, 2003 Posts: 19
|
(Msg. 6) Posted: Sat Nov 22, 2003 6:00 pm
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: comp>sys>mac>programmer, others (more info?)
|
|
|
In Article BBE40DD8.C43%mlevin77@comcast.net, Michael Levin wrote:
> I need the ability to write some simple C code which would create a window
> and fill it with dots of different colors (basically, I need to be able to
> call plot_dot(x,y,c) where x,y are the coordinates of pixel (x,y) in the
> window, and c is the color. I'm happy programming from the shell, using
> emacs; I don't need a fancy IDE. I want a nice simple cc compiler, and a
> library which can just draw some graphics (I do simple scientific
> programming from time to time). I've checked out the Apple developers kit on
> their website, and it looks like total overkill for me - I don't need (or
> have time to delve into) all the fancy stuff for making cool-looking user
> interfaces etc. On the other hand, maybe the basics are easier than I think.
> Could someone give me some advice: what's the simplest way to write a simple
> C program to draw some color dots on a 2D square of the screen? Do I use the
> Apple kit (if so, is there a primer somewhere) or can I just get a C
> compiler which would run from the shell (I need executables, maybe for gcc
> or something like this)? Any suggestions for a simple graphical library
> which can be used? Please cc: any replies to mlevin77.TakeThisOut@comcast.net. Thank you
> in advance!!
The question about IDE aside (I would recommend using "free" Xcode),
here is the basic app that draws pixel.
#include <Carbon.h>
int main(void)
{
WindowRef window;
Rect r = { 10, 50, 300, 300 };
RGBColor color = { 0xFFFF, 0, 0 }
window = NewCWindow(NULL, &r, "\pTitle", true, 0, (WindowPtr)-1, 0, 0);
SetPort(GetWindowPort(window));
SetCPixel(100, 100, &color);
QDFlushPortBuffer(GetWindowPort(window), NULL);
while (!Button()) {}
return 0;
}
--
Mike Kluev
PS. Remove "-DELETE-." part of my e-mail address to reply.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Nov 23, 2003 Posts: 9
|
(Msg. 7) Posted: Sun Nov 23, 2003 7:42 pm
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: comp>sys>mac>programmer, others (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Dec 03, 2003 Posts: 18
|
(Msg. 8) Posted: Mon Nov 24, 2003 10:18 am
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <BBE40DD8.C43%mlevin77@comcast.net>, Michael Levin
<mlevin77 RemoveThis @comcast.net> wrote:
> I need the ability to write some simple C code which would create a window
> and fill it with dots of different colors (basically, I need to be able to
> call plot_dot(x,y,c) where x,y are the coordinates of pixel (x,y) in the
> window, and c is the color. I'm happy programming from the shell, using
> emacs; I don't need a fancy IDE. I want a nice simple cc compiler, and a
> library which can just draw some graphics (I do simple scientific
> programming from time to time). I've checked out the Apple developers kit on
> their website, and it looks like total overkill for me - I don't need (or
> have time to delve into) all the fancy stuff for making cool-looking user
> interfaces etc. On the other hand, maybe the basics are easier than I think.
> Could someone give me some advice: what's the simplest way to write a simple
> C program to draw some color dots on a 2D square of the screen? Do I use the
> Apple kit (if so, is there a primer somewhere) or can I just get a C
> compiler which would run from the shell (I need executables, maybe for gcc
> or something like this)? Any suggestions for a simple graphical library
> which can be used? Please cc: any replies to mlevin77 RemoveThis @comcast.net. Thank you
> in advance!!
Here's how to compile and link programs with quickdraw calls without
using a fancy IDE. I don't know how you find this kind of stuff out
other than asking on news groups...
cc tst.c -o tst -framework Carbon
Here's the test program posted earlier, with a few typos fixed...
#include <Carbon/Carbon.h>
int main(void)
{
WindowRef window;
Rect r = { 40, 50, 300, 300 };
RGBColor color = { 0xFFFF, 0, 0 };
window = NewCWindow(NULL, &r, 0, true, 0, (WindowPtr)-1, 0, 0);
SetPort(GetWindowPort(window));
SetCPixel(100, 100, &color);
QDFlushPortBuffer(GetWindowPort(window), NULL);
while (!Button()) {}
return 0;
}
rob<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Dec 03, 2003 Posts: 18
|
(Msg. 9) Posted: Mon Nov 24, 2003 10:39 am
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
As long as I'm complaining about how hard it can be to find out
how to do simple stuff on a mac, here's how to write directly to the screen.
Some of us actually like to write our own (very fast) graphics
without dealing with the (#$%^&*!) GUI.
/* write directly to screen... */
/* scribble to first 100 rows... */
#include <Carbon/Carbon.h>
char *getfb(short *rowl,short *nrows,short *depth,short *rowbytes);
main()
{
short rowl,nrows,depth,rowbytes;
char *fb,val;
long i,j,jump;
fb = getfb(&rowl,&nrows,&depth,&rowbytes);
rowbytes &= 0x7fff;
jump = rowbytes - rowl*depth;
for(j=0;j<100;j++)
{
for(i=0;i<rowl*depth;i++)
*fb++ = val++;
fb += jump;
}
}
char *getfb(short *rowl,short *nrows,short *depth,short *rowbytes)
{
GDHandle theGDList;
Ptr theBase;
theGDList = GetDeviceList();
theBase = (*(*theGDList)->gdPMap)->baseAddr;
*rowl = (*(*theGDList)->gdPMap)->bounds.right;
*nrows = (*(*theGDList)->gdPMap)->bounds.bottom;
*depth = (*(*theGDList)->gdPMap)->pixelSize;
*rowbytes = (*(*theGDList)->gdPMap)->rowBytes;
return(theBase);
} >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
External

Since: Mar 09, 2004 Posts: 51
|
(Msg. 10) Posted: Fri Nov 28, 2003 9:02 pm
Post subject: Re: What's a simple C programming environment on Mac OS X? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Michael Levin <mlevin77 RemoveThis @comcast.net> wrote in message news:<BBE4B6C5.1403%mlevin77@comcast.net>...
> On 11/22/03 4:26 AM, in article 3fbf2a6e.651846786 RemoveThis @news.blueyonder.co.uk,
> "Alan Gauld" <alan.gauld RemoveThis @btinternet.com> wrote:
>
> > Can I ask why it needs to be C code?
> > While it is possible to do what you want in C it sounds like a
> > higher level language like Tcl or Python (andm maybe even
> > Applescript) would be much easier and faster to use.
> > Unless you are doing a ton of number crunching as well C is an
> > awful lot of hard work to throw up a canvas and draw some
> > graphics!
>
> I already have a bunch of C code which does quite a bit of number
> crunching (I'm moving from a different platform). I'd rather not change all
> of it...
>
> > The simplest way is to join the program and use the Apple tools.
> > But you can do it by hand if you really want.
>
> is this the Xcode package, or have I got the wrong thing?
If you're working in and targeting OS X, then Xcode (or gcc as other
posters suggest) would be ideal. Otherwise, MPW (free download from
<a style='text-decoration: underline;' href="http://developer.apple.com/tools/mpw-tools/" target="_blank">http://developer.apple.com/tools/mpw-tools/</a> ) is an excellent command
line-oriented development environment. It can create any kind of
Classic executable, and Carbon executables for OS X.
The example posted by Mike Kluev would be easily built under MPW. Note
that using SetCPixel() in this way would be very slow if you were
plotting many pixels. In that instance, a much faster method (with
Carbon) would be an offscreen GWorld, set memory directly to plot
pixels, then CopyBits the offscreen PixMap into your window.
Toby
>
> Thanks for the help!
>
> Mike<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: What's a simple C programming environment on Mac OS X? |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|