Advertisement

[Problematic Fragment shader source code]

Started by July 01, 2022 11:30 AM
2 comments, last by ogldev1 2 years, 4 months ago

Hello guys,

I hope you're all doing well.

So I've been trying to load a 3D Model ( obj file) but when running my application, it crashes and I get this error:

QOpenGLShader::compile(Fragment): ERROR: 0:? : 'variable' : is removed in Forward Compatible context gl_FragColor

*** Problematic Fragment shader source code ***

/*uniform sampler2D qt_Texture0;

varying highp vec4 qt_TexCoord0;

void main(void)

{

gl_FragColor = texture2D(qt_Texture0, qt_TexCoord0.st);

}*/

#version 330 core

#ifdef GL_KHR_blend_equation_advanced

#extension GL_ARB_fragment_coord_conventions : enable

#extension GL_KHR_blend_equation_advanced : enable

#endif

#define lowp

#define mediump

#define highp

#line 9

in vec4 v_color;

void main(void)

{

gl_FragColor=v_color;

}

***

ASSERT failure in QList::operator[]: "index out of range",

This is the fragment shader program:

#version 330 core
in vec4 v_color;
void main(void)

{ gl_FragColor=v_color; }

I don't get what's wrong with my application.

Any suggestion on how to fix this please ?

Thank you all.

gl_FragColor was deprecated in GLSL 1.3 (#version 130)

https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.30.pdf

The following is a summary of features deprecated in version 1.3:

• Use of the keywords attribute and varying (use in and out).
• Use of gl_ClipVertex (use gl_ClipDistance)
• Use of gl_FragData and gl_FragColor (use user-defined out instead).
[…]

You are specifying version 330 core so gl_FragColor is not valid to specify the fragment output color.

You have two options:

  1. Use the compatible GLSL version “#version 330 compatibility”, so it will accept previous versions code.
  2. Or use the core with the new way to define the output color →Define an output fragment variable ("out vec4 FragColor") and use it to specify the fragment output color.
#version 330 core
out vec4 FragColor;		
in vec4 v_color;

void main(void)
{ FragColor=v_color; } 

None

Advertisement

@Gotanod

First of all, thank you for the reply.

Well I tried what you suggested (the code lines you provided).

However the app is still crashing.

Plus, there is an error which is “index out of range” so there is a problem with some list. I didn't know which one because in the tutorial, he used many QLists, ( materialname, vertexdata, normals, etc..).

The object rendered in the tutorial is a colored cube ( not all faces have the same color), however mine is all red.

Could that be the problem ?

I tried to use the same colors as he did using blender but that didn't work, I still get the same error. (index out of range + the fragment shader problem).

This topic is closed to new replies.

Advertisement