KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What's the bare skeleton to get a triangle drawn on an OpenGL window in C on OSX? I've gone through the tutorials at Nehe and tried to get it working, but the CreateGLWindow seems hopelessly tied to win32. I want to stick to just opengl and glut, etc. I'll be eventually wrapping this in scheme, but I'd like to have a firmer understanding at the c-level beforehand. Here's what I have thus far: #include <OpenGL/gl.h>// Header File For The OpenGL32 Library #include <OpenGL/glu.h>// Header File For The GLu32 Library #include <GLUT/glut.h>// Header File For The GLut Library #define kWindowWidth 400; #define kWindowHeight 300; HGLRC hRC=NULL;// Permanent Rendering Context HDC hDC=NULL;// Private GDI Device Context HWND hWnd=NULL;// Holds Our Window Handle HINSTANCE hInstance;// Holds The Instance Of The Application LRESULTCALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);// Declaration For WndProc boolkeys[256];// Array Used For The Keyboard Routine boolactive=TRUE;// Window Active Flag Set To TRUE By Default boolfullscreen=TRUE;// Fullscreen Flag Set To Fullscreen Mode By Default GLvoid ReSizeGLScene(GLsizei width, GLsizei height)// Resize And Initialize The GL Window { if (height==0)// Prevent A Divide By Zero By { height=1;// Making Height Equal One } glViewport(0, 0, width, height);// Reset The Current Viewport glMatrixMode(GL_PROJECTION);// Select The Projection Matrix glLoadIdentity();// Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW);// Select The Modelview Matrix glLoadIdentity();// Reset The Modelview Matrix } int InitGL(GLvoid)// All Setup For OpenGL Goes Here { glShadeModel(GL_SMOOTH);// Enables Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.0f);// Black Background glClearDepth(1.0f);// Depth Buffer Setup glEnable(GL_DEPTH_
Tags (comma-separated)
Save Edits
Cancel