custom build rules

I’m self-teaching myself c++ for a small game projects me and my friends are jumping into. I got myself opengl superbible 5 and tried following their instructions… however when I try to import the lib files it prompts me that I don’t have default build rules.

The book makes mention of custom build rules for mac os X but nothing on Vstudio2008

I didn’t think that would be a problem but once I compiled the basic triangle the whole thing just crashes.

I’ve gone over the code several times and I haven’t made any syntax errors. Help?

This is really something for the Windows forum. If you want something portable, use a glut variant, then ask here if it doesn’t work.

http://www.opengl.org/resources/libraries/glut/

Also, claims like “it just crashes” show you haven’t made the vaguest effort to debug, or you don’t know how to debug. An application never just crashes, you can always trace to the point of crash with a debugger and fix from there.

That’s not how you add libs to Visual Studio. Look instead to Tools | Options | Projects and Solutions | VC++ Directories and add the directory containing the libs to “Library Files”.

I am currently using FreeGlut from the libraries from The OpenGL superbible website and I linked the libraries in the VC++ directories but I’m still getting the same crash.

Unhandled exception at 0x00000000 in retry02.exe: 0xC0000005: Access violation.

And the program freezes.

Thanks for trying anyways I’m trying my luck in vstudio helpfiles now.

Hi,
Try the latest svn release from

svn checkout http://oglsuperbible5.googlecode.com/svn/trunk/ oglsuperbible5-read-only

and then tell us if u still get crashes.

Regards,
Mobeen

Unhandled exception at 0x00000000 in retry02.exe: 0xC0000005: Access violation.

This in an OpenGL program commonly indicates that you’re not getting the function pointer for a post-1.1 entry point. Are you using any OpenGL functions from OpenGL 1.2 or higher, or any extensions? Are you calling wglGetProcAddress? Or using an extensions library?

I can’t tell you for sure, I am trying to run a book example from superbible.

As far as I can tell I’m not calling wglGetProcAddress and I’m using
…\freeglut-2.6.0\VisualStudio2008Static\Release
freeglut_static.lib
…\VisualStudio2008\GLTools\Release\gltools.lib
(and additionally when I just link the release folders in VC++ directories the compiler can’t find them)
…\freeglut-2.6.0\include
…\Src\GLTools\include

Other than that I’m not using any other files contained there, should I?
Btw thanks for that link mobeen but I tried to update the files but it didn’t change anything.

Edit: after going over some of the .h files it indicates that I am using v1.1, however I don’t know if the calls are appropriate or not as of yet.

Edit again:

Could this be the problem?
1>LINK : warning LNK4098: defaultlib ‘LIBCMT’ conflicts with use of other libs; use /NODEFAULTLIB:library

Edit again, again:

I am no longer getting the defaultlib warning but there is definitally something wrong with the function calls;
It can’t find vc100.pdb in freeglut_static.lib
and vc90.pdb in GLtools.lib

edit’’’: I’ve been staring at Folders, code, header files and error reports and I seem to be stuck exactly where I started.
1>freeglut_static.lib(freeglut_callbacks.obj) : warning LNK4099: PDB ‘vc100.pdb’ was not found with ‘…\freeglut-2.6.0\VisualStudio2008Static\Release\freeglut_static.lib’ or at …\Documents\Visual Studio 2008\Projects\retry02\Debug\vc100.pdb’; linking object as if no debug info

I can imagine that I’m not using the proper version but there is only one code example I am currently able to follow I am at loss at what to do.
I’m going to take a break and get some fresh air now and will start from scratch when I come back.

Hi.
Did u download the code from svn repository (the link i gave earlier) or did u download the zip file from the book site.
You should download the latest svn version since all these issues have been resolved in the latest svn release (revision 189).

My suggestion is to begin a fresh and download the latest svn release in a new folder on ur hardrive. Then, try to compile the code samples they should work fine. Atleast for chapter 1-10 all of the codes work fine.

I had exactly the same problem on some computers, for a project. I really wasn’t able to know where the problem comes from. It seems some glut libraries don’t like some computers since it worked fine on my computer, at my computer at university, at the teacher’s computer but not my school mate computer (with same glut libraries). And I used only GL 1.1 functions…

Maybe you can try with a different version of glut.

I got the same problem:(
and I svn the last version of the book’s source code,however,I still got the same problem.it really confuses new one to OpenGL like me.

Hi could u share a minimal glut code that may reproduce this error so that we may see what’s going wrong?

I get a solution from http://www.gamedev.net/topic/592832-error-glbatchs-vertexarrayobect-symbol-not-found/
as karwosts(in that topic) says:my graphic card drivers do not support VAO(my card is GMA4500MHD).then,I remove all the VAO related code in the source code,exactly in the GLBatch.cpp,such as:glGenVertexArrays(),glBindVertexArray(),glDeleteVertexArrays().and rebuild the related lib:GLtools.lib,then the example works on my laptop.

it seems that upgrade my driver is another solution, but I tried,finally didn’t get it right.

the first line which program crashes is:

glGenVertexArrays(1, &vertexArrayObject);

in the file:GLBatch.cpp,it seems to be portion of GLtools,not glut.

And which sample are u running? I would suggest you update your driver and keep the vao stuff in the gltools library as it was.

You can also try adding glewExperimental=GL_TRUE; before glewInit in the main function as follows and tell me if this helps.


void main() {
   gltSetWorkingDirectory(argv[0]);
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
   glutInitWindowSize(800, 600);
   glutCreateWindow("Triangle");
   glutReshapeFunc(ChangeSize);
   glutDisplayFunc(RenderScene);

   glewExperimental=GL_TRUE;
   GLenum err = glewInit();
   if (GLEW_OK != err) {
      fprintf(stderr, "GLEW Error: %s
", glewGetErrorString(err));
     return 1;
   }
	
   SetupRC();
   glutMainLoop();
}

mobeen,thanks for your reply.
1.the example that I run is the first example in OpenGL super bible 5th:the first triangle,in chapter 2,page 62.(attached)
2.I have tested your suggestion with the original gltools.lib,but it still doesn’t work on my computer,and the same error as before.

I also think upgrade my driver is more flexible,I’ll try it again late.

I upgrade my graphic card’s driver to last version,and it works!
thanks for all:)

Hi,
MAke sure you have the latest glew version. Add glewExperimental=GL_TRUE; before glewInit in the main not in the gltools lib. Could u try this,


// Triangle.cpp
// Our first OpenGL program that will just draw a triangle on the screen.
#include <GL/glew.h>
#include <GLTools.h>            // OpenGL toolkit
#include <GLShaderManager.h>    // Shader Manager Class

#ifdef __APPLE__
#include <glut/glut.h>          // OS X version of GLUT
#else
#define FREEGLUT_STATIC
#include <GL/glut.h>            // Windows FreeGlut equivalent
#endif

GLBatch	triangleBatch;
GLShaderManager	shaderManager;

///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
    {
	glViewport(0, 0, w, h);
    }


///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context. 
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC()
	{
	// Blue background
	glClearColor(0.0f, 0.0f, 1.0f, 1.0f );
    
	shaderManager.InitializeStockShaders();

	// Load up a triangle
	GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f, 
		                  0.5f, 0.0f, 0.0f,
						  0.0f, 0.5f, 0.0f };

	triangleBatch.Begin(GL_TRIANGLES, 3);
	triangleBatch.CopyVertexData3f(vVerts);
	triangleBatch.End();
	}



///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
	{
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
	shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
	triangleBatch.Draw();

	// Perform the buffer swap to display back buffer
	glutSwapBuffers();
	}


///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
	{
	gltSetWorkingDirectory(argv[0]);
	
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
	glutInitWindowSize(800, 600);
	glutCreateWindow("Triangle");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);
    
    glewExperimental=GL_TRUE;

	GLenum err = glewInit();
	if (GLEW_OK != err) {
		fprintf(stderr, "GLEW Error: %s
", glewGetErrorString(err));
		return 1;
		}
	
	SetupRC();

	glutMainLoop();
	return 0;
	}

Try this and let me know if u still get the error.

I just read the update now. Just adding a note here. Some examples in the later chapters would not work and give u runtime exception since the function pointers will be void. In that case, you should add glewExperimental =GL_TRUE; before glewInit as I told earlier.

Hi,I’m not sure wether the glew is latest version(I get all the super bible 5ed’s source code by svn). then,I’ve tried it both with my old driver and new driver,but I don’t find out any different between with or without this line:

 glewExperimental=GL_TRUE;

that is:
1.in the old driver,the program crashes at the same line
2.in the new driver,the program run not bad…because in the new driver,the program still has a problem,it can’t exit except stopping debug.and the visual studio can’t locate which line it is.then,I turn back to remove VAO related code in GLBatch.cpp,it runs without any error.

Hi,
For the basic samples this wont make any difference since these are not using advance features (exposed through extensions). In the later chapters where advanced features are introduce these are needed.

thanks for your reminding.