Commits

Bart van Strien committed ed39142

Add getColor to love.graphics.sdl

  • Participants
  • Parent commits 1c8a41c

Comments (0)

Files changed (5)

platform/nlove/CMakeLists.txt

 
 set(PHYSFS_INCLUDE /usr/include/)
 set(PHYSFS_LIBRARY physfs)
-set(LUA_INCLUDE /usr/include/lua5.1)
-set(LUA_LIBRARY lua5.1)
+set(LUA_INCLUDE /usr/include/)
+set(LUA_LIBRARY lua)
 set(SDL_INCLUDE /usr/include/SDL)
 set(SDL_LIBRARY SDL SDL_image SDL_gfx SDL_mixer)
 set(FREETYPE_INCLUDE /usr/include/freetype2)

src/modules/graphics/sdl/Graphics.cpp

 		color.b = b;
 		color.a = a;
 	}
+	
+	Color Graphics::getColor() const
+	{
+		return color;
+	}
 
 	void Graphics::setBackgroundColor(int r, int g, int b)
 	{

src/modules/graphics/sdl/Graphics.h

 
 // General
 #include <iostream>
+#include <stdint.h>
 
 // SDL
 #include <SDL.h>
 {
 namespace sdl
 {
+	struct Color
+	{
+		uint8_t r, g, b, a;
+	};
+	
 	class Graphics : public love::graphics::Graphics
 	{
 	private:
-		struct
-		{
-			uint8_t r, g, b, a;
-		} color, backgroundColor;
+		Color color, backgroundColor;
 		struct
 		{
 			int w, h;
 		void present();
 		void clear();
 		void setColor(int r, int g, int b, int a);
+		Color getColor() const;
 		void setBackgroundColor(int r, int g, int b);
 		bool isCreated();
 		void rectangle(DrawMode mode, int x, int y, int width, int height);

src/modules/graphics/sdl/wrap_Graphics.cpp

 		instance->setColor(r, g, b, a);
 		return 0;
 	}
+	
+	int w_getColor(lua_State * L)
+	{
+		Color c = instance->getColor();
+		lua_pushinteger(L, c.r);
+		lua_pushinteger(L, c.g);
+		lua_pushinteger(L, c.b);
+		lua_pushinteger(L, c.a);
+		return 4;
+	}
 
 	int w_setBackgroundColor(lua_State * L)
 	{
 		{ "clear", w_clear },
 		{ "setBackgroundColor", w_setBackgroundColor },
 		{ "setColor", w_setColor },
+		{ "getColor", w_getColor },
 		{ "rectangle", w_rectangle },
 		{ "circle", w_circle },
 		{ "line", w_line },

src/modules/graphics/sdl/wrap_Graphics.h

 	int w_checkMode(lua_State * L);
 	int w_getModes(lua_State * L);
 	int w_setColor(lua_State * L);
+	int w_getColor(lua_State * L);
 	int w_setBackgroundColor(lua_State * L);
 	int w_rectangle(lua_State * L);
 	int w_circle(lua_State * L);