-void OpenGL$RectGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx1, jint sy1, jint sx2, jint sy2) {
- if (gl->hasRectangularTextures()) {
- glColor4f(1.0f,1.0f,1.0f,1.0f);
- glEnable(GL_TEXTURE_RECTANGLE_EXT);
- glBindTexture(GL_TEXTURE_RECTANGLE_EXT, textureName);
- glBegin(GL_QUADS);
- glTexCoord2i (sx1, sy1 );
- glVertex3i (dx1, dy1, 0);
- glTexCoord2i (sx2, sy1 );
- glVertex3i (dx2, dy1, 0);
- glTexCoord2i (sx2, sy2 );
- glVertex3i (dx2, dy2, 0);
- glTexCoord2i (sx1, sy2 );
- glVertex3i (dx1, dy2, 0);
- glEnd();
- glDisable(GL_TEXTURE_RECTANGLE_EXT);
- checkGLError();
- } else {
- float tx1,ty1,tx2,ty2; // normalized texture coords
- tx1 = (float) sx1 / (float) width;
- ty1 = (float) sy1 / (float) height;
- tx2 = (float) sx2 / (float) width;
- ty2 = (float) sy2 / (float) height;
-
- glColor4f(1.0f,1.0f,1.0f,1.0f);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, textureName);
- checkGLError();
- glBegin(GL_QUADS);
- glTexCoord2f (tx1, ty1 );
- glVertex3i (dx1, dy1, 0);
- glTexCoord2f (tx2, ty1 );
- glVertex3i (dx2, dy1, 0);
- glTexCoord2f (tx2, ty2 );
- glVertex3i (dx2, dy2, 0);
- glTexCoord2f (tx1, ty2 );
- glVertex3i (dx1, dy2, 0);
- glEnd();
- glDisable(GL_TEXTURE_2D);
- checkGLError();
- }
+void OpenGL$RectGLPicture::draw(jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) {
+ cx1 = max(dx, cx1);
+ cy1 = max(dy, cy1);
+ cx2 = min(cx2, dx + width);
+ cy2 = min(cy2, dy + height);
+ if (cy2 <= cy1 || cx2 <= cx1) return;
+ glEnable(GL_TEXTURE_RECTANGLE_EXT);
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, textureName);
+ glBegin(GL_QUADS); {
+ glTexCoord2i (cx1 - dx, cy1 - dy );
+ glVertex3i (cx1, cy1, 0);
+ glTexCoord2i (cx2 - dx, cy1 - dy );
+ glVertex3i (cx2, cy1, 0);
+ glTexCoord2i (cx2 - dx, cy2 - dy );
+ glVertex3i (cx2, cy2, 0);
+ glTexCoord2i (cx1 - dx, cy2 - dy );
+ glVertex3i (cx1, cy2, 0);
+ } glEnd();
+ glDisable(GL_TEXTURE_RECTANGLE_EXT);
+ checkGLError();