当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_RenderDrawPoint函数代码示例

本文整理汇总了C++中SDL_RenderDrawPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_RenderDrawPoint函数的具体用法?C++ SDL_RenderDrawPoint怎么用?C++ SDL_RenderDrawPoint使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_RenderDrawPoint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Shorthand_SDL_RenderDrawCircle

// Circle centred at (cx,cy) of radius r, see :
// http://content.gpwiki.org/index.php/SDL:Tutorials:Drawing_and_Filling_Circles
void Shorthand_SDL_RenderDrawCircle(SDL_Renderer *rend, int cx, int cy, int r)
{

   double dx, dy;
   dx = floor(sqrt((2.0 * r ) ));
   SDL_RenderDrawLine(rend, cx-dx, cy+r, cx+dx, cy+r);
   SDL_RenderDrawLine(rend, cx-dx, cy-r, cx+dx, cy-r);
   for (dy = 1; dy <= r; dy += 1.0) {
        dx = floor(sqrt((2.0 * r * dy) - (dy * dy)));
        SDL_RenderDrawPoint(rend, cx+dx, cy+r-dy);
        SDL_RenderDrawPoint(rend, cx+dx, cy-r+dy);
        SDL_RenderDrawPoint(rend, cx-dx, cy+r-dy);
        SDL_RenderDrawPoint(rend, cx-dx, cy-r+dy);
   }

}
开发者ID:andrewjohnconnell,项目名称:Logo_In_C,代码行数:18,代码来源:sdlShorthand.c

示例2: SDL_SetRenderTarget

void Renderer::drawPixel(const Color &color, int x, int y)
{
    SDL_SetRenderTarget(this->renderer, this->nativeTexture);
    SDL_SetRenderDrawColor(this->renderer, color.getR(), color.getG(),
                           color.getB(), color.getA());
    SDL_RenderDrawPoint(this->renderer, x, y);
}
开发者ID:afritz1,项目名称:OpenTESArena,代码行数:7,代码来源:Renderer.cpp

示例3: DegsToRads

void S013010C_Aaron_Smith_Tank::DrawDebugCircle(Vector2D centrePoint, float radius)
{
	Vector2D polarVec;
	polarVec.x = 0.0f;
	polarVec.y = radius;

	float stepSize = 0.05f;

	float _360DegAsRads = DegsToRads(360.0);

	while (polarVec.x < _360DegAsRads)
	{
		Vector2D polarAsCart;
		polarAsCart.x = polarVec.y * cosf(polarVec.x);
		polarAsCart.y = polarVec.y * sinf(polarVec.x);

		Vector2D drawPoint;
		drawPoint.x = centrePoint.x + polarAsCart.x;
		drawPoint.y = centrePoint.y + polarAsCart.y;

		SDL_SetRenderDrawColor(mRenderer, 0, 0, 0, 255);
		SDL_RenderDrawPoint(mRenderer, drawPoint.x, drawPoint.y);

		polarVec.x += stepSize;
	}

}
开发者ID:CrohnsAndMe,项目名称:Test,代码行数:27,代码来源:S013010C_Aaron_Smith_Tank.cpp

示例4: SDL_SetRenderDrawColor

//Draws a point at the specified coordinates
//param:x->X coordinate of the point
//param:y->Y coordinate of the point
//param:color->Color to draw the point
//returns 0 for success, -1 for errors
int SpriteBatch::DrawPoint(int x, int y, SDL_Color color)
{
	//Check if spritebatch.begin has been called
	if(!begun)
	{
		std::cout<<"Begin must be called before attempting to draw"<<std::endl;
		return -1;
	}

	int result = 0;

	//Set the point color
	result = SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);

	//Check for color setting problems
	if(result != 0)
	{
		std::cout<<"DrawPoint error: Problem setting point color"<<std::endl;
		return result;
	}

	//Draw the point
	result = SDL_RenderDrawPoint(renderer, x, y);

	//Check for drawing problems
	if(result != 0)
	{
		std::cout<<"DrawPoint error: Problem drawing the point"<<std::endl;
		return result;
	}

	//return success
	return result;
}
开发者ID:cs253074,项目名称:SpaceGladiators,代码行数:39,代码来源:SpriteBatch.cpp

示例5: SDL_SetRenderDrawColor

   GraphicsManager& GraphicsManager::DrawPixel (int x, int y, const Color& color)
   {
      SDL_SetRenderDrawColor(device, color.Red(), color.Green(), color.Blue(), color.Alpha());
      SDL_RenderDrawPoint(device, x, y);

      return *this;
   }
开发者ID:cppisfun,项目名称:GameEngine,代码行数:7,代码来源:GraphicsManager.cpp

示例6: SDL_DestroyTexture

void Range::generateTexture(SDL_Renderer * renderer)
{
    if(texture != nullptr)
    {
        SDL_DestroyTexture(texture);
        texture = nullptr;
    }

    setWidth(value * 2);
    setHeight(value * 2);

    SDL_Texture * prevRenderTarget = SDL_GetRenderTarget(renderer);
    texture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_UNKNOWN,SDL_TEXTUREACCESS_TARGET,getWidth(),getHeight());
    SDL_SetTextureBlendMode(texture,SDL_BLENDMODE_BLEND);

    SDL_SetRenderTarget(renderer,texture);
    SDL_SetRenderDrawColor(renderer,0,0,0,0);
    SDL_RenderClear(renderer);
    SDL_SetRenderDrawColor(renderer,255,0,0,255);



    for(double i = 0; i<=360; i+=0.01)
    {
        int x = value + value * cos(i);
        int y = value + value * sin(i);

        SDL_RenderDrawPoint(renderer,x,y);
    }




    SDL_SetRenderTarget(renderer,prevRenderTarget);
}
开发者ID:dgi09,项目名称:Tower-Defence,代码行数:35,代码来源:Range.cpp

示例7: afficherPoint

//Affiche un point aux coordonnées de la souris
void afficherPoint()
{
	static int x, y;
	SDL_GetMouseState(&x, &y);
	SDL_RenderDrawPoint(globalRenderer, x, y);
	SDL_RenderPresent(globalRenderer);
}
开发者ID:ndelanou,项目名称:PCWorms,代码行数:8,代码来源:new++1.c

示例8: render_point

void render_point(renderer *renderer, world *world, int id) {
	position pos = world->positions[id];
	color color = world->colors[id];
	(void)printf("Rendering point %d at %d, %d\n", id, pos.x, pos.y);

	SDL_SetRenderDrawColor(renderer->sdl_renderer, color.r, color.g, color.b, color.a);
	SDL_RenderDrawPoint(renderer->sdl_renderer, pos.x, pos.y);
}
开发者ID:akydd,项目名称:sdl,代码行数:8,代码来源:renderer.c

示例9: renderRadius

void renderRadius(GraphicsData *graphicsData, SDL_Point *point, double radius, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
	double currOffsetX, currOffsetY;
	point->x += graphicsData->navigationOffset.x;
	point->y += graphicsData->navigationOffset.y;

	SDL_SetRenderDrawColor(graphicsData->renderer, r,g,b, a);

    for (currOffsetY = 1; currOffsetY <= radius; currOffsetY ++) {
         currOffsetX = floor(sqrt((2.0 * radius * currOffsetY) - (pow(currOffsetY, 2))));
         SDL_RenderDrawPoint(graphicsData->renderer, point->x - currOffsetX, point->y + radius - currOffsetY);
         SDL_RenderDrawPoint(graphicsData->renderer, point->x - currOffsetX, point->y - radius + currOffsetY);
         SDL_RenderDrawPoint(graphicsData->renderer, point->x + currOffsetX, point->y + radius - currOffsetY);
         SDL_RenderDrawPoint(graphicsData->renderer, point->x + currOffsetX, point->y - radius + currOffsetY);
    }

}
开发者ID:Syreniac,项目名称:verdant-octo-spork,代码行数:17,代码来源:graphics.c

示例10: drawBetweenPoints

/* this is as low as it gets. slams pixels onto surface */
static void drawBetweenPoints(SDL_Point* p1, SDL_Point* p2, SDL_Color c, int w) {
	double divDiff;
	bool yLonger = false;
	int incrementVal;
	int shortLen;
	int longLen;
	int i;

	if (!p1 || !p2) {
		return;
	}

	shortLen = p2->y - p1->y;
	longLen = p2->x - p1->x;

	//determine long
	if (abs(shortLen)>abs(longLen)) {
		int swap = shortLen;
		shortLen = longLen;
		longLen = swap;
		yLonger = true;
	}

	if (longLen<0) incrementVal = -1;
	else incrementVal = 1;

	if (shortLen == 0) divDiff = longLen;
	else divDiff = (double)longLen / (double)shortLen;

	//ok time to draw
	SDL_SetRenderDrawColor(global_renderer, c.r, c.g, c.b, 255);
	if (yLonger) {
		for (i = 0; i != longLen; i += incrementVal) {
			int x = p1->x + (int)((double)i / divDiff) + gDrawOffset_x;
			int y = p1->y + i + gDrawOffset_y;
			SDL_RenderDrawPoint(global_renderer, x, y);
		}
	}
	else {
		for (i = 0; i != longLen; i += incrementVal) {
			int x = p1->x + i + gDrawOffset_x;
			int y = p1->y + (int)((double)i / divDiff) + gDrawOffset_y;
			SDL_RenderDrawPoint(global_renderer, x, y);
		}
	}
}
开发者ID:dvranizan,项目名称:dione,代码行数:47,代码来源:draw.c

示例11: LOBJECT_METHOD

		int LOBJECT_METHOD(drawPoint, SDL_Renderer * renderer){
			if (state.is_number(1) && state.is_number(2)){
				state.push_boolean(SDL_RenderDrawPoint(renderer, state.to_integer(1), state.to_integer(2)) == 0);
				return 1;
			}else{
				return 0;
			}
		}
开发者ID:swc4848a,项目名称:LuaSDL-2.0,代码行数:8,代码来源:renderer.hpp

示例12: SDL_GetWindowSize

void Circle::draw()
{
	int window_w, window_h;
	SDL_GetWindowSize(window, &window_w, &window_h);

	std::vector<SDL_Point> draw_points;

	// get drawing area of circle and don't draw outside the window
	int tlx = position.x - radius;
	tlx = tlx >= 0? tlx : 0;
	int tly = position.y - radius;
	tly = tly >= 0? tly : 0;
	int brx = position.x + radius;
	brx = brx <= window_w? brx : window_w;
	int bry = position.y + radius;
	bry = bry <= window_h? bry : window_h;

	// for each pixel in this area
	for(int x = tlx; x <= brx; x++)
	{
		for(int y = tly; y <= bry; y++)
		{
			// get distance between this pixel and the center of the circle
			int x_length = abs(position.x - x);
			int y_length = abs(position.y - y);
			double r = sqrt(x_length*x_length + y_length*y_length);

			// if this circle is in range (ceilinged)
			if(ceil(r) <= radius+1)
			{
				// draw it, with anti aliasing if i'm at the very edge of the circle and the radius doesn't fully reach this pixel
				int anti_alias = 0;
				if(r > radius)
				{
					anti_alias = floor(double(255) * (r - double(radius)));
				}

				// draw each anti-aliased pixel separately
				if(anti_alias > 0)
				{
					SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a - anti_alias > 0? color.a - anti_alias : 0);
					SDL_RenderDrawPoint(renderer, x, y);
				}
				// non anti-aliased pixels will be drawn all at once using RenderDrawPoints
				else
				{
					SDL_Point p;
					p.x = x;
					p.y = y;
					draw_points.push_back(p);
				}
			}
		}
	}

	SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
	SDL_RenderDrawPoints(renderer, &draw_points[0], draw_points.size());
}
开发者ID:epark009,项目名称:gravity_genetic_algorithm,代码行数:58,代码来源:Circle.cpp

示例13: SDL_SetRenderTarget

/*
 * Set the pixel at (x, y) to the given value
 */
void SDLHardwareImage::drawPixel(int x, int y, const Color& color) {
	if (!surface) return;

	SDL_SetRenderTarget(renderer, surface);
	SDL_SetTextureBlendMode(surface, SDL_BLENDMODE_BLEND);
	SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
	SDL_RenderDrawPoint(renderer, x, y);
	SDL_SetRenderTarget(renderer, NULL);
}
开发者ID:clintbellanger,项目名称:flare-engine,代码行数:12,代码来源:SDLHardwareRenderDevice.cpp

示例14: caml_SDL_RenderDrawPoint2

CAMLprim value
caml_SDL_RenderDrawPoint2(value renderer, value x, value y)
{
    int r = SDL_RenderDrawPoint(
                SDL_Renderer_val(renderer),
                Int_val(x), Int_val(y));
    if (r) caml_failwith("Sdlrender.draw_point2");
    return Val_unit;
}
开发者ID:fccm,项目名称:OCamlSDL2,代码行数:9,代码来源:sdlrender_stub.c

示例15: SDL_SetRenderDrawColor

void Bullet::Render()
{
    if(alive)
    {
        //  Render and color
        SDL_SetRenderDrawColor(m_renderer, 255, 255, 255, 255);
        SDL_RenderDrawPoint(m_renderer,points[0].x,points[0].y);
    }
}
开发者ID:szganev,项目名称:CPP-SDL-development,代码行数:9,代码来源:Bullet.cpp


注:本文中的SDL_RenderDrawPoint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。