fork download
  1. Vertex:
  2. #version 330 core
  3.  
  4. layout (location = 0) in vec3 in_Position;
  5. layout (location = 1) in vec3 in_Color;
  6. layout (location = 2) in vec2 in_UV;
  7.  
  8. out vec2 vs_TexturePos;
  9.  
  10. uniform mat4 model;
  11. uniform mat4 view;
  12. uniform mat4 projection;
  13.  
  14. void main()
  15. {
  16. gl_Position = projection * view * model * vec4(in_Position, 1.0f);
  17. vs_TexturePos = in_UV;
  18. }
  19.  
  20. --------------------------------------------------------------------------------
  21. Fragment:
  22. #version 330 core
  23.  
  24. in vec2 vs_TexturePos;
  25.  
  26. uniform sampler2D t_Texture;
  27.  
  28. out vec4 color;
  29.  
  30. void main()
  31. {
  32. color = texture(t_Texture, vs_TexturePos);
  33. }
  34. ------------------------------------------------------------------------------------------
  35. And Buffer Data:
  36.  
  37. glCreateVertexArrays(1, &vao);
  38. glGenBuffers(1, &vbo);
  39.  
  40. glBindVertexArray(vao);
  41.  
  42. glBindBuffer(GL_ARRAY_BUFFER, vbo);
  43. glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), vertices.data(), GL_STATIC_DRAW);
  44.  
  45. glEnableVertexAttribArray(0);
  46. glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, Position)));
  47.  
  48. glEnableVertexAttribArray(1);
  49. glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, Color)));
  50.  
  51. glEnableVertexAttribArray(2);
  52. glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, UV)));
  53.  
  54. glBindBuffer(GL_ARRAY_BUFFER, 0);
  55. glBindVertexArray(0);
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:2: error: invalid preprocessing directive #version
 #version 330 core
  ^
prog.cpp:3:8: error: expected constructor, destructor, or type conversion before '(' token
 layout (location = 0) in vec3 in_Position;
        ^
prog.cpp:4:8: error: expected constructor, destructor, or type conversion before '(' token
 layout (location = 1) in vec3 in_Color;
        ^
prog.cpp:5:8: error: expected constructor, destructor, or type conversion before '(' token
 layout (location = 2) in vec2 in_UV;
        ^
prog.cpp:7:1: error: 'out' does not name a type
 out vec2 vs_TexturePos;
 ^
prog.cpp:9:1: error: 'uniform' does not name a type
 uniform mat4 model;
 ^
prog.cpp:10:1: error: 'uniform' does not name a type
 uniform mat4 view;
 ^
prog.cpp:11:1: error: 'uniform' does not name a type
 uniform mat4 projection;
 ^
prog.cpp:13:11: error: '::main' must return 'int'
 void main()
           ^
prog.cpp: In function 'int main()':
prog.cpp:15:2: error: 'gl_Position' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
  ^
prog.cpp:15:16: error: 'projection' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
                ^
prog.cpp:15:29: error: 'view' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
                             ^
prog.cpp:15:36: error: 'model' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
                                    ^
prog.cpp:15:49: error: 'in_Position' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
                                                 ^
prog.cpp:15:66: error: 'vec4' was not declared in this scope
  gl_Position = projection * view * model * vec4(in_Position, 1.0f);
                                                                  ^
prog.cpp:16:2: error: 'vs_TexturePos' was not declared in this scope
  vs_TexturePos = in_UV;
  ^
prog.cpp:16:18: error: 'in_UV' was not declared in this scope
  vs_TexturePos = in_UV;
                  ^
stdout
Standard output is empty