Using OpenGL ES Features on Mac

I am trying to make opengl in 2d space and doing the following, however it does not 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 have run out of ideas on how to fix this. My goal is currently a desktop application, but I try to make an iphone application in the end.

+6
xcode opengl-es macos
source share
3 answers

Have you included the appropriate headings?

On a Mac, this

 #import <OpenGL/OpenGL.h> 

and, perhaps,

 #import <GLUT/GLUT.h> 

On the iPhone they

 #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 a Mac.

+6
source share

I have included the OpenGL.framework framework ...

You do not enable frameworks. You include (or import) headers and link to frames. In addition, only the compiler displays only an output warning. all after it comes from the linker ( ld ).

The compiler and linker do not complain that no other of these functions exists, so your problem is simply that this function does not exist. Since it does not exist, it is not declared in the header (hence, a compiler warning) or is not exported by the framework (hence, a linker error).

Make sure you are using the OpenGL environment from the iPhone SDK and not from your (Mac OS X) system folder. They are different, and I know that in Mac OS X OpenGL.framework there is no glOrthof function. Remove the OpenGL framework that you have in your project and add the OpenGL iPhone framework using the "Add Existing Frames" command that appears when you right-click on a group in your Xcode project.

My goal is a desktop application, ...

Then you will need to find a replacement for this glOrthof function because it does not exist on the Mac. (Thanks to Brad Larson for pointing out this part of the question.)

+2
source share

You just use glOrtho on vanilla GL. GL ES supports fixed and floating data types, which is why the functions glOrthox and glOrthof.

+2
source share

All Articles