glsl vertex shader causes INTCONSTANT error [closed] - opengl

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
opengl 3.0
glsl 130
ubuntu 18.04
intel i7 3520m
I wrate simple vertex shader and fragment shader.
#version 130
in vec4 position;
void main(){
gl_Position = position;
}
#version 130
out vec4 fragment;
void main(){
fragment = vec4(1.0,0.0,0.0,1.0);
}
But the shaders causes errors.
Compile Error in vertex shader
0:7(2): error: syntax error, unexpected INTCONSTANT, expecting $end
Compile Error in fragment shader
0:7(2): error: syntax error, unexpected INTCONSTANT, expecting $end

glShaderSource(shader,count, &string, length);
when length is set NULL. the string is null character terminated.
but I wrote ¥0 instead of \0

Related

C++ doesn't work uniform and all variable defines [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h
#include <vector>
uniform vec2 lightpos;
uniform vec3 lightColor;
uniform float screenHeight;
uniform vec3 lightAttenuation;
uniform float radius;
uniform sampler2D texture;
void main()
{
vec2 pixel=gl_FragCoord.xy;
pixel.y=screenHeight-pixel.y;
vec2 aux=lightpos-pixel;
float distance=length(aux);
float attenuation=1.0/(lightAttenuation.x+lightAttenuation.y*distance+lightAttenuation.z*distance*distance);
vec4 color=vec4(attenuation,attenuation,attenuation,1.0)*vec4(lightColor,1.0);
gl_FragColor = color;//*texture2D(texture,gl_TexCoord[0].st);
}
Errors
'uniform' does not name a type
'vec2' was not declared in this scope
'screenHeight' was not declared in this scope
expected ';' before 'aux'
'aux' was not declared in this scope
etc.
I use Dev C++ and ...
projects parameters
/GL/ header subfiles
Don't hesitate to write if any other information is needed. I added what I know. I have done the opengl project before. But know I have to make like this YouTube Video, OpenGL 2D lighting using shaders
GLSL just look like C, it's not actually C. The code has to be compiled by a different compiler (an external one like glslc or the driver provided OpenGL compiler) and it runs on the GPU as part of a render pass.
This is a shader program, not a c++ program. You have to compile it with a shader compiler.

How to fix an issue with shaders? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm working on writing code for simpliest shader.
Here is its code.
const char* Vertex_Shader_Descrip = "#version 330/n"
"layout(location = 0) in vec3 position;/n"
"void main()/n"
"{/n"
"gl_Position = vec4(position.x, position.y, position.z, 1.0);/n"
"}/0";
glsl shader compilation fails with the error
error C0206: invalid token "<invalid atom 199709744>" in version line
Don't remember the exact version of shader, but it supports opengl 3.3
Please, could you point on my mistakes if there's any or just explain me what is wrong?
You need to use reverse slash instead of used.
const char* Vertex_Shader_Descrip = "#version 330\n"
Remove all the /n and try adding \n.

glUniformLocation returns -1 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to uniform a model matrix into a vertex shader using
glUniformMatrix4fv(glGetAttribLocation(shaderProgram, "modelMatrix"),
1, GL_FALSE, glm::value_ptr(objmesh[0]->modelMatrix));
but when I use this, the model does not show. I've used
int location = glGetAttribLocation(shaderProgram, "modelMatrix");
to find the location but it only returns -1. I've also tried using a manually made matrix (as an identity matrix) in the vertex shader and when I do that it works. I've done this exact thing to another shader, just a different program.
objmesh is just a std::vector that contains a struct with a mesh's vertices, uvs and so fourth. As of now, the modelMatrix is just an identity matrix.
I uniform the matrix in the vertex shader like so: uniform mat4 modelMatrix;
Solved it: I accidentally used glGetAttribLocation instead of glGetUniformLocation

GLSL error: `out' qualifier only valid for function parameters in GLSL 1.10 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
My shaders have in/out keywords. But I've got GLSL compile error: 'out' qualifier only valid for function parameters in GLSL 1.10. Shaders have #version 330 directive. Calling glGetString(GL_SHADING_LANGUAGE_VERSION) returns 3.30.
Here is my project: github.com/wlad031/ssu-coursework-2016. Input folder contains shaders. Main source files are src/ShaderProgramControl.cpp and src/Shader.cpp. Where is my mistake?
In your src/FileReader.cpp you have :
if (first != '#') {
res.push_back(line);
}
And this strips out the #version 330 ...

glm::vec3 array to pass shader -OpenGL -GLSL [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a 3d glm vector:
glm::vec3 Position[5];
However when I use it like this:
location = glGetUniformLocation(_programHandle, "lightPos");
glUniform3fv(location,5, &Position[0][0]);
I get segmentation fault in shader vertex:
uniform vec3 lightPos[5];
Where is the mistake in code?
Would value_ptr(Position[0]) work any better?