PDA

View Full Version : OpenGL Shader Builder, Lion, and GLSL 1.50



Name 777
08-31-2011, 04:03 PM
Howdy,
Has anyone figured out how to get OpenGL Shader Builder to accept GLSL 1.5 syntax under Lion? If not, what do people use to develop and test shaders on the mac side? I could always use something like Text Wrangler, but I would miss the real-time code checking.

Pop N Fresh
09-03-2011, 02:37 AM
OpenGL Shader Builder has been deprecated for some time. It probably hasn't been updated to acquire an OpenGL 3.2 context under Lion.

GLSLEditorSample is the replacement AFAIK.

Name 777
09-15-2011, 12:30 AM
Great, I'll see if I can track that utility down.

Thanks for your help.

Name 777
09-18-2011, 05:57 PM
So it looks like GLSLEditorSample no longer exists in Apple's sample code repository; I doubt it has support for post Opengl 2 shader syntax anyway. For now I will just write the shaders in something like Xcode or TextWrangler and debug them manually during the compile stage.

Which leads me to my next problem. Here is the basic Fragment shader I am trying to compile:



#version 140

uniform vec3 MortarColor, BrickColor;
uniform vec2 BrickSize;
uniform vec2 BrickPct;

in vec2 MCposition;
in float LightIntensity;

out vec4 FragColor;

void main()
{
vec3 color;
vec2 position, useBrick;

position = MCposition / BrickSize;

if(fract(position.y * 0.5) > 0.5)
position.x+=0.5;

position=fract(position);

useBrick = step(position, BrickPct);

color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
color *= LightIntensity;

FragColor = vec4(color,1.0);
}


Compilation fails with the following log output:

ERROR: 0:4: 'premature EOF' : syntax error syntax error

I don't see any syntax errors, nor any errant EOF characters. Is there anybody out there who might know why I keep getting this error?

Thanks.

arekkusu
09-18-2011, 08:05 PM
Perhaps your shader loader is broken?

Set a breakpoint on glShaderSource, then inspect **string (note: pointer to char *).

Name 777
09-18-2011, 10:26 PM
No, I've traced the problem to how I'm deriving cStrings from Cocoa. I've got a separate loader in C++ that handles the files just fine. I was using a Cocoa setup until I had gotten SDL 1.3 to properly initialize OpenGL 3.2 for Lion, which I have just figured out.

My guess is that I did something improperly with the text encoding when I pulled the cString from the NSString. I did a memory dump of the cString (as you suggested above), and didn't see anything out of the ordinary (no strange byte codes or anything).

Thank you for your suggestion. Now that I have my preferred solution, I'll put the cocoa-based loader on the back burner.