Hi all
I'm newbie with OpenGL, so I'm trying to make a simple app to draw the famous triangle,
using shaders and the "modern" opengl (not using glBegin, glEnd, glOrtho, ...).
But I'm unable to compile a simple shader. The related code is:
- (BOOL) compileShader: (GLuint *)shader
type: (GLenum)type
file: (NSString *)file
{
GLint status;
const GLchar *source;
int InfoLogLength = 0;
source =
(GLchar *)[[NSString stringWithContentsOfFile: file
encoding: NSUTF8StringEncoding
error: NULL] UTF8String];
if (!source)
{
NSLog(@"Failed to load vertex shader");
return NO;
}
*shader = glCreateShader(type);
glShaderSource(*shader, 1, &source, NULL);
glCompileShader(*shader);
if (status == GL_TRUE)
return YES;
else
return NO;
}
The shader files (I copied these from internet):
#version 330 core
// Ouput data
out vec3 color;
void main()
{
// Output color = red
color = vec3(1,0,0);
}
And:
#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;
void main(){
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
}
Any advice? Thanks
Germán
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep