• FEATURED

View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

OpenGL GUI anyone? Updated on 11/17/05

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

207 replies to this topic

#201billconan  Members

Posted 13 December 2005 - 03:32 AM

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

#202ViLiO  Members

Posted 13 December 2005 - 03:48 AM

Quote:
 Original post by billconanit is great, but how come i only get a 75fps? i have a 6600gt and 1g ram with the newest driver.

You have v-sync enabled and your monitor is set to 75Hz?

#203Thunder_Hawk  Members

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).
______________________________________________________________________________________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______________________________________________________________________________________

#204sckoobs  Members

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.


void Box2D(int x0, int y0, int width, int height)
{
//
{
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 + width - radius, y0 - height + radius},	// bottom right
};

float start[4][2] =
{
{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 &lt; 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 &gt; 0; --j)
{
x = cos(total);
y = sin(total);
total += inc;

}
}
glEnd();
}

//
}



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.

#205sckoobs  Members

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).


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 + width - radius, y0},
{x0 + width, y0 - height + radius},
{x0 + radius, y0 - height}
};

// four corners and 2 coords (x, y)
float corners[4][2] =
{
{x0 + width - radius, y0 - height + radius},	// bottom right
};

// 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(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?

#206Boder  Members

Posted 02 January 2006 - 03:26 PM

To compile on Mingw.

MathUtils.h
line 61: #ifdef NOTDEFINED
line 239: std::out -> out
line 494: std::out -> out
line 498: std::in -> in
line 715: std::out -> out

#207evolutional  Moderators

Posted 25 June 2006 - 11:57 PM

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

#208Alpheus  GDNet+

Posted 26 June 2006 - 12:19 AM

Quote:
 Original post by evolutionalWhat'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...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.