1. Bart van Strien
  2. love-experiments

Commits

Alex Szpakowski  committed fc10e87

Removed love.graphics.points (no use in having unnecessary API changes.)

  • Participants
  • Parent commits 26b1264
  • Branches GLES2-compatibility

Comments (0)

Files changed (9)

File src/modules/graphics/opengl/Context.cpp

View file
 	return glattrib->second;
 }
 
-void Context::useVertexAttribArray(unsigned int attrib, bool use)
+void Context::setVertexAttribArray(unsigned int attrib, bool enable)
 {
 	if (attrib == ATTRIB_NONE)
 		return;
 
 	// is this attribute already set to the state we want?
 	std::map<unsigned int, bool>::const_iterator attribenabled = state.enabledVertexAttribArrays.find(attrib);
-	if (attribenabled != state.enabledVertexAttribArrays.end() && attribenabled->second == use)
+	if (attribenabled != state.enabledVertexAttribArrays.end() && attribenabled->second == enable)
 		return;
 
 	// get the internal OpenGL representation for this attribute, if it exists
 
 	if (isGenericVertexAttrib(attrib))
 	{
-		if (use)
+		if (enable)
 			glEnableVertexAttribArray(glattrib);
 		else
 			glDisableVertexAttribArray(glattrib);
 	}
 	else
 	{
-		if (use)
+		if (enable)
 			glEnableClientState(glattrib);
 		else
 			glDisableClientState(glattrib);
 	}
 
 	// save the attribute's state
-	state.enabledVertexAttribArrays[attrib] = use;
+	state.enabledVertexAttribArrays[attrib] = enable;
 }
 
 void Context::useVertexAttribArrays(unsigned int attribs)
 	{
 		unsigned int attrib = 1u << i;
 		bool enable = (attribs & attrib) != 0;
-		useVertexAttribArray(attrib, enable);
+		setVertexAttribArray(attrib, enable);
 	}
 }
 

File src/modules/graphics/opengl/Context.h

View file
 	 *
 	 * @param attrib The vertex attribute to change the active state of (see
 	 * VertexAttribType.)
-	 * @param use Whether to enable or disable this vertex attribute for the
+	 * @param enable Whether to enable or disable this vertex attribute for the
 	 * array.
 	 **/
-	void useVertexAttribArray(unsigned int attrib, bool use);
+	void setVertexAttribArray(unsigned int attrib, bool enable);
 
 	/**
 	 * Sets the per-vertex attributes used when rendering a vertex array.

File src/modules/graphics/opengl/Graphics.cpp

View file
  * Primitives
  **/
 
-void Graphics::points(const float *coords, size_t count)
+void Graphics::point(float x, float y)
 {
+	float coord[] = {x, y};
+
 	Context *ctx = getContext();
 
 	ctx->bindTexture(0);
 	ctx->useVertexAttribArrays(Context::ATTRIB_VERTEX);
-	ctx->vertexAttribPointer(Context::ATTRIB_VERTEX, 2, GL_FLOAT, 0, coords);
+	ctx->vertexAttribPointer(Context::ATTRIB_VERTEX, 2, GL_FLOAT, 0, coord);
 
 	ctx->setupRender();
-	glDrawArrays(GL_POINTS, 0, count / 2);
+	glDrawArrays(GL_POINTS, 0, 1);
 }
 
 // Calculate line boundary points u1 and u2. Sketch:
 }
 
 // precondition:
-// context->useVertexAttribArray(ATTRIB_VERTEX, true);
+// context->setVertexAttribArray(ATTRIB_VERTEX, true);
 static void draw_overdraw(Vector *overdraw, size_t count, float pixel_size, bool looping)
 {
 	// if not looping, the outer overdraw vertices need to be displaced
 	}
 
 	// draw faded out line halos
-	ctx->useVertexAttribArray(Context::ATTRIB_COLOR, true);
+	ctx->setVertexAttribArray(Context::ATTRIB_COLOR, true);
 
 	ctx->vertexAttribPointer(Context::ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, 0, colors);
 	ctx->vertexAttribPointer(Context::ATTRIB_VERTEX, 2, GL_FLOAT, 0, (const GLvoid *)overdraw);

File src/modules/graphics/opengl/Graphics.h

View file
 	void printf(const char *str, float x, float y, float wrap, AlignMode align);
 
 	/**
-	 * Draws a series of points using the given vertices.
-	 * @param coords Vertex components (x1, y1, ..., xn, yn).
-	 * @param count Number of items in the array, i.e. count = 2 * n
+	 * Draws a point at (x,y).
+	 * @param x Point along x-axis.
+	 * @param y Point along y-axis.
 	 **/
-	void points(const float *coords, size_t count);
+	void point(float x, float y);
 
 	/**
 	 * Draws a series of lines connecting the given vertices.

File src/modules/graphics/opengl/SpriteBatch.cpp

View file
 	// Apply per-sprite color, if a color is set.
 	if (color)
 	{
-		ctx->useVertexAttribArray(Context::ATTRIB_COLOR, true);
+		ctx->setVertexAttribArray(Context::ATTRIB_COLOR, true);
 		ctx->vertexAttribPointer(Context::ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, sizeof(vertex), array_buf->getPointer(color_offset));
 	}
 

File src/modules/graphics/opengl/wrap_Graphics.cpp

View file
 	return 0;
 }
 
-int w_points(lua_State *L)
+int w_point(lua_State *L)
 {
-	int args = lua_gettop(L);
-
-	bool is_table = false;
-	if (args == 1 && lua_istable(L, 1))
-	{
-		args = lua_objlen(L, 1);
-		is_table = true;
-	}
-	if (args % 2 != 0)
-		return luaL_error(L, "Number of vertices must be a multiple of two");
-
-	float *coords = new float[args];
-
-	if (is_table)
-	{
-		for (int i = 0; i < args; ++i)
-		{
-			lua_pushnumber(L, i + 1);
-			lua_rawget(L, 1);
-			coords[i] = luax_tofloat(L, -1);
-			lua_pop(L, 1);
-		}
-	}
-	else
-	{
-		for (int i = 0; i < args; ++i)
-			coords[i] = luax_tofloat(L, i + 1);
-	}
-
-	instance->points(coords, args);
-
-	delete[] coords;
+	float x = (float)luaL_checknumber(L, 1);
+	float y = (float)luaL_checknumber(L, 2);
+	instance->point(x, y);
 	return 0;
 }
 
 	{ "setStencil", w_setStencil },
 	{ "setInvertedStencil", w_setInvertedStencil },
 
-	{ "points", w_points },
+	{ "point", w_point },
 	{ "line", w_line },
 	{ "triangle", w_triangle },
 	{ "rectangle", w_rectangle },

File src/modules/graphics/opengl/wrap_Graphics.h

View file
 int w_drawq(lua_State *L);
 int w_print(lua_State *L);
 int w_printf(lua_State *L);
-int w_points(lua_State *L);
+int w_point(lua_State *L);
 int w_line(lua_State *L);
 int w_triangle(lua_State *L);
 int w_rectangle(lua_State *L);

File src/scripts/graphics.lua

View file
 		return love.graphics.printf(...)
 	end
 
-	function love.graphics.point(x, y)
-		return love.graphics.points(x, y)
-	end
-
 
 	-- SHADERS
 

File src/scripts/graphics.lua.h

View file
 	0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 
 	0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 
-	0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x29, 0x0a,
-	0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 
-	0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x29, 0x0a,
-	0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x2d, 0x2d, 0x20, 0x53, 0x48, 0x41, 0x44, 0x45, 0x52, 0x53, 0x0a,
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x47, 0x4c, 0x53, 0x4c, 0x5f, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 
 	0x4e, 0x20, 0x3d, 0x20, 0x22, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x32, 0x30, 0x22, 0x0a,