[solved] Fragment shader problem on OS X: gl_FragColor

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
MyOwnClone
Posts: 3
Joined: Tue Nov 16, 2010 6:50 am

[solved] Fragment shader problem on OS X: gl_FragColor

Post by MyOwnClone »

Hi,
I am using this fragment shader:

Code: Select all

#version 120
 
varying float realDist;
 
uniform sampler2D GrassTexture;
 
void main ()
{
    gl_FragColor = texture2D( GrassTexture, gl_TexCoord[0].st);
}
 
Running on OS X and using irrlicht 1.8. On my windows machine, everything works great, but when I try to run my app with
this shader used, i got this error message on OS X:

Code: Select all

GLSL shader failed to compile
ERROR: 0:9: Use of undeclared identifier 'gl_FragColor'
As far as i know, irrlicht uses lower versions of OpenGL on OS X than on Windows. But gl_FragColor is supported even in opengl 2.1. So why it won't compile?
This is what I get when irrlicht starts:

Code: Select all

Irrlicht Engine version 1.8.0
Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64
Using renderer: OpenGL 2.1
AMD Radeon HD 6750M OpenGL Engine: ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
GLSL version: 1.2
Code which uses this shader:

Code: Select all

s32 materialGrass = repoGame.get_context()->device->getVideoDriver()->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles(
        vertPath, "main", video::EVST_VS_1_1,
        fragPath, "main", video::EPST_PS_1_1,
        grassShaderCB, video::EMT_TRANSPARENT_ALPHA_CHANNEL);
fragPath points to fragment shader mentioned above.

Does somebody know where is the problem?
Last edited by MyOwnClone on Thu Apr 11, 2013 3:05 pm, edited 1 time in total.
MyOwnClone
Posts: 3
Joined: Tue Nov 16, 2010 6:50 am

Re: Fragment shader problem on OS X: gl_FragColor is undecla

Post by MyOwnClone »

Sorry,
my bad. The real cause of the problem was in another part of code which resulted that fragment shader code was supplied both to vertex shader and fragment shader, resulting in error in compilation.

Problem solved!
Post Reply