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 char*);//Save to .mdl
    glModel &Vertex(float tx, float ty, float x, float y, float z);
    glModel &Draw();
    glModel &Move(float x, float y, float z){glTranslatef(x,y,z);return *this;}
    int len()const{return numv;}
    glVertexStructure &operator[](int x)const{if (x<numv){return vars[x];}else{return NULLV;}}
};



glModel::glModel(const glModel &source)
{
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;
    id=++HIGH_ID;
}
glModel::glModel(const char *filename)
{
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//I hope this works :P
    }
    fclose(file);
    id=++HIGH_ID;
}
glModel &glModel::operator=(const glModel &source)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;//Must I clean up the old model?
    return *this;
}
glModel &glModel::operator=(const char *filename)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//again I hope this works ><
    }
    fclose(file);
    return *this;
}
glModel glModel::operator+(const glVertexStructure& add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel glModel::operator+(const glModel&add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel &glModel::operator+=(const glVertexStructure& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    vars[numv]=add;
    delete[]vars;
    vars=temp;
    numv++;
    return *this;
}
glModel &glModel::operator+=(const glModel& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    for (int i=0; i<add.len(); i++)
        (*this)+=add[i];
    return *this;
}
glModel &glModel::Load(const char *fname)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>1)
        delete[]vars;
    else if (numv>0)
        delete vars;
    FILE *file=fopen(fname,"rb");
    if (file)
    {
        fread(&numv,sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]),sizeof(float), 8, file);
    }
    fclose(file);
    return *this;
}
glModel &glModel::Save(const char *fname)
{
    FILE *file=fopen(fname,"wb");
    fwrite(&numv, sizeof(unsigned int), 1, file);
    fwrite(vars, sizeof(float), numv, file);//Again.... I hope this works!!!
    fclose(file);
    return *this;
}


glModel &glModel::Vertex(float tx, float ty, float x, float y, float z)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv+1];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    delete[]vars;
    vars=temp;
    temp=NULL;
    vars[numv].vert[0]=x;
    vars[numv].vert[1]=y;
    vars[numv].vert[2]=z;
    vars[numv].text[0]=tx;
    vars[numv].text[1]=ty;
    vars[numv].norm[0]=0.0;
    vars[numv].norm[1]=0.0;
    vars[numv].norm[2]=0.0;
    numv++;
    if (numv%3==0)
    {
        float &zz0=vars[numv-3].vert[2];
        float &zz1=vars[numv-2].vert[2];
        float &zz2=vars[numv-1].vert[2];
        float &yy0=vars[numv-3].vert[1];
        float &yy1=vars[numv-2].vert[1];
        float &yy2=vars[numv-1].vert[1];
        float &xx0=vars[numv-3].vert[0];
        float &xx1=vars[numv-2].vert[0];
        float &xx2=vars[numv-1].vert[0];
        float ox=(yy1-yy0)*(zz2-zz0)-(zz1-zz0)*(yy2-yy0);
        float oy=(zz1-zz0)*(xx2-xx0)-(xx1-xx0)*(zz2-zz0);
        float oz=(xx1-xx0)*(yy2-yy0)-(yy1-yy0)*(xx2-xx0);
        float mag=sqrt(ox*ox+oy*oy+oz*oz);
        ox/=mag;
        oy/=mag;
        oz/=mag;
        vars[numv-1].norm[0]=vars[numv-2].norm[0]=vars[numv-3].norm[0]=ox;
        vars[numv-1].norm[1]=vars[numv-2].norm[1]=vars[numv-3].norm[1]=oy;
        vars[numv-1].norm[2]=vars[numv-2].norm[2]=vars[numv-3].norm[2]=oz;
    }
    return *this;
}
glModel &glModel::Compile()
{
    #ifndef GOODGL
    glGenBuffersD(1,&model);//1st sigseg here
    glBindBufferD(GL_ARRAY_BUFFER, model);
    glBufferDataD(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #else
    glGenBuffers(1,&model);
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glBufferData(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #endif
    COMPILED_ID=id;
    return *this;
}
glModel &glModel::Draw()
{
    if (COMPILED_ID!=id){Compile();}//1st sigseg comes from here
    int numt=numv-numv%3;
    if (numt==0)
        return *this;
    #ifndef GOODGL
    glBindBufferD(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #else
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #endif
    return *this;
}
#endif
#endif

This works in tandem with a header that sets up OpenGL. My test case that sigsegs is here:

#include "3dglgui.h"
int main()
{
    GL.Init("TEST",500,500,24,false,0,0);
    glModel model;
    model.Vertex(0,0,0,0,0);
    model.Vertex(1,1,1,1,1);
    model.Vertex(1,0,1,1,0);
    model.Draw();
    do{
    GL.Update();
    }while(!GL.window.key[VK_ESCAPE]);
    return 0;
}

GL.Init refers to this function in my OpenGL set up header:

OpenGLInstance &OpenGLInstance::Init(const char *title, int width, int height, int bpp, bool fullscreen, int posx, int posy)
{
    DEVMODE tmp;
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&tmp);
    window.fps=tmp.dmDisplayFrequency;
    unsigned int PixelFormat;
    DWORD dwExStyle,dwStyle;
    RECT WindowRect={(long)0,(long)0,(long)width,(long)height};
    window.fullscreen=fullscreen;
    hInstance=GetModuleHandle(NULL);
    WNDCLASS wc={CS_HREDRAW|CS_VREDRAW|CS_OWNDC,(WNDPROC)WndProc,0,0,hInstance,LoadIcon(NULL,IDI_WINLOGO),LoadCursor(NULL,IDC_ARROW),NULL,NULL,CLASS_NAME};
    (!RegisterClass(&wc))?ERRORCODE|=ERR_CLASS_REGISTRY_FAILED:ERRORCODE=ERRORCODE;
    if (fullscreen)
    {
        DEVMODE dmScreenSettings;
        memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
        dmScreenSettings.dmSize=sizeof(dmScreenSettings);
        dmScreenSettings.dmPelsWidth=width;
        dmScreenSettings.dmPelsHeight=height;
        dmScreenSettings.dmBitsPerPel=bpp;
        dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSHEIGHT|DM_PELSWIDTH;
        (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)?ERRORCODE|=ERR_FULLSCREEN_FAILED:ERRORCODE=ERRORCODE;
        dwExStyle=WS_EX_APPWINDOW;
        dwStyle=WS_POPUP;
        ShowCursor(false);
    }
    else
    {
        dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        dwStyle=WS_OVERLAPPEDWINDOW;
    }
    AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle);
    if (!(hWnd=CreateWindowEx(dwExStyle,CLASS_NAME,title,WS_CLIPSIBLINGS|WS_CLIPCHILDREN|dwStyle,posx,posy,WindowRect.right-WindowRect.left,WindowRect.bottom-WindowRect.top,NULL,NULL,hInstance,NULL)))
    {
        Kill();
        ERRORCODE|=ERR_WINDOW_CREATION_FAILED;
    }
    static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,bpp,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,PFD_MAIN_PLANE,0,0,0,0};
    if (!(hDC=GetDC(hWnd)))
    {
        Kill();
        ERRORCODE|=ERR_GET_DC_FAILED;
    }
    if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
    {
        Kill();
        ERRORCODE|=ERR_PIXEL_FORMAT_CHOICE_FAILED;
    }
    if (!SetPixelFormat(hDC,PixelFormat,&pfd))
    {
        Kill();
        ERRORCODE|=ERR_NO_VALID_PIXEL_FORMAT;
    }
    if (!wglMakeCurrent(hDC,hRC))
    {
        Kill();
        ERRORCODE|=ERR_MAKE_CURRENT_FAILED;
    }
    ShowWindow(hWnd,SW_SHOW);
    SetForegroundWindow(hWnd);
    SetFocus(hWnd);
    Resize(width,height);
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f,0.0f,0.0f,0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_COLOR_MATERIAL);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    quadricobject=gluNewQuadric();
    gluQuadricNormals(quadricobject,GLU_SMOOTH);
    gluQuadricTexture(quadricobject,GL_TRUE);
    return *this;
}

Recommended Answers

All 47 Replies

I may be mistaken at any point here, so try one thing at a time and see what (if anything helps).

First, at lines 9-12, you can declare your global function-pointers here, but I don't think you can call wglGetProcAddress() (or any other function) in the global scope. I think you need to assign the pointers to NULL and then call wglGetProcAddress() maybe in your GL.Init() or even just in main():

#ifndef GOODGL
if (!glGenBuffersD)
    glGenBuffersD=(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
...
#endif

In your destructor in lines 47-54, if you always allocate vars as vars = new glVertexStructure[numv]; then you should always deallocate it via delete [] vars; whether numv is 1 or greater. delete vars; is intended to be used in conjunction with vars = new glVertexStructure;. It might work as-is, but your code is actually cleaner without worrying about the count. Of course, still don't try to delete if numv is 0 (or equivalently if vars is NULL), and don't forget to check whether numv > 0 before allocating in your copy-constructor, assignment-operator, etc.

In lines 111-127, are you really going to support a statement like model = "filename.ext";? If not, you don't need this assignment operator. If you keep it, initialize the 'model' member as well (you set it to zero in the previous method).

In operator+=() (lines 144-156), you don't make your temp[] array any bigger than vars is, and then you assign the new 'add' piece into the wrong array and don't check vars before deleting, so try:

glVertexStructure *temp = new glVertexStructure[numv+1];  // guaranteed to be >0
for (int i=0; i<numv; i++)
    temp[i] = vars[i];
temp[numv] = add;
if numv > 0:
    delete [] vars;
vars = temp;
numv++;
return *this;

At line 188, I think you need to write out numv glVertexStructure objects (same as you read in), not numv floats.

At lines 198-212 of method Vertex(), could you also just create and populate a local glVertexStructure object called s, and then call *this += s;? Keeps the re-allocation and copying code in one place.... And then, of course still do the normal computation, but you would need to do that in operator+=() also, right (for every third vertex added)? Note: it looks like you got the change in size of the vars/temp array correct here!

Your code in lines 262, 264, 271 and 273 looks really suspect. What is it you're trying to compute for the third parameter? Also in those two blocks of code, it looks like the only difference it the first line of each; if so, just #ifdef/#else/#endif those two lines, and have a single copy of the remaining lines. Unless I missed some detail.

Let's start with that, and if needed I'll look more closely at your Gl.Init() later.

Thank you. I will start implementing these changes now. Ill tell you if they work.

Ok, here is my updated 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();
    PFNGLGENBUFFERSARBPROC glGenBuffersD;
    PFNGLBINDBUFFERARBPROC glBindBufferD;
    PFNGLBUFFERDATAARBPROC glBufferDataD;
    PFNGLDELETEBUFFERSARBPROC glDeleteBuffersD;
    void genfunc()
    {
        #ifndef GOODGL
        PFNGLGENBUFFERSARBPROC glGenBuffersD=(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
        PFNGLBINDBUFFERARBPROC glBindBufferD=(PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
        PFNGLBUFFERDATAARBPROC glBufferDataD=(PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
        PFNGLDELETEBUFFERSARBPROC glDeleteBuffersD=(PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
        #endif
    }
    public:
    glModel():numv(0),model(0),vars(0),id(++HIGH_ID){genfunc();}
    glModel(const glModel&);
    glModel(const char*);//Load from .mdl
    ~glModel()
    {
        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 char*);//Save to .mdl
    glModel &Vertex(float tx, float ty, float x, float y, float z);
    glModel &Draw();
    glModel &Move(float x, float y, float z){glTranslatef(x,y,z);return *this;}
    int len()const{return numv;}
    glVertexStructure &operator[](int x)const{if (x<numv){return vars[x];}else{return NULLV;}}
};



glModel::glModel(const glModel &source)
{
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;
    id=++HIGH_ID;
    genfunc();
}
glModel::glModel(const char *filename)
{
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//I hope this works :P
    }
    fclose(file);
    model=0;
    id=++HIGH_ID;
    genfunc();
}
glModel &glModel::operator=(const glModel &source)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;//Must I clean up the old model?
    return *this;
}
glModel &glModel::operator=(const char *filename)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//again I hope this works ><
    }
    fclose(file);
    return *this;
}
glModel glModel::operator+(const glVertexStructure& add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel glModel::operator+(const glModel&add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel &glModel::operator+=(const glVertexStructure& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv+1];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    vars[numv]=add;
    if (numv>0)
        delete[]vars;
    vars=temp;
    numv++;
    return *this;
}
glModel &glModel::operator+=(const glModel& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    for (int i=0; i<add.len(); i++)
        (*this)+=add[i];
    return *this;
}
glModel &glModel::Load(const char *fname)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>1)
        delete[]vars;
    else if (numv>0)
        delete vars;
    FILE *file=fopen(fname,"rb");
    if (file)
    {
        fread(&numv,sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]),sizeof(float), 8, file);
    }
    fclose(file);
    return *this;
}
glModel &glModel::Save(const char *fname)
{
    FILE *file=fopen(fname,"wb");
    fwrite(&numv, sizeof(unsigned int), 1, file);
    fwrite(vars, sizeof(float), numv*8, file);//Again.... I hope this works!!!
    fclose(file);
    return *this;
}


glModel &glModel::Vertex(float tx, float ty, float x, float y, float z)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv+1];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    delete[]vars;
    vars=temp;
    temp=NULL;
    vars[numv].vert[0]=x;
    vars[numv].vert[1]=y;
    vars[numv].vert[2]=z;
    vars[numv].text[0]=tx;
    vars[numv].text[1]=ty;
    vars[numv].norm[0]=0.0;
    vars[numv].norm[1]=0.0;
    vars[numv].norm[2]=0.0;
    numv++;
    if (numv%3==0)
    {
        float &zz0=vars[numv-3].vert[2];
        float &zz1=vars[numv-2].vert[2];
        float &zz2=vars[numv-1].vert[2];
        float &yy0=vars[numv-3].vert[1];
        float &yy1=vars[numv-2].vert[1];
        float &yy2=vars[numv-1].vert[1];
        float &xx0=vars[numv-3].vert[0];
        float &xx1=vars[numv-2].vert[0];
        float &xx2=vars[numv-1].vert[0];
        float ox=(yy1-yy0)*(zz2-zz0)-(zz1-zz0)*(yy2-yy0);
        float oy=(zz1-zz0)*(xx2-xx0)-(xx1-xx0)*(zz2-zz0);
        float oz=(xx1-xx0)*(yy2-yy0)-(yy1-yy0)*(xx2-xx0);
        float mag=sqrt(ox*ox+oy*oy+oz*oz);
        ox/=mag;
        oy/=mag;
        oz/=mag;
        vars[numv-1].norm[0]=vars[numv-2].norm[0]=vars[numv-3].norm[0]=ox;
        vars[numv-1].norm[1]=vars[numv-2].norm[1]=vars[numv-3].norm[1]=oy;
        vars[numv-1].norm[2]=vars[numv-2].norm[2]=vars[numv-3].norm[2]=oz;
    }
    return *this;
}
glModel &glModel::Compile()
{
    #ifndef GOODGL
    glGenBuffersD(1,&model);//1st sigseg here
    glBindBufferD(GL_ARRAY_BUFFER, model);
    glBufferDataD(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #else
    glGenBuffers(1,&model);
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glBufferData(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #endif
    COMPILED_ID=id;
    return *this;
}
glModel &glModel::Draw()
{
    if (COMPILED_ID!=id){Compile();}//1st sigseg comes from here
    int numt=numv-numv%3;
    if (numt==0)
        return *this;
    #ifndef GOODGL
    glBindBufferD(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #else
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #endif
    return *this;
}
#endif
#endif

Here is GL.Init():

OpenGLInstance &OpenGLInstance::Init(const char *title, int width, int height, int bpp, bool fullscreen, int posx, int posy)
{
    DEVMODE tmp;
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&tmp);
    window.fps=tmp.dmDisplayFrequency;
    unsigned int PixelFormat;
    DWORD dwExStyle,dwStyle;
    RECT WindowRect={(long)0,(long)0,(long)width,(long)height};
    window.fullscreen=fullscreen;
    hInstance=GetModuleHandle(NULL);
    WNDCLASS wc={CS_HREDRAW|CS_VREDRAW|CS_OWNDC,(WNDPROC)WndProc,0,0,hInstance,LoadIcon(NULL,IDI_WINLOGO),LoadCursor(NULL,IDC_ARROW),NULL,NULL,CLASS_NAME};
    (!RegisterClass(&wc))?ERRORCODE|=ERR_CLASS_REGISTRY_FAILED:ERRORCODE=ERRORCODE;
    if (fullscreen)
    {
        DEVMODE dmScreenSettings;
        memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
        dmScreenSettings.dmSize=sizeof(dmScreenSettings);
        dmScreenSettings.dmPelsWidth=width;
        dmScreenSettings.dmPelsHeight=height;
        dmScreenSettings.dmBitsPerPel=bpp;
        dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSHEIGHT|DM_PELSWIDTH;
        (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)?ERRORCODE|=ERR_FULLSCREEN_FAILED:ERRORCODE=ERRORCODE;
        dwExStyle=WS_EX_APPWINDOW;
        dwStyle=WS_POPUP;
        ShowCursor(false);
    }
    else
    {
        dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        dwStyle=WS_OVERLAPPEDWINDOW;
    }
    AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle);
    if (!(hWnd=CreateWindowEx(dwExStyle,CLASS_NAME,title,WS_CLIPSIBLINGS|WS_CLIPCHILDREN|dwStyle,posx,posy,WindowRect.right-WindowRect.left,WindowRect.bottom-WindowRect.top,NULL,NULL,hInstance,NULL)))
    {
        Kill();
        ERRORCODE|=ERR_WINDOW_CREATION_FAILED;
    }
    static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,bpp,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,PFD_MAIN_PLANE,0,0,0,0};
    if (!(hDC=GetDC(hWnd)))
    {
        Kill();
        ERRORCODE|=ERR_GET_DC_FAILED;
    }
    if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
    {
        Kill();
        ERRORCODE|=ERR_PIXEL_FORMAT_CHOICE_FAILED;
    }
    if (!SetPixelFormat(hDC,PixelFormat,&pfd))
    {
        Kill();
        ERRORCODE|=ERR_NO_VALID_PIXEL_FORMAT;
    }
    if (!wglMakeCurrent(hDC,hRC))
    {
        Kill();
        ERRORCODE|=ERR_MAKE_CURRENT_FAILED;
    }
    ShowWindow(hWnd,SW_SHOW);
    SetForegroundWindow(hWnd);
    SetFocus(hWnd);
    Resize(width,height);
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f,0.0f,0.0f,0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_COLOR_MATERIAL);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    quadricobject=gluNewQuadric();
    gluQuadricNormals(quadricobject,GLU_SMOOTH);
    gluQuadricTexture(quadricobject,GL_TRUE);
    return *this;
}

Oh, sorry I didnt tell you, that code still sigsegs in the Compile() function.

Now that you're using instance members for your GL function pointers, remove lines 9-12.

In genfuncs() (lines 49-52), you're declaring local variables that mask your class members, so that when you get to Compile(), the function-ptr members are still uninitialized. Omit the leading type-names, e.g.:

glGenBuffersD = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");

You should probably also check, at the top of Draw(), that your model actually contains something (numv > 0). I'm not sure what the functions in Compile() will do if you pass 0 vertices and a NULL ptr.

Hopefully this will get you past the immediate problem with Compile()!

YAY!!! We moved up one line!!! Still not working though. Here is the updated 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);
#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();
    PFNGLGENBUFFERSARBPROC glGenBuffersD;
    PFNGLBINDBUFFERARBPROC glBindBufferD;
    PFNGLBUFFERDATAARBPROC glBufferDataD;
    PFNGLDELETEBUFFERSARBPROC glDeleteBuffersD;
    void genfunc()
    {
        #ifndef GOODGL
        PFNGLGENBUFFERSARBPROC glGenBuffersD=(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
        PFNGLBINDBUFFERARBPROC glBindBufferD=(PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
        PFNGLBUFFERDATAARBPROC glBufferDataD=(PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
        PFNGLDELETEBUFFERSARBPROC glDeleteBuffersD=(PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
        #endif
    }
    public:
    glModel():numv(0),model(0),vars(0),id(++HIGH_ID){genfunc();}
    glModel(const glModel&);
    glModel(const char*);//Load from .mdl
    ~glModel()
    {
        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 char*);//Save to .mdl
    glModel &Vertex(float tx, float ty, float x, float y, float z);
    glModel &Draw();
    glModel &Move(float x, float y, float z){glTranslatef(x,y,z);return *this;}
    int len()const{return numv;}
    glVertexStructure &operator[](int x)const{if (x<numv){return vars[x];}else{return NULLV;}}
};



glModel::glModel(const glModel &source)
{
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;
    id=++HIGH_ID;
    genfunc();
}
glModel::glModel(const char *filename)
{
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//I hope this works :P
    }
    fclose(file);
    model=0;
    id=++HIGH_ID;
    genfunc();
}
glModel &glModel::operator=(const glModel &source)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    numv=source.len();
    vars=new glVertexStructure[numv];
    for (int i=0; i<numv; i++)
    {
        vars[i]=source[i];
    }
    model=0;//Must I clean up the old model?
    return *this;
}
glModel &glModel::operator=(const char *filename)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>0)
        delete[]vars;
    FILE *file=fopen(filename,"rb");
    if (file)
    {
        fread(&numv, sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]), sizeof(float), 8, file);//again I hope this works ><
    }
    fclose(file);
    return *this;
}
glModel glModel::operator+(const glVertexStructure& add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel glModel::operator+(const glModel&add)const
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glModel ret=*this;
    ret+=add;
    return ret;
}
glModel &glModel::operator+=(const glVertexStructure& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv+1];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    vars[numv]=add;
    if (numv>0)
        delete[]vars;
    vars=temp;
    numv++;
    return *this;
}
glModel &glModel::operator+=(const glModel& add)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    for (int i=0; i<add.len(); i++)
        (*this)+=add[i];
    return *this;
}
glModel &glModel::Load(const char *fname)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    if (numv>1)
        delete[]vars;
    else if (numv>0)
        delete vars;
    FILE *file=fopen(fname,"rb");
    if (file)
    {
        fread(&numv,sizeof(numv), 1, file);
        vars=new glVertexStructure[numv];
        for (unsigned int i=0; i<numv; i++)
            fread(&(vars[i].vert[0]),sizeof(float), 8, file);
    }
    fclose(file);
    return *this;
}
glModel &glModel::Save(const char *fname)
{
    FILE *file=fopen(fname,"wb");
    fwrite(&numv, sizeof(unsigned int), 1, file);
    fwrite(vars, sizeof(float), numv*8, file);//Again.... I hope this works!!!
    fclose(file);
    return *this;
}


glModel &glModel::Vertex(float tx, float ty, float x, float y, float z)
{
    if (COMPILED_ID==id)
        COMPILED_ID=0;
    glVertexStructure *temp=new glVertexStructure[numv+1];
    for (int i=0; i<numv; i++)
        temp[i]=vars[i];
    delete[]vars;
    vars=temp;
    temp=NULL;
    vars[numv].vert[0]=x;
    vars[numv].vert[1]=y;
    vars[numv].vert[2]=z;
    vars[numv].text[0]=tx;
    vars[numv].text[1]=ty;
    vars[numv].norm[0]=0.0;
    vars[numv].norm[1]=0.0;
    vars[numv].norm[2]=0.0;
    numv++;
    if (numv%3==0)
    {
        float &zz0=vars[numv-3].vert[2];
        float &zz1=vars[numv-2].vert[2];
        float &zz2=vars[numv-1].vert[2];
        float &yy0=vars[numv-3].vert[1];
        float &yy1=vars[numv-2].vert[1];
        float &yy2=vars[numv-1].vert[1];
        float &xx0=vars[numv-3].vert[0];
        float &xx1=vars[numv-2].vert[0];
        float &xx2=vars[numv-1].vert[0];
        float ox=(yy1-yy0)*(zz2-zz0)-(zz1-zz0)*(yy2-yy0);
        float oy=(zz1-zz0)*(xx2-xx0)-(xx1-xx0)*(zz2-zz0);
        float oz=(xx1-xx0)*(yy2-yy0)-(yy1-yy0)*(xx2-xx0);
        float mag=sqrt(ox*ox+oy*oy+oz*oz);
        ox/=mag;
        oy/=mag;
        oz/=mag;
        vars[numv-1].norm[0]=vars[numv-2].norm[0]=vars[numv-3].norm[0]=ox;
        vars[numv-1].norm[1]=vars[numv-2].norm[1]=vars[numv-3].norm[1]=oy;
        vars[numv-1].norm[2]=vars[numv-2].norm[2]=vars[numv-3].norm[2]=oz;
    }
    return *this;
}
glModel &glModel::Compile()
{
    if (numv<3)
        return *this;
    #ifndef GOODGL
    glGenBuffersD(1,&model);
    glBindBufferD(GL_ARRAY_BUFFER, model);//now sigseg here ><
    glBufferDataD(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #else
    glGenBuffers(1,&model);
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glBufferData(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    #endif
    COMPILED_ID=id;
    return *this;
}
glModel &glModel::Draw()
{
    if (COMPILED_ID!=id){Compile();}//1st sigseg comes from here
    int numt=numv-numv%3;
    if (numt==0)
        return *this;
    #ifndef GOODGL
    glBindBufferD(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #else
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(glVertexStructure),0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].norm[0])-&(vars[0].vert[0]))));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #endif
    return *this;
}
#endif
#endif

Are you also going to remove the leading declarations in genfunc(), now in lines 45-48?

I removed the leading declarations from genfunc() but it didnt help the sigseg. In fact it seems to have a negative impact, moving the sigseg back a line.

Hmmm... I suspect the memory you're corrupting isn't where you think it is. Can you post your main() that you're testing this against also?

Here is my main:

int main()
{
GL.Init("TEST",500,500,24,false,0,0);
    glModel model;
    model.Vertex(0,0,0,0,0);
    model.Vertex(1,1,1,1,1);
    model.Vertex(1,0,1,1,0);
    model.Draw();
    do{
    GL.Update();
    }while(!GL.window.key[VK_ESCAPE]);
return 0;
}

And here is gl.Init():

OpenGLInstance &OpenGLInstance::Init(const char *title, int width, int height, int bpp, bool fullscreen, int posx, int posy)
{
    DEVMODE tmp;
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&tmp);
    window.fps=tmp.dmDisplayFrequency;
    unsigned int PixelFormat;
    DWORD dwExStyle,dwStyle;
    RECT WindowRect={(long)0,(long)0,(long)width,(long)height};
    window.fullscreen=fullscreen;
    hInstance=GetModuleHandle(NULL);
    WNDCLASS wc={CS_HREDRAW|CS_VREDRAW|CS_OWNDC,(WNDPROC)WndProc,0,0,hInstance,LoadIcon(NULL,IDI_WINLOGO),LoadCursor(NULL,IDC_ARROW),NULL,NULL,CLASS_NAME};
    (!RegisterClass(&wc))?ERRORCODE|=ERR_CLASS_REGISTRY_FAILED:ERRORCODE=ERRORCODE;
    if (fullscreen)
    {
        DEVMODE dmScreenSettings;
        memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
        dmScreenSettings.dmSize=sizeof(dmScreenSettings);
        dmScreenSettings.dmPelsWidth=width;
        dmScreenSettings.dmPelsHeight=height;
        dmScreenSettings.dmBitsPerPel=bpp;
        dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSHEIGHT|DM_PELSWIDTH;
        (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)?ERRORCODE|=ERR_FULLSCREEN_FAILED:ERRORCODE=ERRORCODE;
        dwExStyle=WS_EX_APPWINDOW;
        dwStyle=WS_POPUP;
        ShowCursor(false);
    }
    else
    {
        dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        dwStyle=WS_OVERLAPPEDWINDOW;
    }
    AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle);
    if (!(hWnd=CreateWindowEx(dwExStyle,CLASS_NAME,title,WS_CLIPSIBLINGS|WS_CLIPCHILDREN|dwStyle,posx,posy,WindowRect.right-WindowRect.left,WindowRect.bottom-WindowRect.top,NULL,NULL,hInstance,NULL)))
    {
        Kill();
        ERRORCODE|=ERR_WINDOW_CREATION_FAILED;
    }
    static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,bpp,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,PFD_MAIN_PLANE,0,0,0,0};
    if (!(hDC=GetDC(hWnd)))
    {
        Kill();
        ERRORCODE|=ERR_GET_DC_FAILED;
    }
    if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
    {
        Kill();
        ERRORCODE|=ERR_PIXEL_FORMAT_CHOICE_FAILED;
    }
    if (!SetPixelFormat(hDC,PixelFormat,&pfd))
    {
        Kill();
        ERRORCODE|=ERR_NO_VALID_PIXEL_FORMAT;
    }
    if (!wglMakeCurrent(hDC,hRC))
    {
        Kill();
        ERRORCODE|=ERR_MAKE_CURRENT_FAILED;
    }
    ShowWindow(hWnd,SW_SHOW);
    SetForegroundWindow(hWnd);
    SetFocus(hWnd);
    Resize(width,height);
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f,0.0f,0.0f,0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_COLOR_MATERIAL);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    quadricobject=gluNewQuadric();
    gluQuadricNormals(quadricobject,GLU_SMOOTH);
    gluQuadricTexture(quadricobject,GL_TRUE);
    return *this;
}

I'm not seeing anything obvious at this point. One question is, at line 38 of GL.Init() above, you initialize pfd to include ... PFD_TYPE_RGBA, bpp, ... , but you're passing 24 in for bpp. Did you mean either to pass in 32, or to specify PFD_TYPE_RGB? Or will ChoosePixelFormat() do the right thing for you?

Other than that, to ensure that GL.Init() is actually working (at least a little), try commenting out the model.Draw(); line, and you should get a running app with a blank black screen. If that works, I'm worried that your looked-up function addresses are still wacky. Try printing out those pointer addresses and see if they make some sense:

printf("glGenBuffersD ptr = %p\n", glGenBuffersD);

Or if your compiler doesn't support %p (and you're building a 32-bit application), try:

printf("glGenBuffersD ptr = 0x%08x\n", (unsigned long)glGenBuffersD);

Other thoughts:
Why are you creating a default quadricobject in GL.Init()?
Should you be enabling GL_TEXTURE_2D if you're not creating and applying a texture-map?

You were right, all of the functions were NULL... unfortunately when I use #define GOODGL then I get the following compiler errors:

D:\Programming\C++\glHeaders\models.h||In constructor 'glModel::glModel()':|
D:\Programming\C++\glHeaders\models.h|36|warning: 'glModel::vars' will be initialized after|
D:\Programming\C++\glHeaders\models.h|33|warning:   'int glModel::id'|
D:\Programming\C++\glHeaders\models.h|54|warning:   when initialized here|
D:\Programming\C++\glHeaders\models.h||In member function 'glVertexStructure& glModel::operator[](int) const':|
D:\Programming\C++\glHeaders\models.h|76|warning: comparison between signed and unsigned integer expressions|
D:\Programming\C++\glHeaders\models.h|85|warning: comparison between signed and unsigned integer expressions|
D:\Programming\C++\glHeaders\models.h||In member function 'glModel& glModel::operator=(const glModel&)':|
D:\Programming\C++\glHeaders\models.h|116|warning: comparison between signed and unsigned integer expressions|
D:\Programming\C++\glHeaders\models.h||In member function 'glModel& glModel::operator+=(const glVertexStructure&)':|
D:\Programming\C++\glHeaders\models.h|161|warning: comparison between signed and unsigned integer expressions|
D:\Programming\C++\glHeaders\models.h||In member function 'glModel& glModel::Vertex(float, float, float, float, float)':|
D:\Programming\C++\glHeaders\models.h|212|warning: comparison between signed and unsigned integer expressions|
obj\Debug\test.o:D:\Programming\C++\glHeaders\models.h|259|undefined reference to `glGenBuffers@8'|
obj\Debug\test.o:D:\Programming\C++\glHeaders\models.h|260|undefined reference to `glBindBuffer@8'|
obj\Debug\test.o:D:\Programming\C++\glHeaders\models.h|261|undefined reference to `glBufferData@16'|
obj\Debug\test.o:D:\Programming\C++\glHeaders\models.h|282|undefined reference to `glBindBuffer@8'|
||=== Build finished: 4 errors, 8 warnings ===|

Maybe I need to install a newer version of OpenGL???

Also when I comment out model.Draw() I get just a clear screen (not black)

For the errors (lines 14-17 of your output above), try wrapping line 10 of your code, replacing:

#include <gl/glext.h>

with

extern "C" {
    #include <gl/glext.h>
}

We can deal with the warnings later, but I think the first one might relate to your constructor-from-filename: vars and numv don't get initialized at all if you fail to open the file. For the signed vs. unsigned cases, when you're looping over the vars, since numv is declared to be unsigned, declare i to match.

As far as your clear (not black) screen ... try setting your glClearColor to opaque:

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

Also, since I don't know what GL.Update() does, perhaps your do{} loop needs to do something like:

do {
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  model.Draw();
  GL.Update();
} while (!GL.window.key[VK_ESCAPE]);

and if you have double-buffering enabled (you requested it in your pfd variable, but I don't think you ever check on return whether you actually got it), you probably need a glSwapBuffers(); call somewhere as well.

Still getting the Errors with GOODGL enabled, and a clear screen without it. I have decided to put my entire 3dglgui.h in here so...

#ifndef LAB2DGLGUI_H
#ifndef CLASS_NAME
#define CLASS_NAME "OpenGL Windows Class"//This can be overwritten to specify a unique class name
#endif
//Header Guards and version number
#ifndef LAB3DGLGUI_H
#define LAB3DGLGUI_H 1.0

//Error codes
#define ERR_NO_ERROR                        0x0000
#define ERR_CLASS_REGISTRY_FAILED           0x0001
#define ERR_FULLSCREEN_FAILED               0x0002
#define ERR_WINDOW_CREATION_FAILED          0x0004
#define ERR_GET_DC_FAILED                   0x0008
#define ERR_PIXEL_FORMAT_CHOICE_FAILED      0x0010
#define ERR_NO_VALID_PIXEL_FORMAT           0x0020
#define ERR_GET_RC_FAILED                   0x0040
#define ERR_MAKE_CURRENT_FAILED             0x0080
#define ERR_OPENGL_INITIALIZATION_FAILED    0x0100
#define ERR_RELEASE_DC_RC_FAILED            0x0200
#define ERR_RELEASE_RC_FAILED               0x0400
#define ERR_RELEASE_DC_FAILED               0x0800
#define ERR_RELEASE_WINDOW_FAILED           0x1000
#define ERR_RELEASE_WINDOW_CLASS_FAILED     0x2000

#define APART(X) ((float)((char)((X)>>24))/255.0)
#define RPART(X) ((float)((char)((X)>>16))/255.0)
#define GPART(X) ((float)((char)((X)>>8))/255.0)
#define BPART(X) ((float)((char)((X)))/255.0)

#define DEGTORAD(X) ((X)*0.0174532925)
//Includes
#include <math.h>//for trig ratios and sqrt
#include <windows.h>//for windows
#include <gl/gl.h>
#include <gl/glu.h>
#define GL_GLEXT_PROTOTYPES
#include <gl/glext2.h>
#include "models.h"
#include "random.h"
RND Rand;
//typedefs
typedef GLuint glTexture;//Storage for one (or more) textures
typedef unsigned int glColour;//Stores a colour as 0xAARRGGBB
//Unique main function
#define main() WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevhInstance, LPSTR cmdline, int cmdshow)
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
class glFont
{
    private:
    unsigned int letters;
    GLYPHMETRICSFLOAT chars[256];
    public:
    void Load(const char *fname, int height, int weight, bool italic, bool underline, bool strikethrough, float depth);
    void operator()(const char *str);
    ~glFont(){glDeleteLists(letters,255);}
};
class OpenGLInstance
{
    private:
    GLUquadricObj *quadricobject;
    HDC hDC;
    HGLRC hRC;
    HWND hWnd;
    HINSTANCE hInstance;
    LONGLONG tm;
    public:
    short ERRORCODE;
    struct windowdatastructure
    {
        bool key[256]; bool active; bool fullscreen; int w; int h; int fps;
    }window;
    struct mousedatastructure
    {
        int x; int y; int scroll; bool l; bool r; bool m;
    }mouse;
    struct positiondatastructure
    {
        float x; float y; float z; float h; float v; float t;
    }pos;
    OpenGLInstance &Perpective(double angle, double near, double far);
    OpenGLInstance &Resize(int height, int width);
    OpenGLInstance &Init(const char *title, int width, int height, bool fullscreen, int posx, int posy);
    OpenGLInstance &Kill();
    OpenGLInstance &LoadTexture(const char *fname, glTexture *tex, bool linear);
    OpenGLInstance &SetTexture(glTexture tex);
    OpenGLInstance &LightPosition(unsigned int light, float x, float y, float z);
    OpenGLInstance &AmbientLight(unsigned int light, glColour col);
    OpenGLInstance &DiffuseLight(unsigned int light, glColour col);
    OpenGLInstance &SpecularLight(unsigned int light, glColour col);
    OpenGLInstance &Move(float rl, float fb, float z);
    OpenGLInstance &Rotate(float rl, float ud, float cc);
    OpenGLInstance &Mouse(int x, int y);
    OpenGLInstance &Fog(unsigned char quality, glColour col, float density, float start, float end);
    OpenGLInstance &Draw(glModel &model);
    OpenGLInstance &Draw(const char *text, glFont font);
    OpenGLInstance &Update();
    OpenGLInstance &DrawCylinder(double baseradius, double topradius, double height, int quality);
    OpenGLInstance &DrawDisk(double innerradius, double outerradius, int quality);
    OpenGLInstance &DrawDisk(double innerradius, double outerradius, double startangle, double deltaangle, int quality);
    OpenGLInstance &DrawSphere(double radius, int quality);
    bool operator()(unsigned char ch){return window.key[ch];}
    HDC &GetHDC(){return hDC;}
}GL;
void glFont::operator()(const char *str)
{
    for (int i=0; str[i]!=0; i++)
        glCallList(letters+str[i]);
}
void glFont::Load(const char *fname, int height, int weight, bool italic, bool underline, bool strikethrough, float depth)
{
    HFONT fnt,ofnt;
    letters=glGenLists(256);
    fnt=CreateFont(-height,0,0,0,weight,italic,underline,strikethrough,ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE|DEFAULT_PITCH,fname);
    ofnt=(HFONT)SelectObject(GL.GetHDC(),fnt);
    wglUseFontOutlines(GL.GetHDC(),0,255,letters,0.0f,depth,WGL_FONT_POLYGONS,chars);
}
/*IMPLEMENTATIONS*/
LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
    switch (msg)
    {
        case WM_ACTIVATE:
        GL.window.active=!HIWORD(wparam);
        return 0;
        case WM_CLOSE:
        PostQuitMessage(0);
        return 0;
        case WM_KEYDOWN:
        GL.window.key[wparam]=true;
        return 0;
        case WM_KEYUP:
        GL.window.key[wparam]=false;
        return 0;
        case WM_SIZE:
        GL.Resize(LOWORD(lparam),HIWORD(lparam));
        return 0;
        case WM_MOUSEMOVE:
        POINT pnt;
        GetCursorPos(&pnt);
        GL.mouse.x=pnt.x;
        GL.mouse.y=pnt.y;
        return 0;
        case WM_MOUSEWHEEL:
        GL.mouse.scroll=GET_WHEEL_DELTA_WPARAM(wparam);
        return 0;
        case WM_RBUTTONDOWN:
        GL.mouse.r=true;
        return 0;
        case WM_RBUTTONUP:
        GL.mouse.r=false;
        return 0;
        case WM_LBUTTONDOWN:
        GL.mouse.l=true;
        return 0;
        case WM_LBUTTONUP:
        GL.mouse.l=false;
        return 0;
        case WM_MBUTTONDOWN:
        GL.mouse.m=true;
        return 0;
        case WM_MBUTTONUP:
        GL.mouse.m=false;
        return 0;
        default:
        return DefWindowProc(hwnd,msg,wparam,lparam);
    }
}
OpenGLInstance &OpenGLInstance::Perpective(double angle, double vnear, double vfar)
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(angle,
                    ((double)((*this).window.w)/(double)((*this).window.h)),vnear,vfar);
    glMatrixMode(GL_MODELVIEW);
    return *this;
}
OpenGLInstance &OpenGLInstance::Resize(int height, int width)
{
    (height==0)?height=1:height=height;
    glViewport(0,0,width,height);
    window.w=width;
    window.h=height;
    return *this;
}
OpenGLInstance &OpenGLInstance::Init(const char *title, int width, int height, bool fullscreen, int posx, int posy)
{
    DEVMODE tmp;
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&tmp);
    window.fps=tmp.dmDisplayFrequency;
    unsigned int PixelFormat;
    DWORD dwExStyle,dwStyle;
    RECT WindowRect={(long)0,(long)0,(long)width,(long)height};
    window.fullscreen=fullscreen;
    hInstance=GetModuleHandle(NULL);
    WNDCLASS wc={CS_HREDRAW|CS_VREDRAW|CS_OWNDC,(WNDPROC)WndProc,0,0,hInstance,LoadIcon(NULL,IDI_WINLOGO),LoadCursor(NULL,IDC_ARROW),NULL,NULL,CLASS_NAME};
    (!RegisterClass(&wc))?ERRORCODE|=ERR_CLASS_REGISTRY_FAILED:ERRORCODE=ERRORCODE;
    if (fullscreen)
    {
        DEVMODE dmScreenSettings;
        memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
        dmScreenSettings.dmSize=sizeof(dmScreenSettings);
        dmScreenSettings.dmPelsWidth=width;
        dmScreenSettings.dmPelsHeight=height;
        dmScreenSettings.dmBitsPerPel=32;
        dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSHEIGHT|DM_PELSWIDTH;
        (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)?ERRORCODE|=ERR_FULLSCREEN_FAILED:ERRORCODE=ERRORCODE;
        dwExStyle=WS_EX_APPWINDOW;
        dwStyle=WS_POPUP;
        ShowCursor(false);
    }
    else
    {
        dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        dwStyle=WS_OVERLAPPEDWINDOW;
    }
    AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle);
    if (!(hWnd=CreateWindowEx(dwExStyle,CLASS_NAME,title,WS_CLIPSIBLINGS|WS_CLIPCHILDREN|dwStyle,posx,posy,WindowRect.right-WindowRect.left,WindowRect.bottom-WindowRect.top,NULL,NULL,hInstance,NULL)))
    {
        Kill();
        ERRORCODE|=ERR_WINDOW_CREATION_FAILED;
    }
    static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,32,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,PFD_MAIN_PLANE,0,0,0,0};
    if (!(hDC=GetDC(hWnd)))
    {
        Kill();
        ERRORCODE|=ERR_GET_DC_FAILED;
    }
    if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
    {
        Kill();
        ERRORCODE|=ERR_PIXEL_FORMAT_CHOICE_FAILED;
    }
    if (!SetPixelFormat(hDC,PixelFormat,&pfd))
    {
        Kill();
        ERRORCODE|=ERR_NO_VALID_PIXEL_FORMAT;
    }
    if (!wglMakeCurrent(hDC,hRC))
    {
        Kill();
        ERRORCODE|=ERR_MAKE_CURRENT_FAILED;
    }
    ShowWindow(hWnd,SW_SHOW);
    SetForegroundWindow(hWnd);
    SetFocus(hWnd);
    Resize(width,height);
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f,0.0f,0.0f,1.0f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_COLOR_MATERIAL);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    quadricobject=gluNewQuadric();
    gluQuadricNormals(quadricobject,GLU_SMOOTH);
    gluQuadricTexture(quadricobject,GL_TRUE);
    return *this;
}
OpenGLInstance &OpenGLInstance::Kill()
{
    if (window.fullscreen)
    {
        ChangeDisplaySettings(NULL,0);
        ShowCursor(TRUE);
    }
    if (hRC)
    {
        (!wglMakeCurrent(NULL,NULL))?ERRORCODE|=ERR_RELEASE_DC_RC_FAILED:ERRORCODE=ERRORCODE;
        (!wglDeleteContext(hRC))?ERRORCODE|=ERR_RELEASE_RC_FAILED:ERRORCODE=ERRORCODE;
        hRC=NULL;
    }
    if (hDC&&!ReleaseDC(hWnd,hDC))
    {
        ERRORCODE|=ERR_RELEASE_DC_FAILED;
        hDC=NULL;
    }
    if (hWnd&&!DestroyWindow(hWnd))
    {
        ERRORCODE|=ERR_RELEASE_WINDOW_FAILED;
        hWnd=NULL;
    }
    if (!UnregisterClass(CLASS_NAME,hInstance))
    {
        ERRORCODE|=ERR_RELEASE_WINDOW_CLASS_FAILED;
        hInstance=NULL;
    }
    return *this;
}

OpenGLInstance &OpenGLInstance::LoadTexture(const char *fname, glTexture *tex, bool linear)
{
    if (!tex)
        return *this;
    glTexture &out=*tex;
    HBITMAP hBMP;BITMAP BMP;
    glTexture texid;
    glGenTextures(1, &texid);
    hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),fname,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
    if (!hBMP)
        return *this;
    GetObject(hBMP, sizeof(BMP), &BMP);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    glBindTexture(GL_TEXTURE_2D, texid);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear?GL_LINEAR:GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear?GL_LINEAR:GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
    DeleteObject(hBMP);
    out=texid;
    return *this;
}
OpenGLInstance &OpenGLInstance::SetTexture(glTexture tex)
{
    glBindTexture(GL_TEXTURE_2D,tex);
    return *this;
}
OpenGLInstance &OpenGLInstance::LightPosition(unsigned int light, float x, float y, float z)
{
    glLightfv(light, GL_POSITION, (float[4]){x,y,z,1.0f});
    return *this;
}
OpenGLInstance &OpenGLInstance::AmbientLight(unsigned int light, glColour col)
{
    glLightfv(light,GL_AMBIENT,(float[4]){RPART(col),GPART(col),BPART(col),APART(col)});
    return *this;
}
OpenGLInstance &OpenGLInstance::DiffuseLight(unsigned int light, glColour col)
{
    glLightfv(light,GL_DIFFUSE,(float[4]){RPART(col),GPART(col),BPART(col),APART(col)});
    return *this;
}
OpenGLInstance &OpenGLInstance::SpecularLight(unsigned int light, glColour col)
{
    glLightfv(light,GL_SPECULAR,(float[4]){RPART(col),GPART(col),BPART(col),APART(col)});
    return *this;
}
OpenGLInstance &OpenGLInstance::Move(float rl, float fb, float z)
{
    if (rl>0)
    {
        pos.x-=(float)sin(DEGTORAD(pos.h-90.0f))*rl;
        pos.y-=(float)cos(DEGTORAD(pos.h-90.0f))*rl;
    }
    else
    {
        pos.x+=(float)sin(DEGTORAD(pos.h+90.0f))*rl;
        pos.y+=(float)cos(DEGTORAD(pos.h+90.0f))*rl;
    }
    pos.x-=(float)sin(DEGTORAD(pos.h))*fb;
    pos.y-=(float)cos(DEGTORAD(pos.h))*fb;
    pos.z+=z;
    return *this;
}
OpenGLInstance &OpenGLInstance::Rotate(float rl, float ud, float cc)
{
    pos.h+=rl;
    pos.v+=ud;
    pos.t+=cc;
    return *this;
}
OpenGLInstance &OpenGLInstance::Mouse(int x, int y)
{
    RECT windim;
    GetWindowRect(hWnd,&windim);
    SetCursorPos(x+windim.left,y+windim.top);
    return *this;
}
OpenGLInstance &OpenGLInstance::Fog(unsigned char quality, glColour col, float density, float start, float end)
{
    unsigned int mode,hint;
    switch (quality)
    {
        case 0:
            mode=GL_EXP;
            hint=GL_FASTEST;
            break;
        case 1:
            mode=GL_EXP;
            hint=GL_DONT_CARE;
            break;
        case 2:
            mode=GL_EXP;
            hint=GL_NICEST;
            break;
        case 3:
            mode=GL_EXP2;
            hint=GL_FASTEST;
            break;
        case 4:
            mode=GL_EXP2;
            hint=GL_DONT_CARE;
            break;
        case 5:
            mode=GL_EXP2;
            hint=GL_NICEST;
            break;
        case 6:
            mode=GL_LINEAR;
            hint=GL_FASTEST;
            break;
        case 7:
            mode=GL_LINEAR;
            hint=GL_DONT_CARE;
            break;
        case 8:
        default:
            mode=GL_LINEAR;
            hint=GL_NICEST;
    }
    glFogi(GL_FOG_MODE,mode);
    float colour[]={RPART(col),GPART(col),BPART(col),APART(col)};
    glFogfv(GL_FOG_COLOR,colour);
    glFogf(GL_FOG_DENSITY,density);
    glHint(GL_FOG_HINT,hint);
    glFogf(GL_FOG_START,start);
    glFogf(GL_FOG_END,end);
    return *this;
}
OpenGLInstance &OpenGLInstance::Draw(glModel &model)
{
    model.Draw();
    return *this;
}
OpenGLInstance &OpenGLInstance::Draw(const char *text, glFont font)
{
    font(text);
    return *this;
}
OpenGLInstance &OpenGLInstance::Update()
{
    SwapBuffers(hDC);
    MSG temp;
    PeekMessage(&temp,NULL,0,0,PM_REMOVE);
    TranslateMessage(&temp);
    DispatchMessage(&temp);
    //wait off to force the fps
    LARGE_INTEGER tmp;
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);
    QueryPerformanceCounter(&tmp);
    int dtime=tmp.QuadPart-tm;
    double deltatime=((double)dtime/(double)freq.QuadPart)*(double)1000.0;
    Sleep(((double)window.fps/(double)1000.0)-deltatime);
    return *this;
}
OpenGLInstance &OpenGLInstance::DrawCylinder(double baseradius, double topradius, double height, int quality)
{
    gluCylinder(quadricobject, baseradius, topradius, height, quality, quality);
    return *this;
}
OpenGLInstance &OpenGLInstance::DrawDisk(double innerradius, double outerradius, int quality)
{
    gluDisk(quadricobject, innerradius, outerradius, quality, quality);
    return *this;
}
OpenGLInstance &OpenGLInstance::DrawDisk(double innerradius, double outerradius, double startangle, double deltaangle, int quality)
{
    gluPartialDisk(quadricobject, innerradius, outerradius, quality, quality, startangle, deltaangle);
    return *this;
}
OpenGLInstance &OpenGLInstance::DrawSphere(double radius, int quality)
{
    gluSphere(quadricobject, radius, quality, quality);
    return *this;
}
#endif
#endif

Should line 446 above read something more like:

double frametime = 1000.0/(double)window.fps;
if (deltatime < frametime)
    Sleep(frametime-deltatime);

You can ignore what I said previously about glSwapBuffers, GL.Update() clearly does that, but you still need to draw into the other buffer, so your do {} while (); loop needs to clear, draw and Update() each time.

While you haven't gotten that far yet (past Compile()), unless you got your glGenBuffersD (etc.) pointers to be non-null, you're going to run into potential problems in model.Draw() where you call

...
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,sizeof(glVertexStructure),(void*)((char*)(NULL)+sizeof(float)*(&(vars[0].text[0])-&(vars[0].vert[0]))));
    ...

if you haven't already called GL.LoadTexture() and GL.SetTexture().

The safest thing to do is probably pass the texture file into a model.AttachTexture() method which calls GL.LoadTexture(), and have the model maintain its texid. Then you can use whether the texid is non-zero to decide whether to call GL.SetTexture() and provide tex-coords.

Also, I think the offset to the first texture coordinate is probably as simple as:

glTexCoordPointer(2, GL_FLOAT, sizeof(glVertexStructure), &(vars[0].vert[0]));

and similar for the first normal coordinate.

But we still gotta figure out why you can't Compile(). If the pointers are NULL, we have to go back to where you assign them in genfunc(). If they're NULL there, then there's something wrong with how you're looking them up.

Ok I have implemented your suggestions, except the Texture and Normal coordinates as I do not understand why they would be the same as the vertex coordinate. Also I think the problem with the NULL functions is the poor practice of using wglGetProcAddress. The issue is that I seem to be missing the OpenGL glext.h and its library, so I made my own (glext2.h) and since I am missing the library I cannot use the real functions. Is there anywhere that I can download the OpenGL headers and libraries?

I'm looking at section "23.070 How can I call extension routines on Microsoft Windows?" of the OpenGL FAQ. It looks like what you're already doing, but if you're getting undefined symbols with GOODGL defined, then those functions are presumably not in your opengl32.lib, and if you're getting NULL pointers back from wglGetProcAddress(), then they're not defined in your device's ICD either ... which indicates that your graphics hardware doesn't support the glGenBuffers() call -- also from the OpenGL website,

Notes: glGenBuffers is available only if the GL version is 1.5 or greater.

Also see this to find out what version of OpenGL you're running, and the question immediately below it if you suspect you're seeing weird behavior (picking unaccelerated pixel formats).

I tried to use this to get my version, but nothing was printed:

#include <gl/gl.h>
#include <iostream>
using namespace std;
int main()
{
    cout<<glGetString(GL_VERSION);
    return 0;
}

I forgot to mention that I am 90% sure that I am running OpenGL version 2.1 (I have asked my IT department before)

I'm getting a NULL-ptr returned from glGetString() also, and glGetError() returns x502 (INVALID_OPERATION) ... still looking into that.

As far as the texture coordinate thing, my typo sorry. That should have read:

glTexCoordPointer(2, GL_FLOAT, sizeof(glVertexStructure), &(vars[0].text[0]));
...
glNormalPointer(GL_FLOAT, sizeof(glVertexStructure), &(vars[0].norm[0]));

For what it's worth, I'm set up to use the MinGW gcc compiler, and the top of my gl.h file reads:

/*
 * Mesa 3-D graphics library
 * Version:  4.0
 *
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
...

Same here...

Grrr... well, when I get more time, I'll see if I can beat some better behavior out of some version of your code. I'm out of ideas for the moment, and headed away from my computer for a few hours too. More later!

Oh, and it looks like I'm way out-of-date (obviously I don't do any new OpenGL development on this box!) -- Mesa is at 7.10 as of January 2011....

Should I try to see if I can update the version of OpenGL on my machine?

Should I try to see if I can update the version of OpenGL on my machine?

I guess that depends on your machine. If you're on a laptop or other graphics-minimal machine, then I'd say yes, try downloading the latest stable version of Mesa (software OpenGL implementation).

If you're on a desktop-style machine with a half-decent graphics card, then the problem is more likely that you're building against the wrong version of the OpenGL headers and libraries, and have to find the correct ones ... if you need updates or are reasonably sure they didn't get installed when the card was added, go to the manufacturer's website to look for up-to-date drivers and possibly OpenGL implementations too.

I am on a laptop, but I dont know where to get the latest version of mesa, also I dont think my headers and libraries are up to date since they are missing some functions that they should have, so I think I should upgrade them too. But how?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.