Merge 4b28f75aeb into 67359073ca
This commit is contained in:
commit
258636490f
25
src/rlgl.h
25
src/rlgl.h
|
|
@ -264,6 +264,7 @@
|
||||||
#define RL_TEXTURE 0x1702 // GL_TEXTURE
|
#define RL_TEXTURE 0x1702 // GL_TEXTURE
|
||||||
|
|
||||||
// Primitive assembly draw modes
|
// Primitive assembly draw modes
|
||||||
|
#define RL_POINTS 0x0000 // GL_POINTS
|
||||||
#define RL_LINES 0x0001 // GL_LINES
|
#define RL_LINES 0x0001 // GL_LINES
|
||||||
#define RL_TRIANGLES 0x0004 // GL_TRIANGLES
|
#define RL_TRIANGLES 0x0004 // GL_TRIANGLES
|
||||||
#define RL_QUADS 0x0007 // GL_QUADS
|
#define RL_QUADS 0x0007 // GL_QUADS
|
||||||
|
|
@ -1461,6 +1462,7 @@ void rlBegin(int mode)
|
||||||
{
|
{
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
case RL_POINTS: glBegin(GL_POINTS); break;
|
||||||
case RL_LINES: glBegin(GL_LINES); break;
|
case RL_LINES: glBegin(GL_LINES); break;
|
||||||
case RL_TRIANGLES: glBegin(GL_TRIANGLES); break;
|
case RL_TRIANGLES: glBegin(GL_TRIANGLES); break;
|
||||||
case RL_QUADS: glBegin(GL_QUADS); break;
|
case RL_QUADS: glBegin(GL_QUADS); break;
|
||||||
|
|
@ -1493,7 +1495,8 @@ void rlBegin(int mode)
|
||||||
// It implies adding some extra alignment vertex at the end of the draw,
|
// It implies adding some extra alignment vertex at the end of the draw,
|
||||||
// those vertex are not processed but they are considered as an additional offset
|
// those vertex are not processed but they are considered as an additional offset
|
||||||
// for the next set of vertex to be drawn
|
// for the next set of vertex to be drawn
|
||||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4);
|
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_POINTS) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount & 3)) & 3;
|
||||||
|
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4);
|
||||||
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4)));
|
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4)));
|
||||||
else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
|
else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
|
||||||
|
|
||||||
|
|
@ -1542,7 +1545,15 @@ void rlVertex3f(float x, float y, float z)
|
||||||
// Checking current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4
|
// Checking current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4
|
||||||
if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
|
if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
|
||||||
{
|
{
|
||||||
if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) &&
|
if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_POINTS) &&
|
||||||
|
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount != 0))
|
||||||
|
{
|
||||||
|
// Reached the maximum number of vertices for RL_POINTS drawing
|
||||||
|
// Launch a draw call but keep current state for next vertices comming
|
||||||
|
// NOTE: Adding +1 vertex to the check for some safety
|
||||||
|
rlCheckRenderBatchLimit(1 + 1);
|
||||||
|
}
|
||||||
|
else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) &&
|
||||||
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%2 == 0))
|
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%2 == 0))
|
||||||
{
|
{
|
||||||
// Reached the maximum number of vertices for RL_LINES drawing
|
// Reached the maximum number of vertices for RL_LINES drawing
|
||||||
|
|
@ -1697,7 +1708,8 @@ void rlSetTexture(unsigned int id)
|
||||||
// It implies adding some extra alignment vertex at the end of the draw,
|
// It implies adding some extra alignment vertex at the end of the draw,
|
||||||
// those vertex are not processed but they are considered as an additional offset
|
// those vertex are not processed but they are considered as an additional offset
|
||||||
// for the next set of vertex to be drawn
|
// for the next set of vertex to be drawn
|
||||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4);
|
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_POINTS) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount & 3)) & 3;
|
||||||
|
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4);
|
||||||
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4)));
|
else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4)));
|
||||||
else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
|
else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
|
||||||
|
|
||||||
|
|
@ -2044,7 +2056,7 @@ float rlGetLineWidth(void)
|
||||||
// Set the point drawing size
|
// Set the point drawing size
|
||||||
void rlSetPointSize(float size)
|
void rlSetPointSize(float size)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
||||||
glPointSize(size);
|
glPointSize(size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -2053,7 +2065,7 @@ void rlSetPointSize(float size)
|
||||||
float rlGetPointSize(void)
|
float rlGetPointSize(void)
|
||||||
{
|
{
|
||||||
float size = 1;
|
float size = 1;
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
||||||
glGetFloatv(GL_POINT_SIZE, &size);
|
glGetFloatv(GL_POINT_SIZE, &size);
|
||||||
#endif
|
#endif
|
||||||
return size;
|
return size;
|
||||||
|
|
@ -3143,7 +3155,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
||||||
// Bind current draw call texture, activated as GL_TEXTURE0 and bound to sampler2D texture0 by default
|
// Bind current draw call texture, activated as GL_TEXTURE0 and bound to sampler2D texture0 by default
|
||||||
glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId);
|
glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId);
|
||||||
|
|
||||||
if ((batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount);
|
if ((batch->draws[i].mode == RL_POINTS) || (batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33)
|
#if defined(GRAPHICS_API_OPENGL_33)
|
||||||
|
|
@ -5062,6 +5074,7 @@ static void rlLoadShaderDefault(void)
|
||||||
" fragTexCoord = vertexTexCoord; \n"
|
" fragTexCoord = vertexTexCoord; \n"
|
||||||
" fragColor = vertexColor; \n"
|
" fragColor = vertexColor; \n"
|
||||||
" gl_Position = mvp*vec4(vertexPosition, 1.0); \n"
|
" gl_Position = mvp*vec4(vertexPosition, 1.0); \n"
|
||||||
|
" gl_PointSize = 1.0; \n" // Some systems set PointSize as 0.0 by default
|
||||||
"} \n";
|
"} \n";
|
||||||
|
|
||||||
// Fragment shader directly defined, no external file required
|
// Fragment shader directly defined, no external file required
|
||||||
|
|
|
||||||
|
|
@ -195,18 +195,13 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a point in 3D space, actually a small line
|
// Draw a point in 3D space
|
||||||
// WARNING: OpenGL ES 2.0 does not support point mode drawing
|
|
||||||
void DrawPoint3D(Vector3 position, Color color)
|
void DrawPoint3D(Vector3 position, Color color)
|
||||||
{
|
{
|
||||||
rlPushMatrix();
|
rlBegin(RL_POINTS);
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
rlBegin(RL_LINES);
|
rlVertex3f(position.x, position.y, position.z);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlEnd();
|
||||||
rlVertex3f(0.0f, 0.0f, 0.0f);
|
|
||||||
rlVertex3f(0.0f, 0.0f, 0.1f);
|
|
||||||
rlEnd();
|
|
||||||
rlPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a circle in 3D world space
|
// Draw a circle in 3D world space
|
||||||
|
|
|
||||||
|
|
@ -128,45 +128,10 @@ void DrawPixel(int posX, int posY, Color color)
|
||||||
// Draw a pixel (Vector version)
|
// Draw a pixel (Vector version)
|
||||||
void DrawPixelV(Vector2 position, Color color)
|
void DrawPixelV(Vector2 position, Color color)
|
||||||
{
|
{
|
||||||
#if SUPPORT_QUADS_DRAW_MODE
|
rlBegin(RL_POINTS);
|
||||||
rlSetTexture(GetShapesTexture().id);
|
|
||||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
|
||||||
|
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(shapeRect.x/texShapes.width, shapeRect.y/texShapes.height);
|
|
||||||
rlVertex2f(position.x, position.y);
|
rlVertex2f(position.x, position.y);
|
||||||
|
|
||||||
rlTexCoord2f(shapeRect.x/texShapes.width, (shapeRect.y + shapeRect.height)/texShapes.height);
|
|
||||||
rlVertex2f(position.x, position.y + 1);
|
|
||||||
|
|
||||||
rlTexCoord2f((shapeRect.x + shapeRect.width)/texShapes.width, (shapeRect.y + shapeRect.height)/texShapes.height);
|
|
||||||
rlVertex2f(position.x + 1, position.y + 1);
|
|
||||||
|
|
||||||
rlTexCoord2f((shapeRect.x + shapeRect.width)/texShapes.width, shapeRect.y/texShapes.height);
|
|
||||||
rlVertex2f(position.x + 1, position.y);
|
|
||||||
|
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
||||||
rlSetTexture(0);
|
|
||||||
#else
|
|
||||||
rlBegin(RL_TRIANGLES);
|
|
||||||
|
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
|
||||||
|
|
||||||
rlVertex2f(position.x, position.y);
|
|
||||||
rlVertex2f(position.x, position.y + 1);
|
|
||||||
rlVertex2f(position.x + 1, position.y);
|
|
||||||
|
|
||||||
rlVertex2f(position.x + 1, position.y);
|
|
||||||
rlVertex2f(position.x, position.y + 1);
|
|
||||||
rlVertex2f(position.x + 1, position.y + 1);
|
|
||||||
|
|
||||||
rlEnd();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a line (using gl lines)
|
// Draw a line (using gl lines)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user