it is great, but how come i only get a 75fps? i have a 6600gt and 1g ram with the newest driver.

**0**

# OpenGL GUI anyone? Updated on 11/17/05

Started by JavaCoolDude, Jun 14 2005 09:18 PM

207 replies to this topic

Sponsor:

###
#203
Members - Reputation: **314**

Posted 13 December 2005 - 03:50 AM

You probably have Vsync turned on (google it). You should leave Vsync on most of the time anyway though since 75 FPS is about the limit of human perception, peripheral or otherwise.

With that, you should probably start another thread if you have further problems that don't directly concern OpenGLUI (this question is a general OpenGL question for instance).

With that, you should probably start another thread if you have further problems that don't directly concern OpenGLUI (this question is a general OpenGL question for instance).

______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________

###
#204
Members - Reputation: **157**

Posted 18 December 2005 - 07:02 AM

I had a go at the rounded panel idea and came up with a method that uses the GL_TRIANGLE_FAN.

The code assumes that your 2d world orgin is in the bottom left corner of the screen, though I don't think it really matters.

The exe (using GLUT) and source code can be found here:

http://myweb.tiscali.co.uk/incognito/roundedrec.zip

You will notice when you run it that there is a slight anomaly in the rop right hand corner which I haven't been able to fix yet, perhaps it just requires more accurate coords than floats, so if anyone fixes that it would be nice to share.

Also I have no idea how to antialias using OpenGL, lines are easy enough, I tried the same principal with GL_POLYGON_SMOOTH hint but still didn't manage to get it to smooth at the corners, i've left that code in there, so any suggestions are welcome!

Forgot to mention, NUM_SIDES in the source code MAIN.CPP is what controls the resolution of the corners, each corner is has a number of sides equal to NUM_SIDES / 4. The smaller the radius the smaller a resolution you can get away with visually, with the radius at 70 pixels, I find 32 a decent resolution.

void Box2D(int x0, int y0, int width, int height)

{

//

glBegin(GL_QUADS);

{

glVertex2i(x0, y0);

glVertex2i(x0 + width, y0);

glVertex2i(x0 + width, y0 - height);

glVertex2i(x0, y0 - height);

}

glEnd();

}

void RoundedBox2D(int x0, int y0, int width, int height, int radius)

{

// four corners and 2 coords (x, y)

float corners[4][2] =

{

{x0 + radius, y0 - radius}, // top left

{x0 + width - radius, y0 - radius}, // top right

{x0 + width - radius, y0 - height + radius}, // bottom right

{x0 + radius, y0 - height + radius} // bottom left

};

float start[4][2] =

{

{x0 + radius, y0},

{x0 + width, y0 - radius},

{x0 + width - radius, y0 - height},

{x0, y0 - height + radius}

};

double inc = (2 * PI) / NUM_SIDES;

double total = 0;

float x, y;

int count = 0;

// top left rounded corner first

for(int i = 0; i < 4; ++i)

{

// draw a rounded corner

glBegin(GL_TRIANGLE_FAN);//POINTS);

{

glVertex2i(start[i][0], start[i][1]);

glVertex2i(corners[i][0], corners[i][1]);

for(int j = (NUM_SIDES / 4); j > 0; --j)

{

x = cos(total);

y = sin(total);

total += inc;

glVertex2i(corners[i][0] - (x * radius), corners[i][1] + (y * radius));

}

}

glEnd();

}

//

Box2D(x0, y0 - radius, radius, height - (2 * radius));

Box2D(x0 + radius, y0, width - (2 * radius), height);

Box2D(x0 + width - radius, y0 - radius, radius, height - (2 * radius));

}

The code assumes that your 2d world orgin is in the bottom left corner of the screen, though I don't think it really matters.

The exe (using GLUT) and source code can be found here:

http://myweb.tiscali.co.uk/incognito/roundedrec.zip

You will notice when you run it that there is a slight anomaly in the rop right hand corner which I haven't been able to fix yet, perhaps it just requires more accurate coords than floats, so if anyone fixes that it would be nice to share.

Also I have no idea how to antialias using OpenGL, lines are easy enough, I tried the same principal with GL_POLYGON_SMOOTH hint but still didn't manage to get it to smooth at the corners, i've left that code in there, so any suggestions are welcome!

Forgot to mention, NUM_SIDES in the source code MAIN.CPP is what controls the resolution of the corners, each corner is has a number of sides equal to NUM_SIDES / 4. The smaller the radius the smaller a resolution you can get away with visually, with the radius at 70 pixels, I find 32 a decent resolution.

###
#205
Members - Reputation: **157**

Posted 18 December 2005 - 12:00 PM

Just created a new one which doesn't require the Box2d function. Just used one big triangle fan (which never occurred to me before now).

The new source and program can be found in the same place as mentioned in my last post. Hopefully this will help you out xargon123.

Still haven't sorted out antialiasing, anyone care to hazzard a guess?

void RoundedBox2D(int x0, int y0, int width, int height, int radius)

{

double inc = (2 * PI) / NUM_SIDES;

double total = 0;

float x, y;

int count = 0;

// the staring coords of each of corners

float start[4][2] =

{

{x0, y0 - radius},

{x0 + width - radius, y0},

{x0 + width, y0 - height + radius},

{x0 + radius, y0 - height}

};

// four corners and 2 coords (x, y)

float corners[4][2] =

{

{x0 + radius, y0 - radius}, // top left

{x0 + width - radius, y0 - radius}, // top right

{x0 + width - radius, y0 - height + radius}, // bottom right

{x0 + radius, y0 - height + radius} // bottom left

};

// populate the vertex coords array

glBegin(GL_TRIANGLE_FAN);

{

// first coord is the center of the panel

glVertex2i(x0 + (width / 2), y0 - (height / 2));

total += inc;

// start populating from the 9 o'clock position on the top left hand corner

for(int i = 0; i < 4; ++i)

{

int startingCornerVertex = i * (NUM_SIDES / 4);

glVertex2i(start[i][0], start[i][1]);

for(int j = (NUM_SIDES / 4); j > 0; --j)

//for(int j = 0; j < (NUM_SIDES / 4); ++j)

{

x = cos(total);

y = sin(total);

total += inc;

glVertex2i(corners[i][0] - (x * radius), corners[i][1] + (y * radius));

}

}

glVertex2i(start[0][0], start[0][1]);

}

glEnd();

The new source and program can be found in the same place as mentioned in my last post. Hopefully this will help you out xargon123.

Still haven't sorted out antialiasing, anyone care to hazzard a guess?

###
#208
Crossbones+ - Reputation: **4774**

Posted 26 June 2006 - 12:19 AM

Quote:

Original post by evolutional

What's the current status of this project? Is it actively being maintained? Is it stable? I'd like to use it as a basis for an article I'm planning on writing.

Cheers

I thought it was the SXML Project...