Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualDark Engineer

Posted 22 January 2013 - 05:29 PM

I have problem with this code because it doesn't show anything in a window, vertex and fragment shaders are loading successfully but glGetError shows something wrong is here. Please someone help me.
#include "loadshader.h"
int main()
{
	glfwInit();
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
	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");
	glewExperimental = GL_TRUE;
	glewInit();
	GLuint vertexBuffer;
	glGenBuffers( 1, &vertexBuffer );
	GLuint vao;
	glGenVertexArrays(1, & vao);
	glBindVertexArray( vao );
	GLuint vbo;
	glGenBuffers( 1, &vbo); //generate 1 buffer
	float vertices[] = {
		0.0f,	0.5f,
		0.5f,	-0.5f,
		-0.5f,	-0.5f
	};
	glBindBuffer( GL_ARRAY_BUFFER, vbo );
	glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );
	// vertex shader loading
	const string vShaderString = loadShaderFile("SimpleVertexShader.vertexshader").c_str();
	const GLchar * tempVShader = vShaderString.c_str();
	GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource(vertexShader, 1, & tempVShader, NULL);
	glCompileShader( vertexShader ); 
	std::fstream logs;
	logs.open( "logs.txt", ios::in | ios::out | ios::trunc );
	char  vsbuffer[512];
	glGetShaderInfoLog( vertexShader, 512, NULL, vsbuffer );
	logs << vsbuffer;
	//fragment shader loading
	const string fShaderString = loadShaderFile("SimpleFragmentShader.fragmentshader").c_str();
	const GLchar * tempFShader = fShaderString.c_str();
	GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
	glShaderSource(fragmentShader, 1, & tempFShader, NULL );
	glCompileShader(fragmentShader);
	char  fsbuffer[512];
	glGetShaderInfoLog( fragmentShader, 512, NULL, fsbuffer );
	logs << fsbuffer;
	if(glGetError() != 0)
	{
		logs << "sth errors";
		cout << "sth wrong" << endl;
	}
	logs.close();
	GLuint shaderProgram = glCreateProgram();
	glAttachShader( shaderProgram, vertexShader );
	glAttachShader( shaderProgram, fragmentShader);
	glBindFragDataLocation( shaderProgram, 0, "outColor" );
	glLinkProgram( shaderProgram );
	glUseProgram( shaderProgram );
	GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
	glEnableVertexAttribArray( posAttrib );
	glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
	while( glfwGetWindowParam( GLFW_WINDOW ) )
	{
		glDrawArrays( GL_TRIANGLES, 0, 3);
		glfwSwapBuffers();
	}
	glDeleteProgram( shaderProgram );
	glDeleteShader( vertexShader );
	glDeleteShader( fragmentShader );
	glDeleteBuffers(1,  & vbo );
	glDeleteVertexArrays(1, &vao );
	glfwTerminate();
	return 0;
}

#3Dark Engineer

Posted 22 January 2013 - 11:52 AM

I have problem with this code because it doesn't show anything in a window, vertex and fragment shaders are loading successfully but glGetError shows something wrong is here. Please someone help me.
#include "loadshader.h"
int main()
{
	glfwInit();
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
	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");
	glewExperimental = GL_TRUE;
	glewInit();
	GLuint vertexBuffer;
	glGenBuffers( 1, &vertexBuffer );
	GLuint vao;
	glGenVertexArrays(1, & vao);
	glBindVertexArray( vao );
	GLuint vbo;
	glGenBuffers( 1, &vbo); //generate 1 buffer
	float vertices[] = {
		0.0f,	0.5f,
		0.5f,	-0.5f,
		-0.5f,	-0.5f
	};
	glBindBuffer( GL_ARRAY_BUFFER, vbo );
	glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );
	// vertex shader loading
	const string vShaderString = loadShaderFile("SimpleVertexShader.vertexshader").c_str();
	const GLchar * tempVShader = vShaderString.c_str();
	GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource(vertexShader, 1, & tempVShader, NULL);
	glCompileShader( vertexShader ); 
	std::fstream logs;
	logs.open( "logs.txt", ios::in | ios::out | ios::trunc );
	char  vsbuffer[512];
	glGetShaderInfoLog( vertexShader, 512, NULL, vsbuffer );
	logs << vsbuffer;
	//fragment shader loading
	const string fShaderString = loadShaderFile("SimpleFragmentShader.fragmentshader").c_str();
	const GLchar * tempFShader = fShaderString.c_str();
	GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
	glShaderSource(fragmentShader, 1, & tempFShader, NULL );
	glCompileShader(fragmentShader);
	char  fsbuffer[512];
	glGetShaderInfoLog( fragmentShader, 512, NULL, fsbuffer );
	logs << fsbuffer;
	if(glGetError != 0)
	{
		logs << "sth errors";
		cout << "sth wrong" << endl;
	}
	logs.close();
	GLuint shaderProgram = glCreateProgram();
	glAttachShader( shaderProgram, vertexShader );
	glAttachShader( shaderProgram, fragmentShader);
	glBindFragDataLocation( shaderProgram, 0, "outColor" );
	glLinkProgram( shaderProgram );
	glUseProgram( shaderProgram );
	GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
	glEnableVertexAttribArray( posAttrib );
	glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
	while( glfwGetWindowParam( GLFW_WINDOW ) )
	{
		glDrawArrays( GL_TRIANGLES, 0, 3);
		glfwSwapBuffers();
	}
	glDeleteProgram( shaderProgram );
	glDeleteShader( vertexShader );
	glDeleteShader( fragmentShader );
	glDeleteBuffers(1,  & vbo );
	glDeleteVertexArrays(1, &vao );
	glfwTerminate();
	return 0;
}

#2Dark Engineer

Posted 22 January 2013 - 11:42 AM

I have problem with this code because it doesn't show anything in a window, vertex and fragment shaders are loading successfully but glGetError shows something wrong is here. Please someone help me.
#include "loadshader.h"
int main()
{
	glfwInit();
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
	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");
	glewExperimental = GL_TRUE;
	glewInit();
	GLuint vertexBuffer;
	glGenBuffers( 1, &vertexBuffer );
	GLuint vao;
	glGenVertexArrays(1, & vao);
	glBindVertexArray( vao );
	GLuint vbo;
	glGenBuffers( 1, &vbo); //generate 1 buffer
	float vertices[] = {
		0.0f,	0.5f,
		0.5f,	-0.5f,
		-0.5f,	-0.5f
	};
	glBindBuffer( GL_ARRAY_BUFFER, vbo );
	glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );
	// vertex shader loading
	const string vShaderString = loadShaderFile("SimpleVertexShader.vertexshader").c_str();
	const GLchar * tempVShader = vShaderString.c_str();
	GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource(vertexShader, 1, & tempVShader, NULL);
	glCompileShader( vertexShader ); 
	std::fstream logs;
	logs.open( "logs.txt", ios::in | ios::out | ios::trunc );
	char  vsbuffer[512];
	glGetShaderInfoLog( vertexShader, 512, NULL, vsbuffer );
	logs << vsbuffer;
	//fragment shader loading
	const string fShaderString = loadShaderFile("SimpleFragmentShader.fragmentshader").c_str();
	const GLchar * tempFShader = fShaderString.c_str();
	GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
	glShaderSource(fragmentShader, 1, & tempFShader, NULL );
	glCompileShader(fragmentShader);
	char  fsbuffer[512];
	glGetShaderInfoLog( fragmentShader, 512, NULL, fsbuffer );
	logs << fsbuffer;
	if(glGetError != 0)
	{
		logs << "sth errors";
		cout << "sth wrong" << endl;
	}
	logs.close();
	GLuint shaderProgram = glCreateProgram();
	glAttachShader( shaderProgram, vertexShader );
	glAttachShader( shaderProgram, fragmentShader);
	glBindFragDataLocation( shaderProgram, 0, "outColor" );
	glLinkProgram( shaderProgram );
	glUseProgram( shaderProgram );
	GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
	glEnableVertexAttribArray( posAttrib );
	glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
	while( glfwGetWindowParam( GLFW_WINDOW ) )
	{
		glDrawArrays( GL_TRIANGLES, 0, 3);
		glfwSwapBuffers();
	}
	/*
	glDeleteProgram( shaderProgram );
	glDeleteShader( vertexShader );
	glDeleteShader( fragmentShader );
	glDeleteBuffers(1,  & vbo );
	glDeleteVertexArrays(1, &vao );
	glfwTerminate();
	return 0;
}

#1Dark Engineer

Posted 22 January 2013 - 11:41 AM

I have problem with this code because it doesn't show anything in a window, vertex and fragment shaders are loading successfully but glGetError show something wrong is here. Please someone help me.

#include "loadshader.h"




int main()
{
	
	glfwInit();
	
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
	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");
	

	
	
	glewExperimental = GL_TRUE;
	glewInit();
	
	GLuint vertexBuffer;
	glGenBuffers( 1, &vertexBuffer );


	GLuint vao;
	glGenVertexArrays(1, & vao);
	glBindVertexArray( vao );

	GLuint vbo;
	glGenBuffers( 1, &vbo); //generate 1 buffer
	

	float vertices[] = {
		0.0f,	0.5f,
		0.5f,	-0.5f,
		-0.5f,	-0.5f
	};

	glBindBuffer( GL_ARRAY_BUFFER, vbo );
	glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );

	// vertex shader loading
	const string vShaderString = loadShaderFile("SimpleVertexShader.vertexshader").c_str();
	const GLchar * tempVShader = vShaderString.c_str();
	GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource(vertexShader, 1, & tempVShader, NULL);
	glCompileShader( vertexShader ); 
	std::fstream logs;
	logs.open( "logs.txt", ios::in | ios::out | ios::trunc );
	char  vsbuffer[512];
	glGetShaderInfoLog( vertexShader, 512, NULL, vsbuffer );
	logs << vsbuffer;

		
	//fragment shader loading
	const string fShaderString = loadShaderFile("SimpleFragmentShader.fragmentshader").c_str();
	const GLchar * tempFShader = fShaderString.c_str();
	GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
	glShaderSource(fragmentShader, 1, & tempFShader, NULL );
	glCompileShader(fragmentShader);

	char  fsbuffer[512];
	glGetShaderInfoLog( fragmentShader, 512, NULL, fsbuffer );
	logs << fsbuffer;
	if(glGetError != 0)
	{
		logs << "sth errors";
		cout << "sth wrong" << endl;
	}
	
	logs.close();
	GLuint shaderProgram = glCreateProgram();
	glAttachShader( shaderProgram, vertexShader );
	glAttachShader( shaderProgram, fragmentShader);
	glBindFragDataLocation( shaderProgram, 0, "outColor" );
	glLinkProgram( shaderProgram );
	glUseProgram( shaderProgram );

	GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
	glEnableVertexAttribArray( posAttrib );
	glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
	
	
	
	

	while( glfwGetWindowParam( GLFW_WINDOW ) )
	{
		glDrawArrays( GL_TRIANGLES, 0, 3);
		glfwSwapBuffers();
		
	}

	/*
	glDeleteProgram( shaderProgram );
	glDeleteShader( vertexShader );
	glDeleteShader( fragmentShader );

	glDeleteBuffers(1,  & vbo );
	glDeleteVertexArrays(1, &vao );

	
	glfwTerminate();
	return 0;
}

 

 


PARTNERS