本文整理汇总了C++中int2类的典型用法代码示例。如果您正苦于以下问题:C++ int2类的具体用法?C++ int2怎么用?C++ int2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了int2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int2
void UIScrollBar::MouseOverHandler(UIDialog const & /*sender*/, uint32_t /*buttons*/, int2 const & pt)
{
last_mouse_ = pt;
is_mouse_over_ = true;
if (drag_)
{
thumb_rc_.bottom() += pt.y() - thumb_offset_y_ - thumb_rc_.top();
thumb_rc_.top() = pt.y() - thumb_offset_y_;
if (thumb_rc_.top() < track_rc_.top())
{
thumb_rc_ += int2(0, track_rc_.top() - thumb_rc_.top());
}
else
{
if (thumb_rc_.bottom() > track_rc_.bottom())
{
thumb_rc_ += int2(0, track_rc_.bottom() - thumb_rc_.bottom());
}
}
// Compute first item index based on thumb position
size_t nMaxFirstItem = end_ - start_ - page_size_; // Largest possible index for first item
size_t nMaxThumb = track_rc_.Height() - thumb_rc_.Height(); // Largest possible thumb position from the top
position_ = start_ +
(thumb_rc_.top() - track_rc_.top() +
nMaxThumb / (nMaxFirstItem * 2)) * // Shift by half a row to avoid last row covered by only one pixel
nMaxFirstItem / nMaxThumb;
}
}
示例2:
void IGLUShaderVariable::operator= ( int2 val )
{
// Check for a valid shader index
if ( m_varIdx < 0 ) return;
// Check for type mismatches
if ( m_isAttribute )
{
AssignmentToAttribute( "ivec2" );
return;
}
if ( m_varType != GL_INT_VEC2 && m_varType != GL_UNSIGNED_INT_VEC2 )
TypeMismatch( "ivec2" );
// Ensure this program is currently bound, or setting shader values fails!
m_parent->PushProgram();
// For types of variable that can be assigned from our input value, assign them here
if ( m_varType == GL_INT_VEC2 )
glUniform2iv( m_varIdx, 1, val.GetConstDataPtr() );
if ( m_varType == GL_UNSIGNED_INT_VEC2 )
glUniform2ui( m_varIdx, val.X(), val.Y() );
// We have a short "program stack" so make sure to pop off.
m_parent->PopProgram();
}
示例3: MouseUpHandler
void UIPolylineEditBox::MouseUpHandler(UIDialog const & /*sender*/, uint32_t buttons, int2 const & pt)
{
if (buttons & MB_Left)
{
if (!this->GetDialog()->IsKeyboardInputEnabled())
{
this->GetDialog()->ClearFocus();
}
if (this->ContainsPoint(pt))
{
if (move_point_)
{
if ((this->ActivePoint() != 0) && (this->ActivePoint() != static_cast<int>(this->NumCtrlPoints() - 1)))
{
float2 p = this->PtFromCoord(pt.x(), pt.y());
if ((p.x() < 0) || (p.x() > 1) || (p.y() < 0) || (p.y() > 1))
{
this->DelCtrlPoint(this->ActivePoint());
}
}
move_point_ = false;
}
}
}
}
示例4: Set2DMode
void Set2DMode(const int2 &screensize)
{
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
otransforms = objecttransforms();
view2clip = orthoGL(0, (float)screensize.x(), (float)screensize.y(), 0, 1, -1); // left handed coordinate system
}
示例5: OpenGLFrameStart
void OpenGLFrameStart(const int2 &screensize)
{
glViewport(0, 0, screensize.x(), screensize.y());
SetBlendMode(BLEND_ALPHA);
curcolor = float4(1);
lights.clear();
}
示例6: MouseDownHandler
void UISlider::MouseDownHandler(UIDialog const & /*sender*/, uint32_t buttons, int2 const & pt)
{
if (buttons & MB_Left)
{
if (button_rc_.PtInRect(pt))
{
// Pressed while inside the control
pressed_ = true;
drag_x_ = pt.x();
//m_nDragY = arg.location.y();
drag_offset_ = button_x_ - drag_x_;
//m_nDragValue = value_;
if (!has_focus_)
{
this->GetDialog()->RequestFocus(*this);
}
return;
}
if (slider_rc_.PtInRect(pt))
{
drag_x_ = pt.x();
drag_offset_ = 0;
pressed_ = true;
if (!has_focus_)
{
this->GetDialog()->RequestFocus(*this);
}
if (pt.x() > button_x_ + x_)
{
this->SetValueInternal(value_ + 1);
return;
}
if (pt.x() < button_x_ + x_)
{
this->SetValueInternal(value_ - 1);
return;
}
}
}
}
示例7: MouseOverHandler
void UISlider::MouseOverHandler(UIDialog const & /*sender*/, uint32_t /*buttons*/, int2 const & pt)
{
if (pressed_)
{
this->SetValueInternal(ValueFromPos(x_ + pt.x() + drag_offset_));
}
}
示例8: mSize
//---------------------------------------------------------------------------------------------------------
BlockGenerator::BlockGenerator( const int2& size, int blockSize ) : mSize(size), mBockSize(blockSize)
{
mNumBlocks = int2(
(int)std::ceil(size.X() / (float) blockSize),
(int)std::ceil(size.Y() / (float) blockSize));
mBlocksLeft = mNumBlocks.X() * mNumBlocks.Y();
mDirection = Right;
mBlock = mNumBlocks / 2;
mStepsLeft = 1;
mNumSteps = 1;
mStartTime = clock();
}
示例9: MouseDownHandler
void UIScrollBar::MouseDownHandler(UIDialog const & /*sender*/, uint32_t buttons, int2 const & pt)
{
last_mouse_ = pt;
if (buttons & MB_Left)
{
if (up_button_rc_.PtInRect(pt))
{
if (position_ > start_)
{
-- position_;
}
this->UpdateThumbRect();
arrow_ = CLICKED_UP;
arrow_ts_ = timer_.current_time();
return;
}
// Check for click on down button
if (down_button_rc_.PtInRect(pt))
{
if (position_ + page_size_ < end_)
{
++ position_;
}
this->UpdateThumbRect();
arrow_ = CLICKED_DOWN;
arrow_ts_ = timer_.current_time();
return;
}
// Check for click on thumb
if (thumb_rc_.PtInRect(pt))
{
drag_ = true;
thumb_offset_y_ = pt.y() - thumb_rc_.top();
return;
}
// Check for click on track
if ((thumb_rc_.left() <= pt.x()) && (thumb_rc_.right() > pt.x()))
{
if ((thumb_rc_.top() > pt.y()) && (track_rc_.top() <= pt.y()))
{
this->Scroll(-static_cast<int>(page_size_ - 1));
}
else
{
if ((thumb_rc_.bottom() <= pt.y()) && (track_rc_.bottom() > pt.y()))
{
this->Scroll(static_cast<int>(page_size_ - 1));
}
}
}
}
}
示例10: OnMouseButtonRelease
bool ListBox::OnMouseButtonRelease( const int2& screenPos, uint32_t button )
{
bool eventConsumed = false;
if (button == MS_LeftButton)
{
if (mPressed)
{
if (mSelectionRegion.Contains((float)screenPos.X(), (float)screenPos.Y()))
{
int32_t selIndex = mVertScrollBar->GetScrollValue() + (int32_t)floorf((screenPos.Y() - mSelectionRegion.Top()) / mTextRowHeight);
SetSelectedIndex(selIndex, true);
}
mPressed = false;
eventConsumed = true;
}
}
return eventConsumed;
}
示例11: GaussBlur
void Blur::GaussBlur(
const Ptr<ShaderResourceView> & src,
const Ptr<RenderTargetView> & dst,
int2 numSamples,
float2 blurRadius)
{
auto dstTex = dst->GetResource()->Cast<Texture>();
auto mipSize = dstTex->GetMipSize(dst->Cast<TextureRenderTargetView>()->mipLevel);
TextureDesc texDesc = dst->GetResource()->Cast<Texture>()->GetDesc();
texDesc.width = mipSize.x();
texDesc.height = mipSize.y();
texDesc.depth = 1;
texDesc.arraySize = 1;
texDesc.mipLevels = 1;
auto tmpTex = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });
GaussBlurX(src, tmpTex->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1), numSamples.x(), blurRadius.x());
GaussBlurY(tmpTex->Get()->Cast<Texture>()->GetShaderResourceView(0, 1, 0, 1), dst, numSamples.y(), blurRadius.y());
}
示例12: AADist
float AADist(std::vector<float> const & img, std::vector<float2> const & grad,
int width, int offset_addr, int2 const & offset_dist_xy, float2 const & new_dist)
{
int closest = offset_addr - offset_dist_xy.y() * width - offset_dist_xy.x(); // Index to the edge pixel pointed to from c
float val = img[closest];
if (0 == val)
{
return 1e10f;
}
float di = MathLib::length(new_dist);
float df;
if (0 == di)
{
df = EdgeDistance(grad[closest], val);
}
else
{
df = EdgeDistance(new_dist, val);
}
return di + df;
}
示例13: MouseOverHandler
void UIListBox::MouseOverHandler(UIDialog const & sender, uint32_t buttons, int2 const & pt)
{
// Let the scroll bar handle it first.
scroll_bar_.MouseOverHandler(sender, buttons, pt);
if (drag_)
{
// Compute the index of the item below cursor
int nItem;
if (text_height_ != 0)
{
nItem = static_cast<int>(scroll_bar_.GetTrackPos() + (pt.y() - text_rc_.top()) / text_height_);
}
else
{
nItem = -1;
}
// Only proceed if the cursor is on top of an item.
if ((nItem >= static_cast<int>(scroll_bar_.GetTrackPos()))
&& (nItem < static_cast<int>(items_.size()))
&& (nItem < static_cast<int>(scroll_bar_.GetTrackPos() + scroll_bar_.GetPageSize())))
{
selected_ = nItem;
this->OnSelectionEvent()(*this);
}
else
{
if (nItem < static_cast<int>(scroll_bar_.GetTrackPos()))
{
// User drags the mouse above window top
scroll_bar_.Scroll(-1);
selected_ = static_cast<int>(scroll_bar_.GetTrackPos());
this->OnSelectionEvent()(*this);
}
else
{
if (nItem >= static_cast<int>(scroll_bar_.GetTrackPos() + scroll_bar_.GetPageSize()))
{
// User drags the mouse below window bottom
scroll_bar_.Scroll(1);
selected_ = static_cast<int>(std::min(items_.size(), scroll_bar_.GetTrackPos() + scroll_bar_.GetPageSize())) - 1;
this->OnSelectionEvent()(*this);
}
}
}
}
}
示例14: MouseDownHandler
void UIPolylineEditBox::MouseDownHandler(UIDialog const & /*sender*/, uint32_t buttons, int2 const & pt)
{
if (buttons & MB_Left)
{
if (!has_focus_)
{
this->GetDialog()->RequestFocus(*this);
}
if (this->ContainsPoint(pt))
{
float2 p = this->PtFromCoord(pt.x(), pt.y());
if (MathLib::abs(this->GetValue(p.x()) - p.y()) < 0.1f)
{
bool found = false;
for (int i = 0; i < static_cast<int>(this->NumCtrlPoints()); ++ i)
{
float2 cp = this->GetCtrlPoint(i);
cp = p - cp;
if (MathLib::dot(cp, cp) < 0.01f)
{
this->ActivePoint(i);
move_point_ = true;
found = true;
break;
}
}
if (!found)
{
this->AddCtrlPoint(p.x());
move_point_ = true;
}
}
}
}
}
示例15: ScreenShot
bool ScreenShot(const char *filename)
{
SDL_Surface *surf = SDL_CreateRGBSurface(0, screensize.x(), screensize.y(), 24,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
if (!surf) return false;
auto pixels = ReadPixels(int2(0), screensize, false);
SDL_LockSurface(surf);
for (int i = 0; i < screensize.y(); i++)
memcpy(((char *)surf->pixels) + surf->pitch * i,
pixels + 3 * screensize.x() * (screensize.y() - i - 1),
screensize.x() * 3);
SDL_UnlockSurface(surf);
delete[] pixels;
bool ok = !SDL_SaveBMP(surf, filename);
SDL_FreeSurface(surf);
return ok;
}