本文整理汇总了C++中SDL_RenderDrawLine函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_RenderDrawLine函数的具体用法?C++ SDL_RenderDrawLine怎么用?C++ SDL_RenderDrawLine使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_RenderDrawLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SetRenderDrawColor
void
SDLRenderer::renderLine(const vec2& start, const vec2& end, const Color& color) {
SDL_SetRenderDrawColor(_renderer,
color.red * 255,
color.green * 255,
color.blue * 255,
color.alpha * 255);
auto p1 = AffineTransform::applyTransform(_origin, start);
auto p2 = AffineTransform::applyTransform(_origin, end);
SDL_RenderDrawLine(_renderer,
p1.x,
p1.y,
p2.x,
p2.y);
}
示例2: ngui_render_flowbox_connection
void ngui_render_flowbox_connection(ngui_flowbox_connection_data *d)
{
int input_flowbox = d->input_port_flowbox;
int input_port = d->input_port_number;
int output_flowbox = d->output_port_flowbox;
int output_port = d->output_port_number;
double ix = input_port_x (&ngui_flowboxs[input_flowbox] ,input_port);
double iy = input_port_y (&ngui_flowboxs[input_flowbox] ,input_port);
double ox = output_port_x(&ngui_flowboxs[output_flowbox],output_port);
double oy = output_port_y(&ngui_flowboxs[output_flowbox],output_port);
SDL_RenderDrawLine(ngui_renderer,
ix,
iy,
ox,
oy);
int delta=0;
if(ox < ix) delta= 1;
else delta=-1;
if(flow_running)
{
double m = (oy-iy) / (ox-ix);
int n=0;
for(int x=ox; x!=ix; x+=delta)
{
SDL_Rect rect;
rect.x = x;
rect.y = (m*(x-ox))+oy-4;
rect.w = 8;//-((n+(flow_run_count/50))%10);
rect.h = 8;//-((n+(flow_run_count/50))%10);
if(n%15 == ((flow_run_count/50)%15)) SDL_RenderDrawRect(ngui_renderer,&rect);
n++;
}
ngui_redraw_required();
flow_run_count++;
}
}
示例3: SDL_RenderDrawLine
void Path::Render(SDL_Renderer* renderer)
{
if (!m_Points.empty())
{
if (m_Points.size() > 1)
{
for (int i = 0; i < m_Points.size(); i++)
{
if (m_Points[i] != m_Points.back())
{
SDL_RenderDrawLine(renderer, m_Points[i]->x, m_Points[i]->y, m_Points[i + 1]->x, m_Points[i + 1]->y);
}
}
}
}
}
示例4: drawEffects
void drawEffects(void)
{
int i;
Effect *e;
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
for (i = 0, e = effectsToDraw[i] ; e != NULL ; e = effectsToDraw[++i])
{
SDL_SetRenderDrawColor(app.renderer, e->r, e->g, e->b, e->a);
SDL_SetTextureBlendMode(e->texture, SDL_BLENDMODE_ADD);
SDL_SetTextureAlphaMod(e->texture, e->a);
switch (e->type)
{
case EFFECT_POINT:
SDL_RenderDrawPoint(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y);
break;
case EFFECT_LINE:
SDL_RenderDrawLine(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y, e->x + (e->dx * 3) - battle.camera.x, e->y + (e->dy * 3) - battle.camera.y);
break;
case EFFECT_TEXTURE:
SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
blitScaled(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->size, e->size, 0);
break;
case EFFECT_HALO:
SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
blitScaled(e->texture, e->x - battle.camera.x - (e->size / 2), e->y - battle.camera.y - (e->size / 2), e->size, e->size, 0);
break;
case EFFECT_ECM:
SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
blitScaled(e->texture, SCREEN_WIDTH / 2 - (e->size / 2), SCREEN_HEIGHT / 2 - (e->size / 2), e->size, e->size, 0);
break;
}
}
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
}
示例5: SDL_GetWindowPixelFormat
void SDLHardwareRenderDevice::drawLine(
int x0,
int y0,
int x1,
int y1,
Uint32 color
) {
Uint32 u_format = SDL_GetWindowPixelFormat(window);
SDL_PixelFormat* format = SDL_AllocFormat(u_format);
if (!format) return;
SDL_Color rgba;
SDL_GetRGBA(color, format, &rgba.r, &rgba.g, &rgba.b, &rgba.a);
SDL_FreeFormat(format);
SDL_SetRenderDrawColor(renderer, rgba.r, rgba.g, rgba.b, rgba.a);
SDL_RenderDrawLine(renderer, x0, y0, x1, y1);
}
示例6: SimDebugDraw
void SimDebugDraw(SDL_Renderer *r, float t)
{
auto it = GetPotentialField(t);
int w = it->w;
int *next = &it->next[0];
for (int i = 0; i < w * it->h; ++i)
{
int j = next[i];
if (j == -1) continue;
float x0 = float(i % w);
float y0 = float(i / w);
float x1 = float(j % w);
float y1 = float(j / w);
float sx0, sy0, sx1, sy1;
g_world->WorldToScreen(sx0, sy0, x0, y0);
g_world->WorldToScreen(sx1, sy1, x1, y1);
SDL_RenderDrawLine(r, (int)sx0, (int)sy0, (int)sx1, (int)sy1);
}
}
示例7: draw
void draw(){
//SDL_SetRenderDrawColor(render, 128, 128, 128, 255);
//SDL_RenderClear(render);
SDL_RenderCopy( render, tempTex, &SrcR, &DestR);
int mouseX,mouseY;
SDL_GetMouseState( &mouseX, &mouseY );
double dfdx=0,dfdy=0;
double x = i2x( mouseX );
double y = i2y( mouseY );
double f = warped_function( x, y, dfdx, dfdy );
SDL_SetRenderDrawColor(render, 255, 0, 0, 255);
SDL_RenderDrawLine ( render, x2i( x ), y2i( y ), x2i( x - dfdx ), y2i( y - dfdy ) );
//printf( " %f %f %f %f \n", x, y, dfdx, dfdy );
SDL_RenderPresent( render );
SDL_UpdateWindowSurface(window);
}
示例8: lineDraw
void lineDraw(Game* g, float ax, float ay, float bx, float by,
float cr, float cg, float cb, float ca)
{
#ifdef OPENGL
#else
SDL_SetRenderDrawBlendMode(g->renderer,
SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(g->renderer,
clampi((cr * 255), 0, 255),
clampi((cg * 255), 0, 255),
clampi((cb * 255), 0, 255),
clampi((ca * 255), 0, 255));
SDL_RenderDrawLine(g->renderer, ax, ay, bx, by);
#endif
}
示例9: SDL_RenderDrawLine
void PathfindingApp::drawPath()
{
// Start at the start point
// tileSize / 2 is added to all coordinates to put them in the centre of the tile
int lastX = map->getStartX() * tileSize + tileSize / 2;
int lastY = map->getStartY() * tileSize + tileSize / 2;
// Step through the path
for (const Point& point : path)
{
int nextX = point.getX() * tileSize + tileSize / 2;
int nextY = point.getY() * tileSize + tileSize / 2;
SDL_RenderDrawLine(renderer, lastX, lastY, nextX, nextY);
lastX = nextX;
lastY = nextY;
;
}
}
示例10: SDL_SetRenderDrawColor
/** Other Functions **/
void Wall::draw(Renderer & g_renderer)
{
/*
* Draw the line for this Wall object. Use the simple SDL
* functions. The hexidecimal can also be written as decimal.
*/
SDL_SetRenderDrawColor(g_renderer, 0x20, 0x20, 0x20, 0x20);
SDL_RenderDrawLine(g_renderer, getX(), getY(), getX2(), getY2());
/*
int y = getY();
int z;
do
{
SDL_RenderDrawPoint(g_renderer, getX(), y);
if (getO() == TOP) y--;
else y++;
std::cin >> z;
} while (y != 0 && y != 479);
*/
}
示例11: draw_shape
SDL_Renderer* draw_shape(shape_t *shape, SDL_Renderer* renderer){
SDL_SetRenderDrawBlendMode(renderer, (shape->color[3] == 255) ?
SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(renderer,
shape->color[0],
shape->color[1],
shape->color[2],
shape->color[3]);
int i;
for(i = 0; i < shape->line_cnt; i++){
SDL_RenderDrawLine(renderer,
shape->lines[i].xa,
shape->lines[i].y,
shape->lines[i].xb,
shape->lines[i].y);
}
return renderer;
}
示例12: SDL_SetRenderDrawColor
void MinimapView::Render( SDL_Renderer* renderer )
{
SDL_Rect rect;
// For each tile in the game world
Vector2i worldSize = m_gameWorld->GetWorldSize();
for(int y = 0; y < worldSize.y; y++)
for(int x = 0; x < worldSize.x; x++)
{
int tileId = m_gameWorld->GetWorldTile(x, y)->m_tileId;
if(tileId == ' ')
SDL_SetRenderDrawColor( renderer, 255, 255, 255, 255 );
else
SDL_SetRenderDrawColor( renderer, 32, 32, 32, 255 );
rect.x = m_minimapPos.x + x * m_minimapTileSize;
rect.y = m_minimapPos.y + y * m_minimapTileSize;
rect.h = rect.w = m_minimapTileSize;
SDL_RenderFillRect( renderer, &rect );
}
// Draw wherever the player is as a circle, then draw the facing vector
Vector3f ppos = m_player->GetPosition();
rect.x = (int)((float)m_minimapPos.x + ppos.x * (float)m_minimapTileSize - 1.0f);
rect.y = (int)((float)m_minimapPos.y + ppos.y * (float)m_minimapTileSize - 1.0f);
rect.h = rect.w = 3;
SDL_SetRenderDrawColor( renderer, 0, 0, 128, 255 );
SDL_RenderFillRect( renderer, &rect );
// Draw a line for the facing-direction
float facing = m_player->GetFacing();
int dx = (int)(cos( facing ) * 8.0f);
int dy = (int)(-sin( facing ) * 8.0f);
SDL_SetRenderDrawColor( renderer, 255, 0, 0, 255 );
SDL_RenderDrawLine( renderer, rect.x + 1, rect.y + 1, rect.x + dx + 1, rect.y + dy + 1 );
}
示例13: DrawOnViewport
void
DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport)
{
SDL_Rect rect;
/* Set the viewport */
SDL_RenderSetViewport(renderer, &viewport);
/* Draw a gray background */
SDL_SetRenderDrawColor(renderer, 0x80, 0x80, 0x80, 0xFF);
SDL_RenderClear(renderer);
/* Test inside points */
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF);
SDL_RenderDrawPoint(renderer, viewport.h/2 + 10, viewport.w/2);
SDL_RenderDrawPoint(renderer, viewport.h/2 - 10, viewport.w/2);
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - 10);
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + 10);
/* Test horizontal and vertical lines */
SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
SDL_RenderDrawLine(renderer, 1, 0, viewport.w-2, 0);
SDL_RenderDrawLine(renderer, 1, viewport.h-1, viewport.w-2, viewport.h-1);
SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2);
SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2);
/* Test diagonal lines */
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xFF, 0xFF);
SDL_RenderDrawLine(renderer, 0, 0,
viewport.w-1, viewport.h-1);
SDL_RenderDrawLine(renderer, viewport.w-1, 0,
0, viewport.h-1);
/* Test outside points */
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF);
SDL_RenderDrawPoint(renderer, viewport.h/2 + viewport.h, viewport.w/2);
SDL_RenderDrawPoint(renderer, viewport.h/2 - viewport.h, viewport.w/2);
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - viewport.w);
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + viewport.w);
/* Add a box at the top */
rect.w = 8;
rect.h = 8;
rect.x = (viewport.w - rect.w) / 2;
rect.y = 0;
SDL_RenderFillRect(renderer, &rect);
}
示例14: prim_circle
int prim_circle(SDL_Renderer* renderer, Circle* circle, u32 segments) {
int result = 0;
f32 degPerSegment = 360.f / segments;
f32 x0 = circle->position.x + cosf(0.f) * circle->radius;
f32 y0 = circle->position.y + sinf(0.f) * circle->radius;
for (u32 s = 1; s <= segments; ++s) {
f32 a = degPerSegment * DEG_TO_RAD * (f32)s;
f32 x1 = circle->position.x + cosf(a) * circle->radius;
f32 y1 = circle->position.y + sinf(a) * circle->radius;
result |= SDL_RenderDrawLine(renderer, (int)x0, (int)y0, (int)x1, (int)y1);
x0 = x1;
y0 = y1;
}
return result;
}
示例15: draw_alt_icon
void draw_alt_icon (int x,int y,int shine) {
SDL_Rect rect;
rect.x = x;
rect.y = y;
rect.w = 6*16;
rect.h = 6*16;
SDL_SetRenderDrawColor(ngui_renderer,0x50,0x50,0x50,0xFF);
SDL_RenderDrawRect(ngui_renderer,&rect);
int col = 0xA0;
if(shine != 0) {
if(shine>10) {
col = ((255/10)*(shine-10));
} else {
col = (0xA0/10)*(10-shine);
}
}
SDL_SetRenderDrawColor(ngui_renderer,col,col,col,0xFF);
// A
SDL_RenderDrawLine(ngui_renderer,x+16,y+(16*4),x ,y+(16*4)); // Top line
SDL_RenderDrawLine(ngui_renderer,x ,y+(16*4),x ,y+(16*6)-1); // Down line
SDL_RenderDrawLine(ngui_renderer,x ,y+(16*5),x+16,y+(16*5)); // Midline
SDL_RenderDrawLine(ngui_renderer,x+16,y+(16*4),x+16,y+(16*6)-1); // Right down line
// L
SDL_RenderDrawLine(ngui_renderer,x+(16*2),y+(16*4),x+(16*2),y+(16*6)-1); // left
SDL_RenderDrawLine(ngui_renderer,x+(16*3),y+(16*6)-1,x+(16*2),y+(16*6)-1); //bottom
// T
SDL_RenderDrawLine(ngui_renderer,x+(16*6),y+(16*4),x+(16*4),y+(16*4));
SDL_RenderDrawLine(ngui_renderer,x+(16*5),y+(16*4),x+(16*5),y+(16*6)-1);
}