What do I do with the ftp link?

Nothing. Best bet is to start with the html link to mesa3d.org, and go from there. It will likely get you to the same point anyway, but in a more obvious fashion. (I put the ftp link up first, then went and tracked down the website, which was more user-friendly. Anyway, grab v7.11 I guess, and follow whatever instructions you can find for installing it. Or v7.10.3 if you can do without the absolute latest-and-greatest features and want a version that may be more stable until they get a bug-fix release out for 7.11.)

Ill try that.

Ok, I tried everything to get VBOs to work and failed, so I moved on to making my header backwards compatible using display lists (since they worked for me at one point) the issue is that I am still failing. Here is the added section of code:

#ifdef SUPPRESS_VBOS//no VBOs
glModel &glModel::Compile()//uses display lists
{
    if (numv<3)
        return *this;
    model=glGenLists(1);
    glNewList(model,GL_COMPILE);
    glBegin(GL_TRIANGLES);
    for (int i=0; i<numv; i++)
    {
        glTexCoord2f(vars[i].text[0],vars[i].text[1]);
        glVertex3f(vars[i].vert[0],vars[i].vert[1],vars[i].vert[2]);
        glNormal3f(vars[i].norm[0],vars[i].norm[1],vars[i].norm[2]);
    }
    glEnd();
    glEndList();
    COMPILED_ID=id;
    return *this;
}
glModel &glModel::Draw()
{
    if (texture==0){return *this;}
    if (COMPILED_ID!=id){Compile();}
    glCallList(model);
    return *this;
}
#else
glModel &glModel::Compile()
{
    if (numv<3)
        return *this;
    glGenBuffers(1,&model);
    glBindBuffer(GL_ARRAY_BUFFER,model);
    glBufferData(GL_ARRAY_BUFFER, numv*sizeof(glVertexStructure), vars, GL_STATIC_DRAW);
    COMPILED_ID=id;
    return *this;
}
glModel &glModel::Draw()
{
    if (texture==0){return *this;}
    if (COMPILED_ID!=id){Compile();}//1st sigseg comes from here
    int numt=numv-numv%3;
    if (numt==0)
        return *this;
    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),&(vars[0].text[0]));
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,sizeof(glVertexStructure),&(vars[0].norm[0]));
    glDrawArrays(GL_TRIANGLES, 0, numt);
    #endif
    return *this;
}
#endif

But I am still getting a blank window which requires using the Task Manager to kill. What am I doing wrong?

Assuming the stray #endif at line 53 is a left-over typo.

Also, from earlier, does your do-while loop in main() now look something like the following?

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

And have you sanity-checked your frame-rate maintaining Sleep() value, within GL.Update()? If you accidentally send it a negative number, that may well be automatically converted to an unexpectedly very-large positive number! :)

Here is more of my code:
Test.cpp:

#define SUPPRESS_VBOS
#include "3dglgui.h"


int main()
{
    GL.Init("TEST",500,500,false,0,0);
    if (GL.ERRORCODE)
    {
       return GL.ERRORCODE;
    }
    glModel model;
    model.Vertex(0,0,0,0,0);
    model.Vertex(1,1,1,1,1);
    model.Vertex(1,0,1,1,0);
    model.Texture("RANDOMTEST.bmp",true);
    do{
    GL.Draw(model);
    GL.Update();
    }while(!GL.window.key[VK_ESCAPE]);
    GL.Kill();
    return 0;
}

Update Function:

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);
    double deltatime=((double)(tmp.QuadPart-lastframe.QuadPart)/(double)freq.QuadPart)*(double)1000.0;
    double frametime=1000.0/(double)window.fps;
    if (deltatime<frametime)
        Sleep(frametime-deltatime);
    QueryPerformanceCounter(&lastframe);
    return *this;
}

Wow, I'm really running out of good ideas. When all else fails, debug-prints!

Next up, if you can run your executable from a command-prompt, put a couple of printf/cout lines inside your do-while loop to make sure it's actually looping at the expected rate. Feel free to drop your desired frame-rate to 1Hz or less, so you can see the print's ticking by ... and/or add a counter that you can print out so you can see how fast that's changing. I have the vague feeling that something in the functionality is blocking when you aren't expecting it to, but I'm not sure. If your loop is running, we can then try to figure out why the Escape key doesn't exit, and why it doesn't appear to be rendering anything to the window. If it -isn't- looping, we can start narrowing down where it's getting stuck.

*facepalm* I cant believe I missed it! The problem was in my Init() function! I never created a device context! I just had to add hRC=wglCreateContext(hDC); . I still cant get my Model class to draw thought, I just get a blank black screen. Here is my new test code:

#define SUPPRESS_VBOS
#include "3dglgui.h"


int main()
{
    GL.Init("TEST",500,500,32,false,0,0);
    if (GL.ERRORCODE)
    {
       return GL.ERRORCODE;
    }
    glModel model;
    model.Vertex(0,0,0,0,0);
    model.Vertex(1,1,1,1,1);
    model.Vertex(1,0,1,1,0);
    model.Texture("RANDOMTEST.bmp",true);
    do{
        if (GL.window.key[VK_UP])
            GL.Move(0,0.1f,0);
        if (GL.window.key[VK_DOWN])
            GL.Move(0,-0.1f,0);
    GL.Draw(model);
    GL.Update();
    }while(!GL.window.key[VK_ESCAPE]);
    GL.Kill();
    return 0;
}

The problem must be in my Rotation and Motion. Here are the related functions:

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::Update()
{
    glRotatef(pos.h,1,0,0);
    glRotatef(pos.v,0,1,0);
    glRotatef(pos.t,0,0,1);
    glTranslatef(-pos.x,-pos.y,-pos.z);
    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);
    double deltatime=((double)(tmp.QuadPart-lastframe.QuadPart)/(double)freq.QuadPart)*(double)1000.0;
    double frametime=1000.0/(double)window.fps;
    if (deltatime<frametime)
        Sleep(frametime-deltatime);
    QueryPerformanceCounter(&lastframe);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    return *this;
}

On translation/rotation: keep in mind that order-of-operations matters. I think yours will likely do as you expect, as long as it's acceptable that R/L and F/B movement is relative only to the heading (and not the pitch U/D or roll CW/CCW). Also, since the OpenGL camera looks along its own Z-axis, I think maybe you want pos.h to rotate around that, rather than the X-axis. (And since it looks like you intend pos.h=0 to indicate a compass-heading of north, pos.t should rotate around Y and pos.v around X, try changing only one of those values away from zero at a time until you're getting the behavior you expect. Also as you change more than one value, you may find that you need to do roll first, then pitch, then heading.

As far as your Move function, pos.h-90 is 180 degrees off from pos.h+90, so sin and cos of one are negatives of the other, and the entire else{} block is redundant. Instead, double-check that you're moving in the correct direction for obvious values of pos.h (like 0 and 90). Again, to test, set all values to zero except pos.h, then Move only F/B or only L/R and make sure you see what you expect! Also, since the camera is at (0, 0, 0) to begin with, make sure you start with a sensible z value to push the model out in front of the camera. Getting close now! :)

Ok, not working. I swapped the pos.h and pos.t as you suggested.
Mouse functions:

OpenGLInstance &OpenGLInstance::Mouse(int x, int y)
{
    RECT windim;
    GetWindowRect(hWnd,&windim);
    SetCursorPos(x+windim.left,y+windim.top);
    return *this;
}
OpenGLInstance &OpenGLInstance::Mouse(int *x, int *y)
{
    if (x==NULL|y==NULL)
        return *this;
    POINT *temp;
    GetCursorPos(temp);
    *x=temp->x;
    *y=temp->y;
    return *this;
}

Redraw and Update functions:

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);
    double deltatime=((double)(tmp.QuadPart-lastframe.QuadPart)/(double)freq.QuadPart)*(double)1000.0;
    double frametime=1000.0/(double)window.fps;
    if (deltatime<frametime)
        Sleep(frametime-deltatime);
    QueryPerformanceCounter(&lastframe);
    return *this;
}
OpenGLInstance &OpenGLInstance::Redraw()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glRotatef(pos.t,1,0,0);
    glRotatef(pos.v,0,1,0);
    glRotatef(pos.h,0,0,1);
    glTranslatef(-pos.x,-pos.y,pos.z);
    return *this;
}

test.cpp:

#define SUPPRESS_VBOS
#include "3dglgui.h"


int main()
{
    GL.Init("TEST",500,500,32,false,0,0);
    if (GL.ERRORCODE)
    {
       return GL.ERRORCODE;
    }
    glModel model;
    model.Vertex( 0, 1, 0, 0, 0);
    model.Vertex(-1,-1, 0, 1, 1);
    model.Vertex( 1,-1, 0, 1, 0);
    model.Texture("RANDOMTEST.bmp",true);
    int dx=0, dy=0;
    do{
        GL.Redraw();
        //GL.Mouse(&dx,&dy);//this is commented out because it causes a sigseg... why?
        //GL.Rotate(dx-50,dy-50,0).Mouse(50,50);//will this work if the above works?
        glTranslatef(1,0,-6);
        if (GL.window.key[VK_UP])
            GL.Move(0,0,0.1);
        if (GL.window.key[VK_DOWN])
            GL.Move(0,0,-0.1);
        if (GL.window.key[VK_RIGHT])
            GL.Move(0.1,0,0);
        if (GL.window.key[VK_LEFT])
            GL.Move(-0.1,0,0);
        if (GL('a'))
            GL.Rotate(1,0,0);
        if (GL('e'))
            GL.Rotate(-1,0,0);
        if (GL(','))
            GL.Rotate(0,1,0);
        if (GL('o'))
            GL.Rotate(0,-1,0);
    GL.Draw(model);
    GL.Update();
    }while(!GL.window.key[VK_ESCAPE]);
    GL.Kill();
    return 0;
}

It all works in the state above, but when I press the ,aoe keys (Dvorak equivalent of WASD) nothing happens. The Mouse based lines cause a SIGSEG. I kinda need both to work.

In Mouse(int *x, int *y), temp isn't allocated. Replace lines 12-15 with:

POINT temp;
    GetCursorPos(&temp);
    *x=temp.x;
    *y=temp.y;

In fact, if you might want to collect only the x or y value, pass NULL for the other pointer and reimplement as:

OpenGLInstance &OpenGLInstance::Mouse(int *x, int *y)
{
    if (x==NULL && y==NULL)
        return *this;
    POINT temp;
    GetCursorPos(&temp);
    if (x)
        *x=temp.x;
    if (y)
        *y=temp.y;
    return *this;
}

As far as keyboard keys, I'm not sure, but try putting a debug-print in your WndProc WM_KEYDOWN event and make sure that the value you're getting corresponds to the one you're checking for. I wouldn't be surprised if 'a' is really returning 'A' or even 'w' or 'W' depending on when the dvorak translation happens. Also try bumping the angle-increment up to 5 or 10 degrees, temporarily, so you -know- when it happens. :)

ok, its starting to kinda work, but my movement is... weird, i think that its not taking my direction into account correctly.

Oh and I renamed my rotation variables, here you can read them better:

OpenGLInstance &OpenGLInstance::Move(float rl, float fb, float z)
{
    pos.x-=(float)sin(DEGTORAD(pos.yaw-90.0f))*rl;
    pos.z-=(float)cos(DEGTORAD(pos.yaw-90.0f))*rl;
    pos.x-=(float)sin(DEGTORAD(pos.yaw))*fb;
    pos.z-=(float)cos(DEGTORAD(pos.yaw))*fb;
    pos.y+=z;
    return *this;
}
OpenGLInstance &OpenGLInstance::Rotate(float rl, float ud, float cc)
{
    pos.roll+=cc;
    pos.yaw+=rl;
    pos.pitch+=ud;
    return *this;
}

The glTranslate in your Draw() command is in (x,y,z) that take into account your heading rotation, while the one out in your do-while loop does not. One of them is probably incorrect. If you leave them where they are, and just change the rotations, does your model stay centered in your view and twist around as you expect? If so, try moving the one in Redraw to before the glRotates. If not, try moving the new one inside Redraw before the glRotates.

The "right" answer can certainly be painstakenly worked out on paper, given the documentation for how the OpenGL commands work, but I find it actually faster to take a known model (like a simple 3-axis, 3-color ball & stick object) and use trial and error to get the operations into the proper order and in the right directions. Now that you can actually see your model, it should go quicker. If you can't tell why it's moving incorrectly, start over and change as few values as possible, to narrow down which operations might be inverted, or specified in the wrong order. If needed, comment out operations while you test other ones, then put them back in when you're ready. Good luck!

VICTORY!!! THANK YOU FOR YOUR HELP!!! I finally got fed up messing around with components of vectors, so I just changed Move to take distance, yaw, pitch, then I just used the resulting vector and my knowledge of solving the components of 3D vectors and came up with a working function!

VICTORY!!! THANK YOU FOR YOUR HELP!!!

Awesome! And you're quite welcome. Enjoy!

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.