Sign in to follow this  

Filling a rectangle

This topic is 4272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void glFillRect(RECTANGLE* rc, ColourData* colour)
{
	glLoadIdentity();
	glTranslated(rc->x,rc->y,0);
	glColor4d(colour->r,colour->g,colour->b,colour->a);
	glBegin(GL_QUADS);
		glVertex2d(0,0);
		glVertex2d(rc->w,0);
		glVertex2d(rc->w,rc->y);
		glVertex2d(rc->w,0);
	glEnd();
}
Okay... I've put this code in here... Despite me using code very similar to display textured quads (which works), this however, doesn't. Nothing shows up... any ideas as to what might be wrong?

Share this post


Link to post
Share on other sites
*blinks*
...
*smacks head*

Right. I don't know how I missed that :(

Thanks :)

EDIT:

Erm.. even with the changes, it still doesn't work. I'm drawing it last, so it's not behind anything, with this code:

ColourData colour = {255,255,100,255};
RECTANGLE rc = {50,50,10,10};
glFillRect(&rc,&colour);

Share this post


Link to post
Share on other sites
Try reversing the order of the vertices so that they are like this:

glVertex2d(0,0);
glVertex2d(0,rc->y);
glVertex2d(rc->w,rc->y);
glVertex2d(rc->w,0);

Polygons should be drawn in a counter-clockwise vertex order.

Then again, it could be a number of other things. Are you able to draw anything else to the screen?

Share this post


Link to post
Share on other sites
I tried to reverse it, but no luck.

And yes, I can draw quads with textures mapped onto them using this code:

void DrawImage(ImageData* structure, double x, double y, double rotation, ColourData* colour)
{
glBindTexture( GL_TEXTURE_2D, structure->textureid );
glLoadIdentity();
glTranslated(x+structure->w/2,y+structure->h/2,0);
glRotated(rotation,0,0,1);
glColor4ub(colour->r,colour->g,colour->b,colour->a);
glBegin(GL_QUADS);
glTexCoord2f (0.0f, 0.0f); glVertex2d(0-structure->w/2,0-structure->h/2);
glTexCoord2f (1.0f, 0.0f); glVertex2d(0+structure->w/2,0-structure->h/2);
glTexCoord2f (1.0f, 1.0f); glVertex2d(0+structure->w/2,0+structure->h/2);
glTexCoord2f (0.0f, 1.0f); glVertex2d(0-structure->w/2,0+structure->h/2);
glEnd();
}

Share this post


Link to post
Share on other sites

This topic is 4272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this