Opengl.CubeMap, vertec&fragmentshader error.

Hey. new to Opengl and i get this error regarding(i believe) my vertexshader.


ERROR: 0:17: 'gl_Position' : undeclared identifier
ERROR: 0:17: 'assign' :  cannot convert from '4-component vector of highp float' to 'highp float'

Any input is highly appreciated thnx.

Heres the vertexshader


#version 330 core
layout (location = 0) in vec3 position;

    out vec3 TexCoords; 
    

    uniform mat4 projection;
    uniform mat4 view;


    void main()
    {

        

     TexCoords = position; 
    gl_Position = projection * view * vec4(position.xyz, 1.0);

    }

And the FragmentShader


    #version 330 core


    in vec3 TexCoords;


    out vec4 color;


    uniform samplerCube skybox;


    void main()
    {    
    
    color = texture(skybox,TexCoords);
    }

From https://www.khronos.org/files/opengl-quick-reference-card.pdf
““#version 150” is required in shaders using version 1.50 of the language. #version
must occur in a shader before anything else other than white space or comments.”
Try checking for that. (I know it’s for 3.2; I couldn’t find one for 3.3)

[QUOTE=Nokturnis;1291790]From https://www.khronos.org/files/opengl-quick-reference-card.pdf
““#version 150” is required in shaders using version 1.50 of the language. #version
must occur in a shader before anything else other than white space or comments.”
Try checking for that. (I know it’s for 3.2; I couldn’t find one for 3.3)[/QUOTE]

thx for the response. i replaced the versions of the Vertex&fragmentShader to #150 core which gives me the following error," ERROR: 0:2: ‘location’ : syntax error syntax error"

in the VertexShader.

Keep #version 330. Make sure there are no white spaces or comments BEFORE that.

Make sure you are compiling your vertex shader source as GL_VERTEX_SHADER, not GL_FRAGMENT_SHADER.

Thx for the input. I’m not super-familliar with shaders, however i don’t think there’s anything wrong with it,then again i really wish to crack this issue.


#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
using namespace std;

#include <stdlib.h>
#include <string.h>

#include <GL/glew.h>

#include "shader.hpp"









GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){

    // Create the shaders
    GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
    GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);

    // Read the Vertex Shader code from the file
    std::string VertexShaderCode;
    std::ifstream VertexShaderStream(vertex_file_path, std::ios::in);
    if(VertexShaderStream.is_open()){
        std::stringstream sstr;
        sstr << VertexShaderStream.rdbuf();
        VertexShaderCode = sstr.str();
        VertexShaderStream.close();
    }else{
        printf("Impossible to open %s. Are you in the right directory ? Don't forget to read the FAQ !
", vertex_file_path);
        getchar();
        return 0;
    }

    // Read the Fragment Shader code from the file
    std::string FragmentShaderCode;
    std::ifstream FragmentShaderStream(fragment_file_path, std::ios::in);
    if(FragmentShaderStream.is_open()){
        std::stringstream sstr;
        sstr << FragmentShaderStream.rdbuf();
        FragmentShaderCode = sstr.str();
        FragmentShaderStream.close();
    }

    GLint Result = GL_FALSE;
    int InfoLogLength;


    // Compile Vertex Shader
    printf("Compiling shader : %s
", vertex_file_path);
    char const * VertexSourcePointer = VertexShaderCode.c_str();
    glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL);
    glCompileShader(VertexShaderID);
    // Check Vertex Shader
    glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    if ( InfoLogLength > 0 ){
        std::vector<char> VertexShaderErrorMessage(InfoLogLength+1);
        glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]);
        printf("%s
", &VertexShaderErrorMessage[0]);
    }



    // Compile Fragment Shader
    printf("Compiling shader : %s
", fragment_file_path);
    char const * FragmentSourcePointer = FragmentShaderCode.c_str();
    glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL);
    glCompileShader(FragmentShaderID);

    // Check Fragment Shader
    glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    if ( InfoLogLength > 0 ){
        std::vector<char> FragmentShaderErrorMessage(InfoLogLength+1);
        glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]);
        printf("%s
", &FragmentShaderErrorMessage[0]);
    }



    // Link the program
    printf("Linking program
");
    GLuint ProgramID = glCreateProgram();
    glAttachShader(ProgramID, VertexShaderID);
    glAttachShader(ProgramID, FragmentShaderID);
    glLinkProgram(ProgramID);

    // Check the program
    glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
    glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    if ( InfoLogLength > 0 ){
        std::vector<char> ProgramErrorMessage(InfoLogLength+1);
        glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]);
        printf("%s
", &ProgramErrorMessage[0]);
    }

    
    glDetachShader(ProgramID, VertexShaderID);
    glDetachShader(ProgramID, FragmentShaderID);
    
    glDeleteShader(VertexShaderID);
    glDeleteShader(FragmentShaderID);

    return ProgramID;
}