I am still having major trouble with my openGL model program. The big issue is that I cannot figure out how to debug it since I am saving the important data to the graphics chip using vertex buffer objects (VBOs) so at least as far as I can tell, I cant read it. Also I am no computer so I cant interpolate the data. Anyways here is my code:
#ifdef LAB3DGLGUI_H
#ifndef GLMODELS_H
#define GLMODELS_H
#ifndef GOODGL
typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage);
PFNGLGENBUFFERSARBPROC glGenBuffersD=(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
PFNGLBINDBUFFERARBPROC glBindBufferD=(PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
PFNGLBUFFERDATAARBPROC glBufferDataD=(PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersD=(PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
#else
#include <gl/glext.h>
#endif
#include <stdio.h>
struct glVertexStructure
{
float vert[3];
float text[2];
float norm[3];
}NULLV;
/* Model File Format (.mdl)
4 bytes (int) -> numv
32*numv bytes (glVertexStructure)-> vars
-> 12 bytes (float[3]) -> vert
-> 8 bytes (float[2]) -> text
-> 12 bytes (float[3]) -> norm
*/
int HIGH_ID=0;
int COMPILED_ID=0;
class glModel
{
private:
int id;
unsigned int numv;
unsigned int model;
glVertexStructure *vars;
glModel &Compile();
public:
glModel():numv(0),model(0),vars(0),id(++HIGH_ID){}
glModel(const glModel&);
glModel(const char*);//Load from .mdl
~glModel()
{
if (numv>1)
delete[]vars;
else if (numv>0)
delete vars;
//Clean up VBOs??? Research needed!
}
glModel &operator=(const glModel&);
glModel &operator=(const char*);//Load from .mdl
glModel operator+(const glVertexStructure&)const;//Add Vertices
glModel operator+(const glModel&)const;
glModel &operator+=(const glVertexStructure&);//Append Vertices
glModel &operator+=(const glModel&);
glModel &Load(const char*);//Load from .mdl
glModel &Save(const …