Re: Minimal graphics lib for gcc



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.
.



Relevant Pages

  • Re: Mouse Position
    ... VOID* pVertices; ... LONG WINAPI wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM ... HWND CrteWnd(const char *pszName, int x, int y, int w, int h) { ... // Create the application's window ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: CDialog minimize topic
    ... I'm calling to my dialog from CMatAgentMFCApp: ... void CMatAgentMFCApp::OnRead ... int cxIcon = GetSystemMetrics; ... If you want to block the parent window you could simple disable ...
    (microsoft.public.vc.mfc)
  • Re: How add buton onto title bar of any external active window?
    ... I want to add buttons ontoany active window. ... int sm_CXSIZE; ... static int WindowsFeaturesWidth(HWND hwnd, DWORD style) ... LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ...
    (microsoft.public.win32.programmer.gdi)
  • Re: CreateProcess() its extermely slow
    ... I notice that if my application has no Window, ... int APIENTRY _tWinMain(HINSTANCE hInstance, ... LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, ... LPARAM lParam) ...
    (microsoft.public.vc.mfc)
  • JFrame Resize Issues (Redux)
    ... However, when the LookAndFeel is set, Java's Window Manager ... public int OffSetX = 0; ... private Rectangle positRectangle; ... public void componentHidden{ ...
    (comp.lang.java.programmer)