Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenGL ES functions on a Mac

I am trying to draw opengl into 2d space, and am doing the following, however it wont compile:

    int vPort[4];
    glGetIntegerv(GL_VIEWPORT, vPort);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    glOrthof(0, vPort[2], 0, vPort[3], -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

I have included the OpenGL.framework framework, The compiler trace says the following.

In function '-[OpenGLView drawRect:]':
    warning: implicit declaration of function 'glOrthof'

Ld build/Debug/OpenGLTest1.app/Contents/MacOS/OpenGLTest1 normal x86_64
/Developer/usr/bin/gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -        L/Users/user/Documents/cocoa/OpenGLTest1/build/Debug -F/Users/user/Documents/cocoa/OpenGLTest1/build/Debug -filelist /Users/user/Documents/cocoa/OpenGLTest1/build/OpenGLTest1.build/Debug/OpenGLTest1.build/Objects-normal/x86_64/OpenGLTest1.LinkFileList -mmacosx-version-min=10.6 -framework Cocoa -framework OpenGL -o /Users/user/Documents/cocoa/OpenGLTest1/build/Debug/OpenGLTest1.app/Contents/MacOS/OpenGLTest1

Undefined symbols:
  "_glOrthof", referenced from:
      -[OpenGLView drawRect:] in OpenGLView.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I've run out of ideas on how to fix it. My target is currently a desktop app, but I am aiming to make an iphone app eventually.

like image 941
Jay Avatar asked Jan 04 '10 12:01

Jay


People also ask

Does Mac support OpenGL ES?

On the Mac, rendering is mostly done via ANGLE using presumably the stock Apple OpenGL since the full OpenGL implementation is not available, support for OpenGL ES 3.1 is currently not possible.

Does macbook pro support OpenGL?

Built-in OpenGL on macOS works a little bit different from other platforms like Windows or Linux. On Windows, system-provided opengl32. dll doesn't actually implement OpenGL but is rather a proxy-library dynamically loading functions from a driver provided by a graphics card vendor.

Can you use OpenGL on iOS?

OpenGL ES provides a C-based interface for hardware-accelerated 2D and 3D graphics rendering. The OpenGL ES framework ( OpenGLES. framework ) in iOS provides implementations of versions 1.1, 2.0, and 3.0 of the OpenGL ES specification.


1 Answers

Have you included the appropriate headers?

On the Mac, these are

#import <OpenGL/OpenGL.h>

and possibly

#import <GLUT/GLUT.h>

On the iPhone they are

#import <OpenGLES/EAGL.h>
#import <OpenGLES/EAGLDrawable.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

Also, if I'm not mistaken, glOrthof() is OpenGL-ES-specific. You may need to use glOrtho() on the Mac.

like image 65
Brad Larson Avatar answered Oct 25 '22 18:10

Brad Larson