#version syntax will not work on Visual Studio C++

I can’t get the ‘#version’ syntax to compile and when I do, I get this error:

1>triangle.vert(1): fatal error C1021: invalid preprocessor command ‘version’

Am I don’t something wrong? The file I’m working with is a .vert file and the file name is ‘triangle.vert’.
Here’s the code for this file:

#version 430 core

layout(location = 0) in vec4 vPosition;

void main()
{
gl_Position = vPosition;
}

I’m getting this from a book but it doesn’t seem to help with it comes to actually setting up files.

The name of this book is called: “OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3 (8th Edition)”

You don’t compile GLSL with your C/C++ compiler, but with the compiler that is part of your OpenGL implementation. Your application only needs to load the contents of the file as a text string and pass that to glShaderSource(); compilation of shaders happens a runtime.

This is how you compile GLSL. As previously stated, it happens at runtime, not by compiling things with your compiler.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.