Closed TheRealNOIG closed 4 years ago
Are you able to provide your shader source?
I tested this in a environment that only has that code. Any working shader file (without a in vec3 in_position) gives this error. Here is a minimal viable shader for testing
#version 330
uniform mat4 projection_matrix;
uniform mat4 view_matrix;
uniform mat4 transformation_matrix;
out vec3 color;
attribute vec3 position;
void main(void)
{
gl_Position = projection_matrix * view_matrix * transformation_matrix * vec4(position, 1);
color = vec3(position.x+0.5, position.z+0.5, position.y+0.5);
}
#version 330
in vec3 color;
void main(void)
{
gl_FragColor = vec4(color, 1);
}
I took your code above and made a new project, here's my Program.cs: https://gist.github.com/giawa/c6bfcfa4d2924e86a5af0fcff28dce33
This runs just fine and gives the following:
Is it possible there is something else using a standard VAO somewhere?
So I just got back into work and this just got more confusing. So when I started up the app without changing anything from yesterday the error went away. So I tried testing it by changing position
with other_position
and the error came back saying no variable position
but I already searched for that variable in my project and it has already been replaced everywhere in the code with other_position
. I am even printing out the string before I pass it to the shaderprogram and it shows the updated string.
So I think I found the issue. I am using Resources.resx to load in all my files and looking through the .Designer.cs file it shows that it has some of the old code for the txt files even though when I look at it in the resources.resx page it shows the new code. I will close out this issue and keep looking into why the resources.resx is cashing old txt files.
BTW I wanted to note that it is not returning the old code but the summary of the get function has the old code in it which I think is messing with the shader compiler
Function called
/// <summary>
/// Looks up a localized string similar to #version 330
///
///uniform mat4 projection_matrix;
///uniform mat4 view_matrix;
///uniform mat4 transformation_matrix;
///
///out vec2 uv;
///
///in vec2 position;
///in vec2 in_uv;
///
///void main(void)
///{
/// gl_Position = projection_matrix * view_matrix * transformation_matrix * vec4(position, 0, 1);
/// uv = in_uv;
///}.
/// </summary>
public static string textured2DVertexShader {
get {
return ResourceManager.GetString("textured2DVertexShader", resourceCulture);
}
}
String returned
#version 330
uniform mat4 projection_matrix;
uniform mat4 view_matrix;
uniform mat4 transformation_matrix;
out vec2 uv;
in vec2 other_position;
in vec2 in_uv;
void main(void)
{
gl_Position = projection_matrix * view_matrix * transformation_matrix * vec4(other_position, 0, 1);
uv = in_uv;
}
Another note now it is completely fine with other_position but is now saying 'Shader did not contain 'in_uv'.' So I have no idea what is going on...
Does it appear to only happen when you load shaders from resources?
No. After more testing The issue was still happening and I was completely unable to debug the issue. I did just create my own handler for shaders and shader program and everything is now working without issue.
Edit: Im just going to pull OpenGL.Platform out of my project and switch over to FreeGlut or GLFW to allow for x64 on Windows and Linux support. Luckily over time Ive already been replacing parts of OpenGL.Platform and the only part im using now is creating the SDL2 window and the GenericVBO class.
Okay, sounds good. I've had really good luck with both GLFW and SDL2. Worth noting, GenericVBO isn't part of OpenGL.Platform, and it part of the OpenGL namespace. Good luck!
Why would this code return
error c1008: undefined variable \ "in_position\"
when using genericVAOs This error doesn't seem to make sense. OpenGL dose not have a variable called in_position so why would the compiler be looking for it while creating the shader program. The only place I can find using githubs search that uses in_position is the VAO class. However, in my code I am creating my own VAO that inheritance from GenericVAO that is not looking for a variable named in_position.Here is my VAO class but I dont know why this would effect the creation of the shaderprogram because the shader program is created first.