OpenGL shader issue
I need help with some OpenGL code I am trying to create. Essentially I am trying to create a triangle that is colored green.
Below is the environment, error and code. Can someone please help ?
Env:
Mac OS: High Sierra
Video : Intel HD Graphics 4000 1536 MB graphics
Error Message:
2018-11-14 20:25:46.416648-0800 GLFW opengl[41517:6223602] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file's format version number (0) is not supported
2018-11-14 20:25:46.416773-0800 GLFW opengl[41517:6223602] MessageTracer: Falling back to default whitelist
INFO: OpenGL Version: 2.1 INTEL-10.36.19/n
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
code :
#include <stdio.h>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include "glew.h"
#include "freeglut.h" // Include the freeGLUT header file
using namespace std;
#define WINDOW_TITLE "Modern OpenGL"
#ifndef GLSL
#define GLSL(Version, source) "#version" #Version "n" #source
#endif
int WindowWidth = 800, WindowHeight = 600;
void UInitialize(int,char*);
void UInitWindow(int,char*);
void UResizeWindow(int,int);
void URenderGraphics(void);
void UCreateVBO(void);
void UCreateShaders(void);
const GLchar * VertexShader = GLSL(440,
in layout(location=0) vec4 vertex_Postion;
void main()
gl_Postion = vertex_Postion;
);
const GLchar * FragmentShader = GLSL(440,
void main()
gl_FragColor = vec4(0.0f,1.0f,0.0f,1.0f);
);
int main(int argc, char* argv)
UInitialize(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
void UInitialize(int argc, char* argv)
GLenum GlewInitResult;
UInitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
fprintf(stderr,"ERROR:%s/n",glewGetErrorString(GlewInitResult));
fprintf(stdout, "INFO: OpenGL Version: %s/n",glGetString(GL_VERSION));
UCreateVBO();
UCreateShaders();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
void UInitWindow(int argc, char* argv) GLUT_DOUBLE
void UResizeWindow(int width, int height)
glViewport(0, 0, width, height);
void URenderGraphics(void) GL_DEPTH_BUFFER_BIT);
GLuint totalVertices = 3;
//creates tirangle
glDrawArrays(GL_TRIANGLES, 0, totalVertices);
glutSwapBuffers();
void UCreateVBO(void)
GLfloat verts=
0.0f,1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
;
float numVertices = sizeof(verts);
GLuint myBufferID;
glGenBuffers(1,&myBufferID);
glBindBuffer(GL_ARRAY_BUFFER,myBufferID);
glBufferData(GL_ARRAY_BUFFER,numVertices,verts,GL_STATIC_DRAW);
GLuint floatsPerVertex = 2;
glEnableVertexAttribArray(0);
glVertexAttribPointer(0,floatsPerVertex,GL_FLOAT,GL_FALSE,0,0);
void UCreateShaders(void)
GLuint ProgramId = glCreateProgram();
GLuint vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vertexShaderId,1,&VertexShader,NULL);
glShaderSource(fragmentShaderId,1,&FragmentShader,NULL);
glCompileShader(vertexShaderId);
glCompileShader(fragmentShaderId);
GLint isCompiled = 0;
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
char *infoLog;
int infologLength = 0;
int charsWritten = 0;
if(isCompiled == GL_FALSE)
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
if (infologLength > 0)
infoLog = (char *)malloc(infologLength);
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog);
printf("n%sn",infoLog);
free(infoLog);
// Provide the infolog in whatever manor you deem best.
// Exit with failure.
glDeleteShader(vertexShaderId); // Don't leak the shader.
return;
fprintf(stdout, "OK!!!!!!!!!");
glAttachShader(ProgramId,vertexShaderId);
glAttachShader(ProgramId,fragmentShaderId);
glLinkProgram(ProgramId);
glUseProgram(ProgramId);
c++ opengl glsl glut
add a comment |
I need help with some OpenGL code I am trying to create. Essentially I am trying to create a triangle that is colored green.
Below is the environment, error and code. Can someone please help ?
Env:
Mac OS: High Sierra
Video : Intel HD Graphics 4000 1536 MB graphics
Error Message:
2018-11-14 20:25:46.416648-0800 GLFW opengl[41517:6223602] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file's format version number (0) is not supported
2018-11-14 20:25:46.416773-0800 GLFW opengl[41517:6223602] MessageTracer: Falling back to default whitelist
INFO: OpenGL Version: 2.1 INTEL-10.36.19/n
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
code :
#include <stdio.h>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include "glew.h"
#include "freeglut.h" // Include the freeGLUT header file
using namespace std;
#define WINDOW_TITLE "Modern OpenGL"
#ifndef GLSL
#define GLSL(Version, source) "#version" #Version "n" #source
#endif
int WindowWidth = 800, WindowHeight = 600;
void UInitialize(int,char*);
void UInitWindow(int,char*);
void UResizeWindow(int,int);
void URenderGraphics(void);
void UCreateVBO(void);
void UCreateShaders(void);
const GLchar * VertexShader = GLSL(440,
in layout(location=0) vec4 vertex_Postion;
void main()
gl_Postion = vertex_Postion;
);
const GLchar * FragmentShader = GLSL(440,
void main()
gl_FragColor = vec4(0.0f,1.0f,0.0f,1.0f);
);
int main(int argc, char* argv)
UInitialize(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
void UInitialize(int argc, char* argv)
GLenum GlewInitResult;
UInitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
fprintf(stderr,"ERROR:%s/n",glewGetErrorString(GlewInitResult));
fprintf(stdout, "INFO: OpenGL Version: %s/n",glGetString(GL_VERSION));
UCreateVBO();
UCreateShaders();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
void UInitWindow(int argc, char* argv) GLUT_DOUBLE
void UResizeWindow(int width, int height)
glViewport(0, 0, width, height);
void URenderGraphics(void) GL_DEPTH_BUFFER_BIT);
GLuint totalVertices = 3;
//creates tirangle
glDrawArrays(GL_TRIANGLES, 0, totalVertices);
glutSwapBuffers();
void UCreateVBO(void)
GLfloat verts=
0.0f,1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
;
float numVertices = sizeof(verts);
GLuint myBufferID;
glGenBuffers(1,&myBufferID);
glBindBuffer(GL_ARRAY_BUFFER,myBufferID);
glBufferData(GL_ARRAY_BUFFER,numVertices,verts,GL_STATIC_DRAW);
GLuint floatsPerVertex = 2;
glEnableVertexAttribArray(0);
glVertexAttribPointer(0,floatsPerVertex,GL_FLOAT,GL_FALSE,0,0);
void UCreateShaders(void)
GLuint ProgramId = glCreateProgram();
GLuint vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vertexShaderId,1,&VertexShader,NULL);
glShaderSource(fragmentShaderId,1,&FragmentShader,NULL);
glCompileShader(vertexShaderId);
glCompileShader(fragmentShaderId);
GLint isCompiled = 0;
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
char *infoLog;
int infologLength = 0;
int charsWritten = 0;
if(isCompiled == GL_FALSE)
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
if (infologLength > 0)
infoLog = (char *)malloc(infologLength);
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog);
printf("n%sn",infoLog);
free(infoLog);
// Provide the infolog in whatever manor you deem best.
// Exit with failure.
glDeleteShader(vertexShaderId); // Don't leak the shader.
return;
fprintf(stdout, "OK!!!!!!!!!");
glAttachShader(ProgramId,vertexShaderId);
glAttachShader(ProgramId,fragmentShaderId);
glLinkProgram(ProgramId);
glUseProgram(ProgramId);
c++ opengl glsl glut
Why are you trying to use#version 440GLSL on a GL 2.1 context?
– genpfault
Nov 15 '18 at 15:09
add a comment |
I need help with some OpenGL code I am trying to create. Essentially I am trying to create a triangle that is colored green.
Below is the environment, error and code. Can someone please help ?
Env:
Mac OS: High Sierra
Video : Intel HD Graphics 4000 1536 MB graphics
Error Message:
2018-11-14 20:25:46.416648-0800 GLFW opengl[41517:6223602] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file's format version number (0) is not supported
2018-11-14 20:25:46.416773-0800 GLFW opengl[41517:6223602] MessageTracer: Falling back to default whitelist
INFO: OpenGL Version: 2.1 INTEL-10.36.19/n
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
code :
#include <stdio.h>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include "glew.h"
#include "freeglut.h" // Include the freeGLUT header file
using namespace std;
#define WINDOW_TITLE "Modern OpenGL"
#ifndef GLSL
#define GLSL(Version, source) "#version" #Version "n" #source
#endif
int WindowWidth = 800, WindowHeight = 600;
void UInitialize(int,char*);
void UInitWindow(int,char*);
void UResizeWindow(int,int);
void URenderGraphics(void);
void UCreateVBO(void);
void UCreateShaders(void);
const GLchar * VertexShader = GLSL(440,
in layout(location=0) vec4 vertex_Postion;
void main()
gl_Postion = vertex_Postion;
);
const GLchar * FragmentShader = GLSL(440,
void main()
gl_FragColor = vec4(0.0f,1.0f,0.0f,1.0f);
);
int main(int argc, char* argv)
UInitialize(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
void UInitialize(int argc, char* argv)
GLenum GlewInitResult;
UInitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
fprintf(stderr,"ERROR:%s/n",glewGetErrorString(GlewInitResult));
fprintf(stdout, "INFO: OpenGL Version: %s/n",glGetString(GL_VERSION));
UCreateVBO();
UCreateShaders();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
void UInitWindow(int argc, char* argv) GLUT_DOUBLE
void UResizeWindow(int width, int height)
glViewport(0, 0, width, height);
void URenderGraphics(void) GL_DEPTH_BUFFER_BIT);
GLuint totalVertices = 3;
//creates tirangle
glDrawArrays(GL_TRIANGLES, 0, totalVertices);
glutSwapBuffers();
void UCreateVBO(void)
GLfloat verts=
0.0f,1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
;
float numVertices = sizeof(verts);
GLuint myBufferID;
glGenBuffers(1,&myBufferID);
glBindBuffer(GL_ARRAY_BUFFER,myBufferID);
glBufferData(GL_ARRAY_BUFFER,numVertices,verts,GL_STATIC_DRAW);
GLuint floatsPerVertex = 2;
glEnableVertexAttribArray(0);
glVertexAttribPointer(0,floatsPerVertex,GL_FLOAT,GL_FALSE,0,0);
void UCreateShaders(void)
GLuint ProgramId = glCreateProgram();
GLuint vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vertexShaderId,1,&VertexShader,NULL);
glShaderSource(fragmentShaderId,1,&FragmentShader,NULL);
glCompileShader(vertexShaderId);
glCompileShader(fragmentShaderId);
GLint isCompiled = 0;
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
char *infoLog;
int infologLength = 0;
int charsWritten = 0;
if(isCompiled == GL_FALSE)
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
if (infologLength > 0)
infoLog = (char *)malloc(infologLength);
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog);
printf("n%sn",infoLog);
free(infoLog);
// Provide the infolog in whatever manor you deem best.
// Exit with failure.
glDeleteShader(vertexShaderId); // Don't leak the shader.
return;
fprintf(stdout, "OK!!!!!!!!!");
glAttachShader(ProgramId,vertexShaderId);
glAttachShader(ProgramId,fragmentShaderId);
glLinkProgram(ProgramId);
glUseProgram(ProgramId);
c++ opengl glsl glut
I need help with some OpenGL code I am trying to create. Essentially I am trying to create a triangle that is colored green.
Below is the environment, error and code. Can someone please help ?
Env:
Mac OS: High Sierra
Video : Intel HD Graphics 4000 1536 MB graphics
Error Message:
2018-11-14 20:25:46.416648-0800 GLFW opengl[41517:6223602] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file's format version number (0) is not supported
2018-11-14 20:25:46.416773-0800 GLFW opengl[41517:6223602] MessageTracer: Falling back to default whitelist
INFO: OpenGL Version: 2.1 INTEL-10.36.19/n
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
code :
#include <stdio.h>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include "glew.h"
#include "freeglut.h" // Include the freeGLUT header file
using namespace std;
#define WINDOW_TITLE "Modern OpenGL"
#ifndef GLSL
#define GLSL(Version, source) "#version" #Version "n" #source
#endif
int WindowWidth = 800, WindowHeight = 600;
void UInitialize(int,char*);
void UInitWindow(int,char*);
void UResizeWindow(int,int);
void URenderGraphics(void);
void UCreateVBO(void);
void UCreateShaders(void);
const GLchar * VertexShader = GLSL(440,
in layout(location=0) vec4 vertex_Postion;
void main()
gl_Postion = vertex_Postion;
);
const GLchar * FragmentShader = GLSL(440,
void main()
gl_FragColor = vec4(0.0f,1.0f,0.0f,1.0f);
);
int main(int argc, char* argv)
UInitialize(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
void UInitialize(int argc, char* argv)
GLenum GlewInitResult;
UInitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
fprintf(stderr,"ERROR:%s/n",glewGetErrorString(GlewInitResult));
fprintf(stdout, "INFO: OpenGL Version: %s/n",glGetString(GL_VERSION));
UCreateVBO();
UCreateShaders();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
void UInitWindow(int argc, char* argv) GLUT_DOUBLE
void UResizeWindow(int width, int height)
glViewport(0, 0, width, height);
void URenderGraphics(void) GL_DEPTH_BUFFER_BIT);
GLuint totalVertices = 3;
//creates tirangle
glDrawArrays(GL_TRIANGLES, 0, totalVertices);
glutSwapBuffers();
void UCreateVBO(void)
GLfloat verts=
0.0f,1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
;
float numVertices = sizeof(verts);
GLuint myBufferID;
glGenBuffers(1,&myBufferID);
glBindBuffer(GL_ARRAY_BUFFER,myBufferID);
glBufferData(GL_ARRAY_BUFFER,numVertices,verts,GL_STATIC_DRAW);
GLuint floatsPerVertex = 2;
glEnableVertexAttribArray(0);
glVertexAttribPointer(0,floatsPerVertex,GL_FLOAT,GL_FALSE,0,0);
void UCreateShaders(void)
GLuint ProgramId = glCreateProgram();
GLuint vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vertexShaderId,1,&VertexShader,NULL);
glShaderSource(fragmentShaderId,1,&FragmentShader,NULL);
glCompileShader(vertexShaderId);
glCompileShader(fragmentShaderId);
GLint isCompiled = 0;
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
char *infoLog;
int infologLength = 0;
int charsWritten = 0;
if(isCompiled == GL_FALSE)
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
if (infologLength > 0)
infoLog = (char *)malloc(infologLength);
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog);
printf("n%sn",infoLog);
free(infoLog);
// Provide the infolog in whatever manor you deem best.
// Exit with failure.
glDeleteShader(vertexShaderId); // Don't leak the shader.
return;
fprintf(stdout, "OK!!!!!!!!!");
glAttachShader(ProgramId,vertexShaderId);
glAttachShader(ProgramId,fragmentShaderId);
glLinkProgram(ProgramId);
glUseProgram(ProgramId);
c++ opengl glsl glut
c++ opengl glsl glut
edited Nov 15 '18 at 15:07
genpfault
42.6k954100
42.6k954100
asked Nov 15 '18 at 5:14
Akhil SompalliAkhil Sompalli
4
4
Why are you trying to use#version 440GLSL on a GL 2.1 context?
– genpfault
Nov 15 '18 at 15:09
add a comment |
Why are you trying to use#version 440GLSL on a GL 2.1 context?
– genpfault
Nov 15 '18 at 15:09
Why are you trying to use
#version 440 GLSL on a GL 2.1 context?– genpfault
Nov 15 '18 at 15:09
Why are you trying to use
#version 440 GLSL on a GL 2.1 context?– genpfault
Nov 15 '18 at 15:09
add a comment |
1 Answer
1
active
oldest
votes
Read the error message:
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
this is caused, because the first line in your shader code is:
#version440
but the correct syntax would be #version 440.
This line is automatically generated by the macro GLSL. You have to insert a blank at the end of "#version", so it has to be:
#ifndef GLSL
#define GLSL(Version, source) "#version " #Version "n" #source
#endif
There is a typo in you vertex shader program. It has to be gl_Position instead of gl_Postion.
You have to check the compilation state of the vertex shader and fragment shader separately:
GLint isCompiled = 0;
glCompileShader(vertexShaderId);
glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
glCompileShader(fragmentShaderId);
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(fragmentShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalligl_Positioninstead ofgl_Postion
– Rabbid76
Nov 16 '18 at 6:26
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312849%2fopengl-shader-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Read the error message:
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
this is caused, because the first line in your shader code is:
#version440
but the correct syntax would be #version 440.
This line is automatically generated by the macro GLSL. You have to insert a blank at the end of "#version", so it has to be:
#ifndef GLSL
#define GLSL(Version, source) "#version " #Version "n" #source
#endif
There is a typo in you vertex shader program. It has to be gl_Position instead of gl_Postion.
You have to check the compilation state of the vertex shader and fragment shader separately:
GLint isCompiled = 0;
glCompileShader(vertexShaderId);
glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
glCompileShader(fragmentShaderId);
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(fragmentShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalligl_Positioninstead ofgl_Postion
– Rabbid76
Nov 16 '18 at 6:26
add a comment |
Read the error message:
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
this is caused, because the first line in your shader code is:
#version440
but the correct syntax would be #version 440.
This line is automatically generated by the macro GLSL. You have to insert a blank at the end of "#version", so it has to be:
#ifndef GLSL
#define GLSL(Version, source) "#version " #Version "n" #source
#endif
There is a typo in you vertex shader program. It has to be gl_Position instead of gl_Postion.
You have to check the compilation state of the vertex shader and fragment shader separately:
GLint isCompiled = 0;
glCompileShader(vertexShaderId);
glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
glCompileShader(fragmentShaderId);
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(fragmentShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalligl_Positioninstead ofgl_Postion
– Rabbid76
Nov 16 '18 at 6:26
add a comment |
Read the error message:
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
this is caused, because the first line in your shader code is:
#version440
but the correct syntax would be #version 440.
This line is automatically generated by the macro GLSL. You have to insert a blank at the end of "#version", so it has to be:
#ifndef GLSL
#define GLSL(Version, source) "#version " #Version "n" #source
#endif
There is a typo in you vertex shader program. It has to be gl_Position instead of gl_Postion.
You have to check the compilation state of the vertex shader and fragment shader separately:
GLint isCompiled = 0;
glCompileShader(vertexShaderId);
glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
glCompileShader(fragmentShaderId);
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(fragmentShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
Read the error message:
ERROR: 0:1: '' : Invalid Directive: version440
ERROR: 0:2: '(' : syntax error: syntax error
this is caused, because the first line in your shader code is:
#version440
but the correct syntax would be #version 440.
This line is automatically generated by the macro GLSL. You have to insert a blank at the end of "#version", so it has to be:
#ifndef GLSL
#define GLSL(Version, source) "#version " #Version "n" #source
#endif
There is a typo in you vertex shader program. It has to be gl_Position instead of gl_Postion.
You have to check the compilation state of the vertex shader and fragment shader separately:
GLint isCompiled = 0;
glCompileShader(vertexShaderId);
glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(vertexShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
glCompileShader(fragmentShaderId);
glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
GLint infologLength;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infologLength);
std::vector< char >infoLog(infologLength);
GLsizei charsWritten;
glGetShaderInfoLog(fragmentShaderId, infologLength, &charsWritten, infoLog.data());
std::cout << "compile error:" << std::endl << infoLog.data() << std::endl;
// .....
edited Nov 16 '18 at 6:25
answered Nov 15 '18 at 5:53
Rabbid76Rabbid76
42.5k123354
42.5k123354
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalligl_Positioninstead ofgl_Postion
– Rabbid76
Nov 16 '18 at 6:26
add a comment |
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalligl_Positioninstead ofgl_Postion
– Rabbid76
Nov 16 '18 at 6:26
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
I was able to fix these issues thank you for helping me out but the triangle is still not being shaded green.
– Akhil Sompalli
Nov 16 '18 at 1:13
@AkhilSompalli
gl_Position instead of gl_Postion– Rabbid76
Nov 16 '18 at 6:26
@AkhilSompalli
gl_Position instead of gl_Postion– Rabbid76
Nov 16 '18 at 6:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312849%2fopengl-shader-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown

Why are you trying to use
#version 440GLSL on a GL 2.1 context?– genpfault
Nov 15 '18 at 15:09