Why the hell would I want to do that? The OpenGL Shader Builder is a great development tool, but it compiles shaders using desktop OpenGL, which allows some things that ES does not. I figure if I can create a tool that links against the OpenGLES.framework in the iPhone Simulator SDK, I can get some error reporting without having to build/install/run my application.
By inspecting the command lines appearing in the Xcode build window, I got as far as this (in Makefile format, for clarity. Seriously!):
ARCH=i386
PLATFORM=/Developer/Platforms/iPhoneSimulator.platform/Developer
GCC=$(PLATFORM)/usr/bin/gcc-4.2
ISYSROOT=$(PLATFORM)/SDKs/iPhoneSimulator3.2.sdk
glsllint: glsllint.c
$(GCC) -arch $(ARCH) -isysroot $(ISYSROOT) -mmacosx-version-min=10.5 -framework OpenGLES \
glsllint.c -o glsllint
The C file itself is minimal; it contains only a call to glCreateShader()
, so that I can tell if it is linking properly. The above produces an executable, but when I try to run it:
dyld: Library not loaded: /System/Library/Frameworks/OpenGLES.framework/OpenGLES
That's the wrong location. How do I make it so the executable looks for the framework in the correct location?
I know this is not supported, but damn, wouldn't it be cool if it worked? To be clear, I'm not expecting this program to draw anything, I just want to load shader source code, use OpenGL to compile it, and print out the errors, if any.
Right now, the question is, can I produce an executable that runs?