[ create a new paste ] login | about

Link: http://codepad.org/C3NGHSxC    [ raw code | fork ]

C++, pasted on Apr 10:
GLvoid LOADcubeGL(GLvoid){

        glGenBuffersARB		    = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
        glBindBufferARB		    = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
        glBufferDataARB	            = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
        glBufferSubDataARB	    = (PFNGLBUFFERSUBDATAARBPROC)wglGetProcAddress("glBufferSubDataARB");
        glDeleteBuffersARB	    = (PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
        glGetBufferParameterivARB   = (PFNGLGETBUFFERPARAMETERIVARBPROC)wglGetProcAddress("glGetBufferParameterivARB");
		
		glGenBuffersARB(1, &gVerts);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, gVerts);
		glBufferDataARB(GL_ARRAY_BUFFER_ARB, 
						sizeof(vertices) + sizeof(normals) + sizeof(colors) + sizeof(texcoords), 
						0, 
						GL_STATIC_DRAW_ARB   );
		glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,                0, sizeof(vertices),  vertices);
		glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices),  sizeof(normals),  normals);
		glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices) + sizeof(normals),  sizeof(colors), colors);
		glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices) + sizeof(normals) + sizeof(colors), sizeof(texcoords), texcoords);
		
		glGenBuffersARB(1, &gIndices);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, gIndices);
		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(indices), indices, GL_STATIC_DRAW_ARB);
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_NORMAL_ARRAY);
		glEnableClientState(GL_COLOR_ARRAY);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	};

GLvoid ACTIVATEcubeGL(GLvoid){
		gVerts = 0;
		gIndices = 0;
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, gVerts);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, gIndices);
		glVertexPointer(3, GL_FLOAT, 0, vertices);
		glNormalPointer(GL_FLOAT, 0, normals);
		glColorPointer(4, GL_FLOAT, 0, colors);
		glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
};

GLvoid KILLcubeGL(GLvoid){
		glDisableClientState(GL_COLOR_ARRAY);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisableClientState(GL_NORMAL_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
		glDeleteBuffersARB(1, &gVerts);
		glDeleteBuffersARB(1, &gIndices);
		delete[] vertices;
		delete[] indices;
	};


Create a new paste based on this one


Comments: