Advertisement

Still Trying to Debug an Odd GLEW Issue, Please Help

Started by October 16, 2018 05:33 PM
7 comments, last by Josheir 6 years, 1 month ago

This is a follow up to a previous post.  MrHallows had asked me to post the project, so I am going to with a new fresh thread so that I can get the most needed help. 

I have put the class in the main .cpp to simplify for your debugging purposes.  My error is :  


C1189 #error: OpenGL header already included, remove this include, glad already provides it

 

I tried adding : #define GLFW_INCLUDE_NONE, and tried adding this as a preprocessor definitions too. I also tried to change the #ifdef - #endif, except I just couldn't get it working. The code repository URL is :

https://github.com/Joshei/GolfProjectRepo/tree/combine_sources/GOLFPROJ

 

The branch is : combine_sources

The Commit ID is: a4eaf31
The files involved are : shader_class.cpp,  glad.h, glew.h

glad1.cpp was also in my project, I removed it to try to solve this problem.
 

 

Here is the description of the problem at hand:

Except for glcolor3f and glRasterPos2i(10,10); the code works without glew.h.  When glew is added there is only a runtime error (that is shown above.) 

 

I could really use some exact help.  You know like, "remove the include for gl.h on lines 50, 65, and 80.  Then delete the code at line 80 that states..."

 

I hope that this is not to much to ask for, I really want to win at OpenGL.  If I can't get help I could use a much larger file to display the test values or maybe it's possible to write to an open file and view the written data as it's outputted.

 

Thanks in advance,

Josheir

Quote

When glew is added there is only a runtime error (that is shown above.)

Just to avoid confusion, are you referring to the 'OpenGL header already included' error? I ask because that appears to be a build-time error rather than a run-time error.

Advertisement

Both glut and glfw are windowing library's. Pick only one and get rid of all references to the other or you will have conflicts. Really, just get rid of glut. Stop using glut, freeglut, glutter, glutton, glutteriffic, glutonymous, tripleglut, anything that has 'glut' in the name, delete, delete, delete.

Don't include glad.h twice.

Also, glad and glew are both extension loading library's. Don't try to add glew when you have glad headers. Again, choose just one.

Delete your commented lines that have gl.h and glu.h includes, just so you won't be tempted to uncomment them.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

I've put together a basic main.cpp that uses GLFW and GLEW. It is based on the GLFW getting started code with GLEW added in.

This should work as is when you have the project paths setup to GLFW and GLEW correctly. Don't change anything or add anything. This will work as is and will show a hot pink (magenta?) OpenGL window on screen.

If you do get errors and can't figure out why, don't change the code. Post the errors you are getting instead.


#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>

int main(void)
{
	GLFWwindow* window;

	/* Initialize the library */
	if (!glfwInit())
		return -1;

	/* Create a windowed mode window and its OpenGL context */
	window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		return -1;
	}

	/* Make the window's context current */
	glfwMakeContextCurrent(window);

	if (glewInit() != GLEW_OK)
	{
		std::cout << "Could not init glew \n";
		glfwTerminate();
		return -1;
	}

	glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
  
	/* Loop until the user closes the window */
	while (!glfwWindowShouldClose(window))
	{
		/* Render here */
		glClear(GL_COLOR_BUFFER_BIT);

		/* Swap front and back buffers */
		glfwSwapBuffers(window);

		/* Poll for and process events */
		glfwPollEvents();
	}

	glfwTerminate();
	return 0;
}

 

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

4 hours ago, Zakwayda said:

Just to avoid confusion, are you referring to the 'OpenGL header already included' error? I ask because that appears to be a build-time error rather than a run-time error.

Sorry, yes, build-time error.  Thank you for doing as I asked, fleabay.  Just what I needed, right?

Josheir

One more thing. Your project is using OpenGL 3.3 core but you have no VAO's set.  You might get a weird error or nothing drawing without a VAO in 3.3 core. It is very frustrating and I remember cursing when I found the problem after many hours.

You need to set a VAO in core profile. Put the following code right before you start calling buffer or attribute calls. Set the VAO once and forget it. Once you get to using VAO's proper, you can delete it.


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

 

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

Advertisement

Thank you for the time-saver concerning the VAO,

Josheir

fleabay, I think I do have your snippet in my code as VAO1?  However, the code is responding weirdly with the new drawing implementation I did.

Maybe you could post me a response,

Josheir

This topic is closed to new replies.

Advertisement