Re: Minimal graphics lib for gcc
- From: David Phillip Oster <oster@xxxxxxxx>
- Date: Thu, 13 Jul 2006 06:34:01 GMT
In article <wissme-D1F056.15062212072006@xxxxxxxxxxxxxxxxxx>,
Jean Guillaume Pyraksos <wissme@xxxxxxxxxxx> wrote:
Thanks to all who answered. After surfing the net and the Carbon docs,
I could get that "simplegraphics.h" working. Ok for the backing store
but the window receives no events. Needs some more work but it's ok for
a beginning student in C...
#include <Carbon/Carbon.h>
WindowRef window;
void drawOval(int x, int y, int width, int height) {
Rect r = {y, x, y + height, x + width};
FrameOval(&r);
QDFlushPortBuffer(GetWindowPort(window), NULL);
}
void drawRect(int x, int y, int width, int height) {
Rect r = {y, x, y + height, x + width};
FrameRect(&r);
QDFlushPortBuffer(GetWindowPort(window), NULL);
}
void drawLine(int x1, int y1, int x2, int y2) {
MoveTo(x1,y1);
LineTo(x2,y2);
QDFlushPortBuffer(GetWindowPort(window), NULL);
}
void initGraphics() {
Rect r = {200,100,400,400};
window = NewCWindow(NULL, &r, 0, true, 0, (WindowPtr)-1, 0, 0);
SetPort(GetWindowPort(window));
}
void waitGraphics() {
printf("Type Ctrl-C to quit the program !\n");
while (1) {}
}
JG
You could try glut and the OpenGL tutorials on http://nehe.gamedev.net
but it is very easy to get your viewport or your clipping wrong so that
you can't see anything. Take it slow, and you'll master a
cross-platform, high-performance graphics package, where glut gives you
a simple model for interacting with the window system and getting events.
.
- Follow-Ups:
- Re: Minimal graphics lib for gcc
- From: Alan Woodland
- Re: Minimal graphics lib for gcc
- References:
- Minimal graphics lib for gcc
- From: Jean-Guillaume Pyraksos
- Re: Minimal graphics lib for gcc
- From: JM Marino
- Re: Minimal graphics lib for gcc
- From: Patrick Machielse
- Re: Minimal graphics lib for gcc
- From: Jean Guillaume Pyraksos
- Minimal graphics lib for gcc
- Prev by Date: Re: using rc.local to launch tomcat
- Next by Date: Re: gprof reporting 0 seconds execution time
- Previous by thread: Re: Minimal graphics lib for gcc
- Next by thread: Re: Minimal graphics lib for gcc
- Index(es):
Relevant Pages
|