Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. static void render_rectangle_bitmap(PictureBuffer* screen, Rect rect,Rect subrect,Vec4 color)
  2. {
  3. glEnable(GL_TEXTURE_2D);
  4. glMatrixMode(GL_TEXTURE);
  5. glLoadIdentity();
  6.  
  7.  
  8. glBindTexture(GL_TEXTURE_2D,(GLuint)screen->handle );
  9.  
  10. Vec2 lower_left=vec2f(rect.startx,rect.endy);
  11. Vec2 upper_left=vec2f(rect.startx,rect.starty);
  12. Vec2 upper_right= vec2f(rect.endx,rect.starty);
  13. Vec2 lower_right= vec2f(rect.endx,rect.endy);
  14.  
  15. glBegin(GL_TRIANGLES);
  16. glColor4fv(color.xyzw);
  17.  
  18.  
  19. glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.starty);
  20. glVertex2fv(upper_left.E);
  21. glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.starty);
  22. glVertex2fv(upper_right.E);
  23. glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.endy);
  24. glVertex2fv(lower_right.E);
  25. glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.starty);
  26. glVertex2fv(upper_left.E);
  27. glTexCoord2f(screen->width*subrect.endx/(r32)screen->pitch,subrect.endy);
  28. glVertex2fv(lower_right.E);
  29. glTexCoord2f(screen->width*subrect.startx/(r32)screen->pitch,subrect.endy);
  30. glVertex2fv(lower_left.E);
  31. glEnd();
  32. glBindTexture(GL_TEXTURE_2D,0 );
  33. glDisable(GL_TEXTURE_2D);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement