Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411630 Posts in 69393 Topics- by 58447 Members - Latest Member: sinsofsven

May 11, 2024, 07:32:08 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Problems with using opengl displaylists in a class
Pages: [1]
Print
Author Topic: Problems with using opengl displaylists in a class  (Read 1574 times)
Tycho Brahe
Level 10
*****

λx.x


View Profile
« on: January 18, 2010, 09:26:50 AM »

I've got a rendering class (or the start of one at least) to aid with streamlining and simplifying rendering in my engine.

I would like to use display lists with my vertex operations because of the speed boost that they give, however when I try to use them with my class they fail...

The class is this:
Code:
#ifndef RENDERER_H
#define RENDERER_H

#include <SDL_opengl.h>
#include <GL/gl.h>
#include <GL/glu.h>
class Renderer
{
public:
    Renderer() {
        OutLine = glGenLists(1);
        glNewList(OutLine,GL_COMPILE);
        glBegin(GL_LINES);
        glColor4f(1.0,1.0,1.0,1.0);
        for (float x = -5;x<=5;x+=0.1)
        {
            glVertex3f(x,-5,0.0);
            glVertex3f(x,5,0.0);
        }
        for (float y = -5;y<=5;y+=0.1)
        {
            glVertex3f(-5,y,0.0);
            glVertex3f(5,y,0.0);
        }
        glVertex3f(-0.05,-0.05,0.0);
        glVertex3f(-0.05,0.05,0.0);
        glVertex3f(0.05,-0.05,0.0);
        glVertex3f(0.05,0.05,0.0);
        glVertex3f(-0.05,-0.05,0.0);
        glVertex3f(0.05,-0.05,0.0);
        glVertex3f(-0.05,0.05,0.0);
        glVertex3f(0.05,0.05,0.0);
        glEnd();
        glEndList();
    }
    virtual ~Renderer()
    {
        glDeleteLists(OutLine,1);
    }
    GLuint OutLine;
    void Compile()
    {


    }
    void DrawOutline()
    {
        glCallList(OutLine);
    }
protected:
private:

};

#endif // RENDERER_H

and I render it every frame with:
Code:
RENDERER.DrawOutLine()

This code simply displays nothing when called, and gives no compile-time errors either. When I check to see if the GLuint has been initialised as a DL it says that it hasn't, even though I know that it has.

Any thoughts?

Thanks.
Logged
powly
Level 4
****



View Profile WWW
« Reply #1 on: January 18, 2010, 10:36:27 AM »

I made an instance of that, called DrawOutline on it and it gave me a grid with a square in the middle. So it's either the rest of the program or your computer - I'd guess the former. Double check your transformations etc. Smiley But if you get the problem with only something like loadidentity->translate(0, 0,-10), it's truly bad times.
Logged
Chromanoid
Level 10
*****



View Profile
« Reply #2 on: January 18, 2010, 10:40:03 AM »

Try to draw the stuff without a display list. Did you check the GL error codes?
Logged
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #3 on: January 18, 2010, 10:56:58 AM »

It works without display lists, but I will try and check the error codes, thanks

Also, msqrt, its heartening that it does work for you, that means that its something else in my program that's broken.

[EDIT]

I've run some tests, and the drawing code and everything is fine. Going by what msqrt said, it should work.

When checking for the last error using glGetError() it returns error code 1281, meaning over-large texture (or words to that effect) which I'm very confused by.

also, msqrt, when you got it working, how did you do it? It simply doesnt work for me, even when reduced to loadIdentity() glTranslatef(0,0,-10)
« Last Edit: January 18, 2010, 11:13:39 AM by 14113 » Logged
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #4 on: January 18, 2010, 11:25:17 AM »

Right, fixed it, I was having the dL compilation code in the constructor, not in the compile method, and I wasnt calling it correctly.

Long story short, I fixed it.

Thanks guys!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic