Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void render_rectangle_bitmap(PictureBuffer* screen, Rect rect,Rect subrect,Vec4 color)
- {
- glEnable(GL_TEXTURE_2D);
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glBindTexture(GL_TEXTURE_2D,(GLuint)screen->handle );
- Vec2 lower_left=vec2f(rect.startx,rect.endy);
- Vec2 upper_left=vec2f(rect.startx,rect.starty);
- Vec2 upper_right= vec2f(rect.endx,rect.starty);
- Vec2 lower_right= vec2f(rect.endx,rect.endy);
- glBegin(GL_TRIANGLES);
- glColor4fv(color.xyzw);
- glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.starty);
- glVertex2fv(upper_left.E);
- glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.starty);
- glVertex2fv(upper_right.E);
- glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.endy);
- glVertex2fv(lower_right.E);
- glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.starty);
- glVertex2fv(upper_left.E);
- glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.endy);
- glVertex2fv(lower_right.E);
- glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.endy);
- glVertex2fv(lower_left.E);
- glEnd();
- glBindTexture(GL_TEXTURE_2D,0 );
- glDisable(GL_TEXTURE_2D);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement