summaryrefslogtreecommitdiffhomepage
path: root/src/shapes.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2014-09-16 22:51:31 +0200
committerraysan5 <[email protected]>2014-09-16 22:51:31 +0200
commitfc6081fe70ab7c3b037c0ab9f38478904d3cdde2 (patch)
tree6635fd800fa673ef3fb568c6f47ebc76a2b8ad6e /src/shapes.c
parent01651af08a494b1ac08c897695891ad7cf44ad47 (diff)
downloadraylib-fc6081fe70ab7c3b037c0ab9f38478904d3cdde2.tar.gz
raylib-fc6081fe70ab7c3b037c0ab9f38478904d3cdde2.zip
raylib 1.2
This is a huge update. Check CHANGELOG for details
Diffstat (limited to 'src/shapes.c')
-rw-r--r--src/shapes.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/src/shapes.c b/src/shapes.c
index 17210f21..6fa26bee 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -1,10 +1,10 @@
-/*********************************************************************************************
+/**********************************************************************************************
*
* raylib.shapes
*
* Basic functions to draw 2d Shapes and check collisions
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - [email protected])
+* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -31,11 +31,6 @@
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
-// Security check in case no USE_OPENGL_* defined
-#if !defined(USE_OPENGL_11) && !defined(USE_OPENGL_33) && !defined(USE_OPENGL_ES2)
- #define USE_OPENGL_11
-#endif
-
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@@ -185,43 +180,44 @@ void DrawRectangleGradient(int posX, int posY, int width, int height, Color colo
// Draw a color-filled rectangle (Vector version)
void DrawRectangleV(Vector2 position, Vector2 size, Color color)
{
-#ifdef USE_OPENGL_11
- rlBegin(RL_TRIANGLES);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- rlVertex2i(position.x, position.y);
- rlVertex2i(position.x, position.y + size.y);
- rlVertex2i(position.x + size.x, position.y + size.y);
+ if (rlGetVersion() == OPENGL_11)
+ {
+ rlBegin(RL_TRIANGLES);
+ rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2i(position.x, position.y);
- rlVertex2i(position.x + size.x, position.y + size.y);
- rlVertex2i(position.x + size.x, position.y);
- rlEnd();
-#endif
+ rlVertex2i(position.x, position.y);
+ rlVertex2i(position.x, position.y + size.y);
+ rlVertex2i(position.x + size.x, position.y + size.y);
-#if defined(USE_OPENGL_33) || defined(USE_OPENGL_ES2)
- // NOTE: This shape uses QUADS to avoid drawing order issues (view rlglDraw)
- rlEnableTexture(1); // Default white texture
+ rlVertex2i(position.x, position.y);
+ rlVertex2i(position.x + size.x, position.y + size.y);
+ rlVertex2i(position.x + size.x, position.y);
+ rlEnd();
+ }
+ else if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20))
+ {
+ // NOTE: This shape uses QUADS to avoid drawing order issues (view rlglDraw)
+ rlEnableTexture(1); // Default white texture
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
- rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+ rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
- rlTexCoord2f(0.0f, 0.0f);
- rlVertex2f(position.x, position.y);
+ rlTexCoord2f(0.0f, 0.0f);
+ rlVertex2f(position.x, position.y);
- rlTexCoord2f(0.0f, 1.0f);
- rlVertex2f(position.x, position.y + size.y);
+ rlTexCoord2f(0.0f, 1.0f);
+ rlVertex2f(position.x, position.y + size.y);
- rlTexCoord2f(1.0f, 1.0f);
- rlVertex2f(position.x + size.x, position.y + size.y);
+ rlTexCoord2f(1.0f, 1.0f);
+ rlVertex2f(position.x + size.x, position.y + size.y);
- rlTexCoord2f(1.0f, 0.0f);
- rlVertex2f(position.x + size.x, position.y);
- rlEnd();
+ rlTexCoord2f(1.0f, 0.0f);
+ rlVertex2f(position.x + size.x, position.y);
+ rlEnd();
- rlDisableTexture();
-#endif
+ rlDisableTexture();
+ }
}
// Draw rectangle outline
@@ -457,4 +453,4 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
}
return retRec;
-}
+} \ No newline at end of file