Jump to content

View more

Image of the Day

I've done more tweaks to my color palette selector. #gamedev #screenshotsaturday #madewithunity https://t.co/aJXrC4ruRg
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

OpenGL and GLUT memory runtime error

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 zoner7   Members   

110
Like
0Likes
Like

Posted 14 March 2011 - 05:53 PM

So I'm writing my first program in OpenGL using GLUT. I'm writing this program while simultaneously reading the OpenGL Superbible 5th edition. After tracing through the source code, I learned that the error occurs in the OpenGL Superbible's source... but I have a feeling it's partially my fault.

Here is the error: "Unhandled exception at 0x00c0ff8b in Primitives.exe: 0xC0000005: Access violation writing location 0x00000004."
The error occurs in this chunk of code inside GLBatch.cpp on the line "nNumVerts = nVerts;":


// Start the primitive batch.
void GLBatch::Begin(GLenum primitive, GLuint nVerts, GLuint nTextureUnits)
	{
	primitiveType = primitive;
	nNumVerts = nVerts;
    
    if(nTextureUnits > 4)   // Limit to four texture units
        nTextureUnits = 4;
        
	nNumTextureUnits = nTextureUnits;
	
	if(nNumTextureUnits != 0) {
		uiTextureCoordArray = new GLuint[nNumTextureUnits];

		// An array of pointers to texture coordinate arrays
		pTexCoords = new M3DVector2f*[nNumTextureUnits];
		for(unsigned int i = 0; i < nNumTextureUnits; i++) {
			uiTextureCoordArray[i] = 0;
			pTexCoords[i] = NULL;
			}
		}
		
	// Vertex Array object for this Array
    #ifndef OPENGL_ES
	glGenVertexArrays(1, &vertexArrayObject);
	glBindVertexArray(vertexArrayObject);
	#endif
    }

Here is my code that calls this GLBatch::Begin():


temp->Begin(GL_TRIANGLES, 3);
temp->CopyVertexData3f(vertices);
temp->End();
batches.push_back(*temp);



Does anyone have an idea what's causing the problem? It's probably something very simple

#2 zerothrillz   Members   

152
Like
1Likes
Like

Posted 14 March 2011 - 06:03 PM

Well, it's more than likely wholly your part Posted Image.

What are you getting from glGetError()?

[edit] nm, Maybe I should have read that second line there...[/edit]

How are you initializing temp?

#3 zoner7   Members   

110
Like
0Likes
Like

Posted 14 March 2011 - 06:35 PM

I figured out what was going wrong. Temp was going out of scope
Thank you




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.