Jump to content
  • Advertisement
Sign in to follow this  
Dark Engineer

OpenGL GLSL not working

This topic is 2068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have problem with glsl on windows 8 in Microsoft Visual Studio Express 2012 with Radeon. Even #version 150 is not recognized in code.

 

#version 150
#include <glm\ext.hpp>
#include <glm\glm.hpp>
#include <GL\glew.h>
#include <GL\glut.h>
#include <GL\GL.h>
#include <GL\GLU.h>
#include <GL\glfw.h>

in vec2 position;
out vec4 outColor;

int main()
{
	 vec3 commeo;
	glfwInit();
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
	glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	
	glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
	glfwOpenWindow(800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW);
	glfwSetWindowTitle("Crion World Alpha");
	while( glfwGetWindowParam( GLFW_WINDOW ) )
	{
		glfwSwapBuffers();
	}

	if( glfwGetKey( GLFW_KEY_ESC ) == GLFW_PRESS )
		return 0;
	glewExperimental = GL_TRUE;
	glewInit();
	GLuint vertexBuffer;
	glGenBuffers( 1, &vertexBuffer );

	printf( "%u\n", vertexBuffer);
	 
	float vertices[] = {
		0.0f,	0.5f,
		0.5f,	-0.5f,
		-0.5f,	-0.5f
	};

	GLuint vbo;
	glGenBuffers( 1, &vbo); //generate 1 buffer
	glBindBuffer( GL_ARRAY_BUFFER, vbo );
	glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );

	GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource( vertexShader, 1, &vertexSource, NULL );
	glCompileShader( vertexShader );
	glfwTerminate();
	return 0;
}

I have errors:

 

	1	IntelliSense: unrecognized preprocessing directive	 /// #version 150
	2	IntelliSense: identifier "in" is undefined	
	4	IntelliSense: identifier "out" is undefined	
	6	IntelliSense: identifier "vec3" is undefined	
	7	IntelliSense: identifier "vertexSource" is undefined	

I have linked:

opengl32.lib
glu32.lib
glut32.lib
glfwdll.lib
glew32d.lib

Share this post


Link to post
Share on other sites
Advertisement
There are plenty of resources on this! All I did was google glCreateProgram, but for somebody new to shader, try googling GLSL Tutorial!
 
Try these:
http://samplecodebank.blogspot.dk/2011/05/glcreateprogram-example.html
http://www.lighthouse3d.com/opengl/glsl/
http://www.clockworkcoders.com/oglsl/tutorials.html
The lighthouse3d ones are really good! You will create a GLSL program object by calling glCreateProgram. To this object, you can attach Vertex, Geometry and Fragment shaders.
To start off with, why not try a vertex shader?
 
Have a look at http://www.lighthouse3d.com/tutorials/glsl-tutorial/hello-world-in-glsl/.
It's not as difficult as it seems at first. smile.png
Good luck. Edited by SuperVGA

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!