include header file
Posted: May 9th, 2020, 7:23 pm
How do you include a header filer where the compiler doesn't tell me cannot find.
Code: Select all
gfx.DrawLine({ 100.0f, 100.0f }, (Vec2)wnd.mouse.GetPos(), Colors::Magenta);
Code: Select all
_Vec2( std::pair<int, int> const& p )
:
x( T( p.first ) ),
y( T( p.second ) )
{}
Code: Select all
gfx.DrawLine({ 100.0f, 100.0f }, (Vec2)wnd.mouse.GetPos(), Colors::Magenta);
Code: Select all
gfx.DrawLine( { 100.f, 100.f }, Vec2{ wnd.mouse.GetPos() }, Colors::Magenta );
Code: Select all
gfx.DrawLine( { 100.f, 100.f }, Vec2{ float( wnd.mouse.GetMouseX() ), float( wnd.mouse.GetMouseY() }, Colors::Magenta );
Code: Select all
float m = 0.0f;
if (p1.x > p0.x)
{
m = (p1.y - p0.y) / (p1.x - p0.x);
}
if (p0.x > p1.x && m <= 1.0f)
{
if (p0.x > p1.x)
{
std::swap(p0, p1);
}
const float b = p0.y - m * p0.x;
for (int x = (int)p0.x; x < (int)p1.x; x++)
{
const float y = m * (float)x + b;
PutPixel(x, (int)y, c);
}
}
else
{
if (p0.y > p1.y);
{
std::swap(p0, p1);
}
const float w = (p1.x - p0.x) / (p1.y - p0.y);
const float p = p0.x - m * p0.y;
for (int y = (int)p0.y; y < (int)p1.y; y++)
{
const float x = w * (float)y + p;
PutPixel((int)x, y, c);
}
}
Code: Select all
float m = 0.0f;
if( p1.x != p0.x )
{
m = (p1.y - p0.y) / (p1.x - p0.x);
}
if( p1.x != p0.x && std::abs( m ) <= 1.0f )
{
if( p0.x > p1.x )
{
std::swap( p0,p1 );
}
const float b = p0.y - m * p0.x;
for( int x = (int)p0.x; x <= (int)p1.x; x++ )
{
const float y = m * (float)x + b;
const int yi = (int)y;
if( x >= 0 && x < ScreenWidth && yi >= 0 && yi < ScreenHeight )
{
PutPixel( x,yi,c );
}
}
}
else
{
if( p0.y > p1.y )
{
std::swap( p0,p1 );
}
const float w = (p1.x - p0.x) / (p1.y - p0.y);
const float p = p0.x - w * p0.y;
for( int y = (int)p0.y; y <= (int)p1.y; y++ )
{
const float x = w * (float)y + p;
const int xi = (int)x;
if( xi >= 0 && xi < ScreenWidth && y >= 0 && y < ScreenHeight )
{
PutPixel( xi,y,c );
}
}
}