OpenGL API Specifications
Documents and Learning ResourcesSupport Libraries and FrameworksFunction Libraries and GeneratorsThis list contains some basic resources for getting started with, and developing for, OpenGL 3.0 and onwards. Contact your forum moderator if you want to contribute to the list or have any comments.Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
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.
Posted 13 December 2005 - 03:50 AM
Posted 18 December 2005 - 07:02 AM
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));
}
Posted 18 December 2005 - 12:00 PM
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();
Posted 25 June 2006 - 11:57 PM
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
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.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.