I want to use CGL or NSOpenGL to create an OpenGL window without using XCode (compile with command line gcc). I am developing something that is cross platform, and I'd like to keep the code divergence to a minimum if I can! My codebase is fully C++ at the moment. Is this at all possible? I am new to OSX and I haven't touched objective C. I looked through the developer docs and grabbed some example files. They are all using xcode. I successfully compiled the source and linked with the right framework, but the whole app bundle, xib, and info.plist thing seems a bit over the top.
This is bare-bones as one can get:
// g++ glInfo.cpp -o glInfo.x -framework OpenGL
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <stdio.h>
int main(int argc, char **argv)
{
CGLContextObj ctx;
CGLPixelFormatObj pix;
GLint npix;
CGLPixelFormatAttribute attribs[] = {
(CGLPixelFormatAttribute) 0
};
CGLChoosePixelFormat( attribs, &pix, &npix );
CGLCreateContext( pix, NULL, &ctx );
CGLSetCurrentContext( ctx );
printf("Vendor: %s\n", glGetString(GL_VENDOR) );
printf("Renderer: %s\n", glGetString(GL_RENDERER) );
printf("Version: %s\n", glGetString(GL_VERSION) );
printf("GLSL: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With