25 #if !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
48 #define vertFill2D(tVar, vVar, x1, y1, x2, y2, dstX, dstY, w, h) \
57 vVar[vp + 0] = dstX; \
58 vVar[vp + 1] = dstY; \
59 vVar[vp + 2] = dstX + w; \
60 vVar[vp + 3] = dstY; \
61 vVar[vp + 4] = dstX + w; \
62 vVar[vp + 5] = dstY + h; \
63 vVar[vp + 6] = dstX; \
64 vVar[vp + 7] = dstY + h
67 #define vertFillNv(tVar, vVar, srcX, srcY, dstX, dstY, w, h) \
68 tVar[vp + 0] = srcX; \
69 tVar[vp + 1] = srcY; \
70 tVar[vp + 2] = srcX + w; \
71 tVar[vp + 3] = srcY; \
72 tVar[vp + 4] = srcX + w; \
73 tVar[vp + 5] = srcY + h; \
74 tVar[vp + 6] = srcX; \
75 tVar[vp + 7] = srcY + h; \
76 vVar[vp + 0] = dstX; \
77 vVar[vp + 1] = dstY; \
78 vVar[vp + 2] = dstX + w; \
79 vVar[vp + 3] = dstY; \
80 vVar[vp + 4] = dstX + w; \
81 vVar[vp + 5] = dstY + h; \
82 vVar[vp + 6] = dstX; \
83 vVar[vp + 7] = dstY + h
91 #ifdef DEBUG_DRAW_CALLS
92 unsigned int NormalOpenGLGraphics::mDrawCalls = 0;
93 unsigned int NormalOpenGLGraphics::mLastDrawCalls = 0;
95 #ifdef DEBUG_BIND_TEXTURE
96 unsigned int NormalOpenGLGraphics::mBinds = 0;
97 unsigned int NormalOpenGLGraphics::mLastBinds = 0;
116 #ifdef DEBUG_BIND_TEXTURE
123 mName =
"normal OpenGL";
133 mMaxVertices = vertCount;
134 if (mMaxVertices < 500)
136 else if (mMaxVertices > 1024)
141 const size_t sz = mMaxVertices * 4 + 30;
142 if (mFloatTexArray ==
nullptr)
143 mFloatTexArray =
new GLfloat[sz];
144 if (mIntTexArray ==
nullptr)
145 mIntTexArray =
new GLint[sz];
146 if (mIntVertArray ==
nullptr)
147 mIntVertArray =
new GLint[sz];
148 if (mFloatTexArrayCached ==
nullptr)
149 mFloatTexArrayCached =
new GLfloat[sz];
150 if (mIntTexArrayCached ==
nullptr)
151 mIntTexArrayCached =
new GLint[sz];
152 if (mIntVertArrayCached ==
nullptr)
153 mIntVertArrayCached =
new GLint[sz];
195 return setOpenGLMode();
208 glVertexPointer(2, GL_INT, 0, vert);
209 glTexCoordPointer(2, GL_FLOAT, 0, tex);
214 const GLint *
restrict const tex) A_INLINE;
222 glVertexPointer(2, GL_INT, 0, vert);
223 glTexCoordPointer(2, GL_INT, 0, tex);
228 const int srcX,
const int srcY,
229 const int dstX,
const int dstY,
230 const int width,
const int height)
234 const
int srcX, const
int srcY,
235 const
int dstX, const
int dstY,
236 const
int width, const
int height)
240 const float tw =
static_cast<float>(image->mTexWidth);
241 const float th =
static_cast<float>(image->mTexHeight);
243 const float texX1 =
static_cast<float>(srcX) / tw;
244 const float texY1 =
static_cast<float>(srcY) / th;
245 const float texX2 =
static_cast<float>(srcX + width) / tw;
246 const float texY2 =
static_cast<float>(srcY + height) / th;
260 dstX + width, dstY + height,
265 #ifdef DEBUG_DRAW_CALLS
266 NormalOpenGLGraphics::mDrawCalls ++;
269 glDrawArrays(GL_QUADS, 0, 4);
280 srcX + width, srcY + height,
287 dstX + width, dstY + height,
292 #ifdef DEBUG_DRAW_CALLS
293 NormalOpenGLGraphics::mDrawCalls ++;
296 glDrawArrays(GL_QUADS, 0, 4);
304 const int srcX,
const int srcY,
305 const int dstX,
const int dstY,
306 const int width,
const int height,
307 const int desiredWidth,
308 const int desiredHeight)
312 const
int srcX, const
int srcY,
313 const
int dstX, const
int dstY,
314 const
int width, const
int height,
315 const
int desiredWidth,
316 const
int desiredHeight)
320 const float tw =
static_cast<float>(image->mTexWidth);
321 const float th =
static_cast<float>(image->mTexHeight);
323 const float texX1 =
static_cast<float>(srcX) / tw;
324 const float texY1 =
static_cast<float>(srcY) / th;
325 const float texX2 =
static_cast<float>(srcX + width) / tw;
326 const float texY2 =
static_cast<float>(srcY + height) / th;
339 dstX + desiredWidth, dstY,
340 dstX + desiredWidth, dstY + desiredHeight,
341 dstX, dstY + desiredHeight
345 #ifdef DEBUG_DRAW_CALLS
346 NormalOpenGLGraphics::mDrawCalls ++;
349 glDrawArrays(GL_QUADS, 0, 4);
360 srcX + width, srcY + height,
366 dstX + desiredWidth, dstY,
367 dstX + desiredWidth, dstY + desiredHeight,
368 dstX, dstY + desiredHeight
372 #ifdef DEBUG_DRAW_CALLS
373 NormalOpenGLGraphics::mDrawCalls ++;
376 glDrawArrays(GL_QUADS, 0, 4);
393 if (image ==
nullptr)
397 #ifdef DEBUG_BIND_TEXTURE
404 const SDL_Rect &imageRect = image->mBounds;
405 drawQuad(image, imageRect.x, imageRect.y,
406 dstX, dstY, imageRect.w, imageRect.h);
436 #ifdef DEBUG_DRAW_CALLS
437 NormalOpenGLGraphics::mDrawCalls ++;
440 glDrawArrays(GL_QUADS, 0, 4);
464 #ifdef DEBUG_DRAW_CALLS
465 NormalOpenGLGraphics::mDrawCalls ++;
468 glDrawArrays(GL_QUADS, 0, 4);
478 if (image ==
nullptr)
481 if (image->mGLImage != mImageCached)
484 mImageCached = image->mGLImage;
485 mAlphaCached = image->mAlpha;
488 const SDL_Rect &imageRect = image->mBounds;
489 const int w = imageRect.w;
490 const int h = imageRect.h;
492 if (w == 0 || h == 0)
495 const int srcX = imageRect.x;
496 const int srcY = imageRect.y;
498 const unsigned int vLimit = mMaxVertices * 4;
500 unsigned int vp = mVpCached;
505 const float tw =
static_cast<float>(image->mTexWidth);
506 const float th =
static_cast<float>(image->mTexHeight);
508 const float texX1 =
static_cast<float>(srcX) / tw;
509 const float texY1 =
static_cast<float>(srcY) / th;
511 const float texX2 =
static_cast<float>(srcX + w) / tw;
512 const float texY2 =
static_cast<float>(srcY + h) / th;
514 vertFill2D(mFloatTexArrayCached, mIntVertArrayCached,
515 texX1, texY1, texX2, texY2,
531 vertFillNv(mIntTexArrayCached, mIntVertArrayCached,
532 srcX, srcY,
x,
y, w, h);
554 if (image ==
nullptr)
557 if (image->mGLImage != mImageCached)
560 mImageCached = image->mGLImage;
563 const SDL_Rect &imageRect = image->mBounds;
564 const int srcX = imageRect.x;
565 const int srcY = imageRect.y;
566 const int iw = imageRect.w;
567 const int ih = imageRect.h;
569 if (iw == 0 || ih == 0)
572 unsigned int vp = mVpCached;
573 const unsigned int vLimit = mMaxVertices * 4;
577 const float tw =
static_cast<float>(image->mTexWidth);
578 const float th =
static_cast<float>(image->mTexHeight);
580 const float texX1 =
static_cast<float>(srcX) / tw;
581 const float texY1 =
static_cast<float>(srcY) / th;
583 for (
int py = 0; py < h; py += ih)
585 const int height = (py + ih >= h) ? h - py : ih;
586 const int dstY =
y + py;
587 const float texY2 =
static_cast<float>(srcY + height) / th;
588 for (
int px = 0; px < w; px += iw)
590 const int width = (px + iw >= w) ? w - px : iw;
591 const int dstX =
x + px;
593 const float texX2 =
static_cast<float>(srcX + width) / tw;
595 vertFill2D(mFloatTexArrayCached, mIntVertArrayCached,
596 texX1, texY1, texX2, texY2,
597 dstX, dstY, width, height);
610 for (
int py = 0; py < h; py += ih)
612 const int height = (py + ih >= h) ? h - py : ih;
613 const int dstY =
y + py;
614 for (
int px = 0; px < w; px += iw)
616 const int width = (px + iw >= w) ? w - px : iw;
617 const int dstX =
x + px;
619 vertFillNv(mIntTexArrayCached, mIntVertArrayCached,
620 srcX, srcY, dstX, dstY, width, height);
640 #ifdef DEBUG_BIND_TEXTURE
658 const int desiredWidth,
662 if (image ==
nullptr)
665 const SDL_Rect &imageRect = image->mBounds;
668 if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
675 #ifdef DEBUG_BIND_TEXTURE
684 imageRect.w, imageRect.h, desiredWidth, desiredHeight);
688 const int x,
const int y,
701 if (image ==
nullptr)
704 const SDL_Rect &imageRect = image->mBounds;
705 const
int srcX = imageRect.
x;
706 const
int srcY = imageRect.
y;
707 const
int iw = imageRect.w;
708 const
int ih = imageRect.h;
710 if (iw == 0 || ih == 0)
715 #ifdef DEBUG_BIND_TEXTURE
724 const unsigned int vLimit = mMaxVertices * 4;
728 const float tw =
static_cast<float>(image->mTexWidth);
729 const float th =
static_cast<float>(image->mTexHeight);
731 const float texX1 =
static_cast<float>(srcX) / tw;
732 const float texY1 =
static_cast<float>(srcY) / th;
734 for (
int py = 0; py < h; py += ih)
736 const int height = (py + ih >= h) ? h - py : ih;
737 const int dstY =
y + py;
738 const float texY2 =
static_cast<float>(srcY + height) / th;
739 for (
int px = 0; px < w; px += iw)
741 const int width = (px + iw >= w) ? w - px : iw;
742 const int dstX =
x + px;
743 const float texX2 =
static_cast<float>(srcX + width) / tw;
746 texX1, texY1, texX2, texY2,
747 dstX, dstY, width, height);
762 for (
int py = 0; py < h; py += ih)
764 const int height = (py + ih >= h) ? h - py : ih;
765 const int dstY =
y + py;
766 for (
int px = 0; px < w; px += iw)
768 const int width = (px + iw >= w) ? w - px : iw;
769 const int dstX =
x + px;
772 srcX, srcY, dstX, dstY, width, height);
789 const int x,
const int y,
790 const int w,
const int h,
791 const int scaledWidth,
792 const int scaledHeight)
795 if (image ==
nullptr)
798 if (scaledWidth == 0 || scaledHeight == 0)
801 const SDL_Rect &imageRect = image->mBounds;
802 const int iw = imageRect.w;
803 const int ih = imageRect.h;
804 if (iw == 0 || ih == 0)
807 const int srcX = imageRect.x;
808 const int srcY = imageRect.y;
812 #ifdef DEBUG_BIND_TEXTURE
821 const unsigned int vLimit = mMaxVertices * 4;
826 const float tw =
static_cast<float>(image->mTexWidth);
827 const float th =
static_cast<float>(image->mTexHeight);
829 const float texX1 =
static_cast<float>(srcX) / tw;
830 const float texY1 =
static_cast<float>(srcY) / th;
832 const float tFractionW = iw / tw;
833 const float tFractionH = ih / th;
835 for (
int py = 0; py < h; py += scaledHeight)
837 const int height = (py + scaledHeight >= h)
838 ? h - py : scaledHeight;
839 const int dstY =
y + py;
840 const float visibleFractionH =
static_cast<float>(height)
842 const float texY2 = texY1 + tFractionH * visibleFractionH;
843 for (
int px = 0; px < w; px += scaledWidth)
845 const int width = (px + scaledWidth >= w)
846 ? w - px : scaledWidth;
847 const int dstX =
x + px;
848 const float visibleFractionW =
static_cast<float>(width)
850 const float texX2 = texX1 + tFractionW * visibleFractionW;
853 texX1, texY1, texX2, texY2,
854 dstX, dstY, width, height);
869 const float scaleFactorW =
static_cast<float>(scaledWidth) / iw;
870 const float scaleFactorH =
static_cast<float>(scaledHeight) / ih;
872 for (
int py = 0; py < h; py += scaledHeight)
874 const int height = (py + scaledHeight >= h)
875 ? h - py : scaledHeight;
876 const int dstY =
y + py;
877 const int scaledY = srcY + height / scaleFactorH;
878 for (
int px = 0; px < w; px += scaledWidth)
880 const int width = (px + scaledWidth >= w)
881 ? w - px : scaledWidth;
882 const int dstX =
x + px;
883 const int scaledX = srcX + width / scaleFactorW;
885 mIntTexArray[vp + 0] = srcX;
886 mIntTexArray[vp + 1] = srcY;
888 mIntTexArray[vp + 2] = scaledX;
889 mIntTexArray[vp + 3] = srcY;
891 mIntTexArray[vp + 4] = scaledX;
892 mIntTexArray[vp + 5] = scaledY;
894 mIntTexArray[vp + 6] = srcX;
895 mIntTexArray[vp + 7] = scaledY;
897 mIntVertArray[vp + 0] = dstX;
898 mIntVertArray[vp + 1] = dstY;
900 mIntVertArray[vp + 2] = dstX + width;
901 mIntVertArray[vp + 3] = dstY;
903 mIntVertArray[vp + 4] = dstX + width;
904 mIntVertArray[vp + 5] = dstY + height;
906 mIntVertArray[vp + 6] = dstX;
907 mIntVertArray[vp + 7] = dstY + height;
923 OpenGLGraphicsVertexes
926 const STD_VECTOR<GLint*> &intVertPool = ogl.mIntVertPool;
927 STD_VECTOR<GLint*>::const_iterator iv;
928 const STD_VECTOR<GLint*>::const_iterator iv_end = intVertPool.end();
929 const STD_VECTOR<int> &vp = ogl.mVp;
930 STD_VECTOR<int>::const_iterator ivp;
931 const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
936 const STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
937 STD_VECTOR<GLfloat*>::const_iterator ft;
938 const STD_VECTOR<GLfloat*>::const_iterator
939 ft_end = floatTexPool.end();
941 for (iv = intVertPool.begin(), ft = floatTexPool.begin(),
943 iv != iv_end && ft != ft_end && ivp != ivp_end;
944 ++ iv, ++ ft, ++ ivp)
946 drawQuadArrayfi(*iv, *ft, *ivp);
951 const STD_VECTOR<GLint*> &intTexPool = ogl.mIntTexPool;
952 STD_VECTOR<GLint*>::const_iterator it;
953 const STD_VECTOR<GLint*>::const_iterator it_end = intTexPool.end();
955 for (iv = intVertPool.begin(), it = intTexPool.begin(),
957 iv != iv_end && it != it_end && ivp != ivp_end;
958 ++ iv, ++ it, ++ ivp)
960 drawQuadArrayii(*iv, *it, *ivp);
983 if (image ==
nullptr || vert ==
nullptr)
986 const SDL_Rect &imageRect = image->mBounds;
987 const int iw = imageRect.w;
988 const int ih = imageRect.h;
990 if (iw == 0 || ih == 0)
993 const int srcX = imageRect.x;
994 const int srcY = imageRect.y;
996 const unsigned int vLimit = mMaxVertices * 4;
998 OpenGLGraphicsVertexes &ogl = vert->ogl;
999 unsigned int vp = ogl.continueVp();
1004 const float tw =
static_cast<float>(image->mTexWidth);
1005 const float th =
static_cast<float>(image->mTexHeight);
1006 const float texX1 =
static_cast<float>(srcX) / tw;
1007 const float texY1 =
static_cast<float>(srcY) / th;
1009 GLfloat *floatTexArray = ogl.continueFloatTexArray();
1010 GLint *intVertArray = ogl.continueIntVertArray();
1012 for (
int py = 0; py < h; py += ih)
1014 const int height = (py + ih >= h) ? h - py : ih;
1015 const int dstY =
y + py;
1016 const float texY2 =
static_cast<float>(srcY + height) / th;
1017 for (
int px = 0; px < w; px += iw)
1019 const int width = (px + iw >= w) ? w - px : iw;
1020 const int dstX =
x + px;
1021 const float texX2 =
static_cast<float>(srcX + width) / tw;
1024 texX1, texY1, texX2, texY2,
1025 dstX, dstY, width, height);
1030 floatTexArray = ogl.switchFloatTexArray();
1031 intVertArray = ogl.switchIntVertArray();
1040 GLint *intTexArray = ogl.continueIntTexArray();
1041 GLint *intVertArray = ogl.continueIntVertArray();
1043 for (
int py = 0; py < h; py += ih)
1045 const int height = (py + ih >= h) ? h - py : ih;
1046 const int dstY =
y + py;
1047 for (
int px = 0; px < w; px += iw)
1049 const int width = (px + iw >= w) ? w - px : iw;
1050 const int dstX =
x + px;
1053 srcX, srcY, dstX, dstY, width, height);
1058 intTexArray = ogl.switchIntTexArray();
1059 intVertArray = ogl.switchIntVertArray();
1075 if (vertCol ==
nullptr || image ==
nullptr)
1077 if (vertCol->currentGLImage != image->mGLImage)
1080 vertCol->currentGLImage = image->mGLImage;
1081 vertCol->currentVert = vert;
1082 vert->
image = image;
1083 vertCol->draws.push_back(vert);
1104 #ifdef DEBUG_BIND_TEXTURE
1121 if (vertCol ==
nullptr || image ==
nullptr)
1124 if (vertCol->currentGLImage != image->mGLImage)
1127 vertCol->currentGLImage = image->mGLImage;
1128 vertCol->currentVert = vert;
1129 vert->
image = image;
1130 vertCol->draws.push_back(vert);
1134 vert = vertCol->currentVert;
1154 const SDL_Rect &imageRect = image->mBounds;
1155 const int w = imageRect.w;
1156 const int h = imageRect.h;
1158 if (w == 0 || h == 0)
1161 const int srcX = imageRect.x;
1162 const int srcY = imageRect.y;
1164 const unsigned int vLimit = mMaxVertices * 4;
1166 OpenGLGraphicsVertexes &ogl = vert->
ogl;
1169 unsigned int vp = ogl.continueVp();
1174 const float tw =
static_cast<float>(image->mTexWidth);
1175 const float th =
static_cast<float>(image->mTexHeight);
1177 const float texX1 =
static_cast<float>(srcX) / tw;
1178 const float texY1 =
static_cast<float>(srcY) / th;
1180 const float texX2 =
static_cast<float>(srcX + w) / tw;
1181 const float texY2 =
static_cast<float>(srcY + h) / th;
1183 GLfloat *
const floatTexArray = ogl.continueFloatTexArray();
1184 GLint *
const intVertArray = ogl.continueIntVertArray();
1187 texX1, texY1, texX2, texY2,
1193 ogl.switchFloatTexArray();
1194 ogl.switchIntVertArray();
1201 GLint *
const intTexArray = ogl.continueIntTexArray();
1202 GLint *
const intVertArray = ogl.continueIntVertArray();
1205 srcX, srcY, dstX, dstY, w, h);
1210 ogl.switchIntTexArray();
1211 ogl.switchIntVertArray();
1222 if (vert ==
nullptr)
1227 #ifdef DEBUG_BIND_TEXTURE
1237 const int x,
const int y,
1238 const int w,
const int h,
1243 Image *
const image = imgRect.grid[4];
1244 if (image ==
nullptr)
1246 if (vertCol->currentGLImage != image->mGLImage)
1249 vertCol->currentGLImage = image->mGLImage;
1250 vertCol->currentVert = vert;
1251 vert->
image = image;
1252 vertCol->draws.push_back(vert);
1256 vert = vertCol->currentVert;
1266 #ifdef DEBUG_DRAW_CALLS
1267 mLastDrawCalls = mDrawCalls;
1270 #ifdef DEBUG_BIND_TEXTURE
1271 mLastBinds = mBinds;
1277 SDL_GL_SwapBuffers();
1281 mglFrameTerminator();
1291 glMatrixMode(GL_TEXTURE);
1294 glMatrixMode(GL_PROJECTION);
1297 const int w =
mRect.w;
1298 const int h =
mRect.h;
1301 glOrthof(0.0,
static_cast<float>(w),
1302 static_cast<float>(h),
1306 glOrtho(0.0,
static_cast<double>(w),
1307 static_cast<double>(h),
1311 glMatrixMode(GL_MODELVIEW);
1315 glDisable(GL_LIGHTING);
1317 glDisable(GL_COLOR_MATERIAL);
1319 glEnableClientState(GL_VERTEX_ARRAY);
1320 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1322 glShadeModel(GL_FLAT);
1323 glDepthMask(GL_FALSE);
1325 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1327 glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
1328 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1329 glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
1330 glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
1346 if (!mClipStack.empty())
1348 const ClipRect &clipArea = mClipStack.top();
1355 const ClipRect &clipArea = mClipStack.top();
1359 if (transX != 0 || transY != 0)
1361 glTranslatef(
static_cast<GLfloat
>(transX),
1362 static_cast<GLfloat
>(transY), 0);
1364 glScissor(clipArea.
x * mScale,
1365 (mRect.h - clipArea.
y - clipArea.
height) * mScale,
1366 clipArea.
width * mScale,
1367 clipArea.
height * mScale);
1376 int transX = -clipArea1.
xOffset;
1377 int transY = -clipArea1.
yOffset;
1387 if (transX != 0 || transY != 0)
1389 glTranslatef(
static_cast<GLfloat
>(transX),
1390 static_cast<GLfloat
>(transY), 0);
1392 glScissor(clipArea.
x *
mScale,
1419 mFloatTexArray[0] =
static_cast<float>(x1) + 0.5F;
1420 mFloatTexArray[1] =
static_cast<float>(y1) + 0.5F;
1421 mFloatTexArray[2] =
static_cast<float>(x2) + 0.5F;
1422 mFloatTexArray[3] =
static_cast<float>(y2) + 0.5F;
1442 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
1458 glDisable(GL_BLEND);
1470 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1479 const
float offset = filled ? 0 : 0.5F;
1480 const
float x = static_cast<
float>(rect.
x);
1481 const
float y = static_cast<
float>(rect.
y);
1482 const
float width = static_cast<
float>(rect.width);
1483 const
float height = static_cast<
float>(rect.height);
1490 x + offset,
y + offset,
1491 x + width - offset,
y + offset,
1492 x + width - offset,
y + height - offset,
1493 x + offset,
y + height - offset
1496 glVertexPointer(2, GL_FLOAT, 0, &vert);
1498 #ifdef DEBUG_DRAW_CALLS
1502 glDrawArrays(filled ? GL_QUADS : GL_LINE_LOOP, 0, 4);
1510 const int x2,
const int y2,
1511 const int width,
const int height)
restrict2
1513 unsigned int vp = 0;
1514 const unsigned int vLimit = mMaxVertices * 4;
1519 const float xf1 =
static_cast<float>(x1);
1520 const float xf2 =
static_cast<float>(x2);
1521 const float yf1 =
static_cast<float>(y1);
1522 const float yf2 =
static_cast<float>(y2);
1524 for (
int y = y1;
y < y2;
y += height)
1526 mFloatTexArray[vp + 0] = xf1;
1527 mFloatTexArray[vp + 1] =
static_cast<float>(
y);
1529 mFloatTexArray[vp + 2] = xf2;
1530 mFloatTexArray[vp + 3] =
static_cast<float>(
y);
1540 for (
int x = x1;
x < x2;
x += width)
1542 mFloatTexArray[vp + 0] =
static_cast<float>(
x);
1543 mFloatTexArray[vp + 1] = yf1;
1545 mFloatTexArray[vp + 2] =
static_cast<float>(
x);
1546 mFloatTexArray[vp + 3] = yf2;
1561 const GLuint texture)
1566 glBindTexture(target, texture);
1567 #ifdef DEBUG_BIND_TEXTURE
1576 #ifdef DEBUG_DRAW_CALLS
1580 glDrawArrays(GL_QUADS, 0,
size / 2);
1590 #ifdef DEBUG_DRAW_CALLS
1594 glDrawArrays(GL_QUADS, 0,
size / 2);
1607 glVertexPointer(2, GL_INT, 0, intVertArray);
1608 glTexCoordPointer(2, GL_FLOAT, 0, floatTexArray);
1609 #ifdef DEBUG_DRAW_CALLS
1613 glDrawArrays(GL_QUADS, 0,
size / 2);
1622 #ifdef DEBUG_DRAW_CALLS
1626 glDrawArrays(GL_QUADS, 0,
size / 2);
1636 #ifdef DEBUG_DRAW_CALLS
1640 glDrawArrays(GL_QUADS, 0,
size / 2);
1653 glVertexPointer(2, GL_INT, 0, intVertArray);
1654 glTexCoordPointer(2, GL_INT, 0, intTexArray);
1655 #ifdef DEBUG_DRAW_CALLS
1659 glDrawArrays(GL_QUADS, 0,
size / 2);
1667 glVertexPointer(2, GL_INT, 0, mIntVertArray);
1669 #ifdef DEBUG_DRAW_CALLS
1673 glDrawArrays(GL_LINES, 0,
size / 2);
1681 glVertexPointer(2, GL_FLOAT, 0, mFloatTexArray);
1683 #ifdef DEBUG_DRAW_CALLS
1687 glDrawArrays(GL_LINES, 0,
size / 2);
1698 for (
int f = 0; f < 65535; f ++)
1704 glGetIntegerv(f, &test[0]);
1705 if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
1708 test[0], test[1], test[2], test[3]);
1715 if (!mIsByteColor && mFloatColor == alpha)
1718 glColor4f(1.0F, 1.0F, 1.0F, alpha);
1719 mIsByteColor =
false;
1720 mFloatColor = alpha;
1728 glColor4ub(
static_cast<GLubyte
>(
mColor.
r),
1729 static_cast<GLubyte
>(
mColor.
g),
1730 static_cast<GLubyte
>(
mColor.
b),
1731 static_cast<GLubyte
>(
mColor.
a));
1737 const int w,
const int h,
1745 const int x,
const int y,
1746 const int w,
const int h,
1755 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1758 #ifdef DEBUG_BIND_TEXTURE
1762 const std::string texture = image->mIdPath;
1763 if (mOldTexture != texture)
1765 if ((!mOldTexture.empty() || !texture.empty())
1766 && mOldTextureId != image->mGLImage)
1768 logger->
log(
"bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
1769 mOldTextureId, texture.c_str(), image->mGLImage);
1771 mOldTextureId = image->mGLImage;
1772 mOldTexture = texture;
virtual void updateScreen()=0
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void popClipArea()
virtual void drawRescaledPattern(const Image *const image, const int x, const int y, const int w, const int h, const int scaledWidth, const int scaledHeight)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual bool setVideoMode(const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void drawImageCached(const Image *const image, int srcX, int srcY)=0
virtual void calcPattern(ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const =0
virtual void deleteArrays()
virtual void drawRectangle(const Rect &rectangle)=0
MStack< ClipRect > mClipStack
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void drawLine(int x1, int y1, int x2, int y2)=0
virtual void calcTileVertexes(ImageVertexes *const vert, const Image *const image, int x, int y) const =0
virtual void drawPattern(const Image *const image, const int x, const int y, const int w, const int h)=0
virtual void initArrays(const int vertCount)
virtual void clearScreen() const
virtual void drawPoint(int x, int y)=0
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void copyImage(const Image *const image, int dstX, int dstY)=0
virtual void pushClipArea(const Rect &area)
virtual void drawTileVertexes(const ImageVertexes *const vert)=0
virtual void drawPatternCached(const Image *const image, const int x, const int y, const int w, const int h)=0
virtual void completeCache()=0
virtual void drawNet(const int x1, const int y1, const int x2, const int y2, const int width, const int height)
virtual void drawRescaledImage(const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)=0
OpenGLGraphicsVertexes ogl
void log(const char *const log_text,...)
void drawLineArrayi(const int size) A_INLINE
GLint * mIntVertArrayCached
void drawQuadArrayfi(const int size) A_INLINE
void drawLineArrayf(const int size) A_INLINE
void drawQuadArrayfiCached(const int size) A_INLINE
void drawQuadArrayii(const int size) A_INLINE
void drawQuadArrayiiCached(const int size) A_INLINE
GLfloat * mFloatTexArrayCached
GLint * mIntTexArrayCached
void calcPatternInline(ImageVertexes *restrict const vert, const Image *restrict const image, const int x, const int y, const int w, const int h) const restrict2 A_INLINE
void drawPatternInline(const Image *restrict const image, const int x, const int y, const int w, const int h) restrict2 A_INLINE
void drawRectangle(const Rect &restrict rect) restrict2 override final
void void drawImageInline(const Image *restrict const image, int dstX, int dstY) restrict2 A_INLINE
void calcTileVertexesInline(ImageVertexes *restrict const vert, const Image *restrict const image, int x, int y) const restrict2 A_INLINE A_NONNULL(2
void calcImageRect(ImageVertexes *restrict const vert, int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 A_INLINE
void completeCache() restrict2 override final
GraphicsManager graphicsManager
std::vector< ImageVertexes * > ImageVertexesVector
ImageVertexesVector::const_iterator ImageCollectionCIter
#define isGLNotNull(func)
static void drawQuad(const Image *const image, const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height) A_INLINE
#define vertFillNv(tVar, vVar, srcX, srcY, dstX, dstY, w, h)
static void drawRescaledQuad(const Image *const image, const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, const int desiredHeight) A_INLINE
static void bindPointerIntFloat(const GLint *const vert, const GLfloat *const tex) A_INLINE
#define vertFill2D(tVar, vVar, x1, y1, x2, y2, dstX, dstY, w, h)
static void bindPointerInt(const GLint *const vert, const GLint *const tex) A_INLINE
void enableTexturingAndBlending() restrict2
static GLuint mTextureBinded
void disableTexturingAndBlending() restrict2
static void dumpSettings()
static void bindTexture(const GLenum target, const GLuint texture)
void restoreColor() restrict2 A_INLINE
void setColorAlpha(const float alpha) restrict2 A_INLINE
void deleteArraysInternal() restrict2
void drawVertexes(const OpenGLGraphicsVertexes &restrict ogl) restrict2 A_INLINE
void debugBindTexture(const Image *restrict const image) restrict2
unsigned int vertexBufSize
#define FUNC_BLOCK(name, id)
#define BLOCK_START(name)