VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo)
  : nux::BaseWindow("")
  , scale(1.0)
  , content_size_(geo)
  , content_offset_x_(0)
  , mouse_offset_y_(0)
  , current_state_(ThumbState::NONE)
  , current_action_(ThumbAction::NONE)
  , show_animator_(ANIMATION_DURATION)
{
  Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height);
  SetBackgroundColor(nux::color::Transparent);
  SetAcceptMouseWheelEvent(true);

  show_animator_.updated.connect(sigc::mem_fun(this, &BaseWindow::SetOpacity));
  show_animator_.finished.connect([this] {
    if (animation::GetDirection(show_animator_) == animation::Direction::BACKWARD)
      ShowWindow(false);
  });

  SetOpacity(0.0f);
  UpdateTexture();

  scale.changed.connect([this] (double scale) {
    UpdateContentGeometry();
    UpdateTexture();
  });
}
Example #2
0
void SpriteText::Set(int colorR, int colorG, int colorB)
{
	m_color.r = colorR;
	m_color.g = colorG;
	m_color.b = colorB;
	UpdateTexture();
}
Example #3
0
void
loop()
{
    SDL_Event event;

    while (SDL_PollEvent(&event)) {
        switch (event.type) {
        case SDL_KEYDOWN:
            if (event.key.keysym.sym == SDLK_ESCAPE) {
                done = SDL_TRUE;
            }
            break;
        case SDL_QUIT:
            done = SDL_TRUE;
            break;
        }
    }

    frame = (frame + 1) % MOOSEFRAMES_COUNT;
    UpdateTexture(MooseTexture, frame);

    SDL_RenderClear(renderer);
    SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
    SDL_RenderPresent(renderer);

#ifdef __EMSCRIPTEN__
    if (done) {
        emscripten_cancel_main_loop();
    }
#endif
}
Example #4
0
void D3D7Canvas::DrawBitmap(Bitmap & bmp_info, const Rect & dest)
{
    if (NULL == back_buffer_)
        return;
    HRESULT hr = device7_->SetRenderTarget(back_buffer_, 0);
    if(FAILED(hr))
        return;
    DDSURFACEDESC2 surfaceDesc;
    ::ZeroMemory(&surfaceDesc, sizeof(surfaceDesc));
    surfaceDesc.dwSize = sizeof(surfaceDesc);
    back_buffer_->GetSurfaceDesc(&surfaceDesc);

    D3DVIEWPORT7 port = {0, 0, surfaceDesc.dwWidth, 
        surfaceDesc.dwHeight, 
        0.0f, 1.0f};
    hr = device7_->SetViewport(&port);
    if(FAILED(hr))
        return;

    //set state
    SetTextureState();

    uint32_t width = 0;
    uint32_t height = 0;
    GetTextureWH(width, height);
    //create or update
    if (bmp_info.width > width || bmp_info.height > height)
    {
        //delete texture
        if (texture_)
            SAFE_RELEASE(texture_);      
        //recreate texture
        CreateTexture(bmp_info.width, bmp_info.height);
    }
    //
    if (!UpdateTexture(bmp_info))
        return;

    GetTextureWH(width, height);
    if(width == 0 || height == 0)
        return;
    //update vertex data
    float max_u = (float)(bmp_info.width) / width;
    float max_v = (float)(bmp_info.height) / height;

    SimpleVertex vertex_buffer[4];
    vertex_buffer[0] = SimpleVertex(-0.5f + dest.left() + rect_.left(),
        -0.5f + dest.top() + rect_.top(), 0.0f, 1.0f, 0.0f, 0.0f);
    vertex_buffer[1] = SimpleVertex(-0.5f + dest.right() + rect_.left(),
        -0.5f + dest.top() + rect_.top(), 0.0f, 1.0f, max_u, 0.0f);
    vertex_buffer[2] = SimpleVertex(-0.5f + dest.left() + rect_.left(),
        -0.5f + dest.bottom() + rect_.top(), 0.0f, 1.0f, 0.0f, max_v);
    vertex_buffer[3] = SimpleVertex(-0.5f + dest.right() + rect_.left(),
        -0.5f + dest.bottom() + rect_.top(), 0.0f, 1.0f, max_u, max_v);

    //draw
    device7_->SetTexture(0, texture_);
    device7_->DrawPrimitive(D3DPT_TRIANGLESTRIP, SimpleVertex::GetFVF(), 
        (LPVOID)vertex_buffer, 4, 0);
}
Example #5
0
void Sprite::Render()
{
    if (!ShouldDraw())
        return;

    UpdateTexture();

    SetBlendingMode(BlendingMode);

    // Assign our matrix.
    SetShaderParameters(ColorInvert, AffectedByLightning, Centered, false, BlackToTransparent);

    Mat4 Mat = GetMatrix();
    WindowFrame.SetUniform(U_MVP, &(Mat[0][0]));

    // Set the color.
    WindowFrame.SetUniform(U_COLOR, Red, Green, Blue, Alpha);

    SetTexturedQuadVBO(UvBuffer);
    DoQuadDraw();

    DrawLighten();

    FinalizeDraw();
}
Example #6
0
void CTriMenu::Draw( void )
{
	if( m_pTex )
	{
		g_CGLTriAPI.Color4f( 1, 1, 1, 1 );
		g_CGLTriAPI.RenderMode( kRenderNormal );
		g_CGLTriAPI.CullFace( TRI_NONE );
		g_CGLTriAPI.Texture2D( m_pTex, 0 );
	//	gEngfuncs.Con_Printf( "%i, Texture\n", m_pTex->iTexNum );

		g_CGLTriAPI.Begin( TRI_QUADS );
			// need to find ortho coords for this
			g_CGLTriAPI.TexCoord2f( 0, 0 );
			g_CGLTriAPI.Vertex3fv( MakePointOrtho( m_vPos[1] ) );
			g_CGLTriAPI.TexCoord2f( 0, 1 );
			// gEngfuncs.Con_Printf( "%f\n", m_vPos[0].x );
			g_CGLTriAPI.Vertex3fv( MakePointOrtho( m_vPos[0] ) );//m_vPos[0].x, m_vPos[0].y, 5 );
			g_CGLTriAPI.TexCoord2f( 1, 1 );
			g_CGLTriAPI.Vertex3fv( MakePointOrtho( m_vPos[3] ) );
			g_CGLTriAPI.TexCoord2f( 1, 0 );
			g_CGLTriAPI.Vertex3fv( MakePointOrtho( m_vPos[2] ) );
			
		g_CGLTriAPI.End( );
	}
	else
	{
		UpdateTexture( m_strTex.c_str( ) );
	}

}
//-----------------------------------------------------------------------------
// Purpose: Selects a texture by name.
// Input  : pszTextureName - Texture name to select.
//-----------------------------------------------------------------------------
void CFaceEditMaterialPage::SelectTexture( LPCSTR pszTextureName )
{
	int nIndex = m_TextureList.SelectString( -1, pszTextureName );

	//
	// If the texture is not in the list, add it to the list.
	//
	if( nIndex == LB_ERR )
	{
		IEditorTexture *pTex = g_Textures.FindActiveTexture( pszTextureName );
		if( pTex != NULL )
		{
			nIndex = m_TextureList.AddString( pszTextureName );
			m_TextureList.SetItemDataPtr( nIndex, pTex );
			m_TextureList.SetCurSel( nIndex );
		}
	}

	UpdateTexture();

	if( nIndex != LB_ERR )
	{
		IEditorTexture *pTex = ( IEditorTexture* )m_TextureList.GetItemDataPtr( nIndex );
		m_TextureList.AddMRU( pTex );
	}
}
Example #8
0
void TextField::Render(Rect& rectArea)
{
   if (!m_text.IsInit())
      UpdateTexture();

   m_text.Render(rectArea);
}
Example #9
0
void EditField::Render(Rect& rectArea) throw()
{
   if (!m_text.IsInit())
      UpdateTexture();

   m_text.Render(rectArea);

   // render border
   {
      glLineWidth(2.0f);

      //if (m_bShowBorder) // TODO
      {
         glBegin(GL_LINE_LOOP);
            Color m_cForeground = Color::Black(); // TODO
            glColor4ubv(m_cForeground.m_color);
            glVertex2i(rectArea.Left(),  rectArea.Top());
            glVertex2i(rectArea.Left(),  rectArea.Bottom());
            glVertex2i(rectArea.Right(), rectArea.Bottom());
            glVertex2i(rectArea.Right(), rectArea.Top());
         glEnd();
      }
   }

   // draw caret
   if (m_bFocused)
   {
      glBegin(GL_LINES);
         glColor4ubv(Color::Blue().m_color);
         glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + 2);
         glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + m_uiCaretHeight + 2);
      glEnd();
   }
}
void VScrollBarOverlayWindow::MouseUp()
{
  RemoveState(ThumbState::MOUSE_DOWN);
  current_action_ = ThumbAction::NONE;
  UpdateTexture();
  ShouldHide();
}
Example #11
0
void CCanvas::UpdateTexture(CCanvas* source, const CRectangle* dstRect, const CRectangle* srcRect) {
    if(!GetTexture() || !source->GetSurface()) {
        return;
    }

    UpdateTexture(GetTexture(), srcRect, source->GetSurface()->pixels, source->GetSurface()->pitch);
}
Example #12
0
void CD3DTextTexture::OnPrepareRenderData()
{
	if(m_WantUpdate&&m_AllowUpdate)
	{
		UpdateTexture();
	}
}
Example #13
0
void CCanvas::UpdateTexture(const CRectangle* dstRect, const CRectangle* srcRect) {
    if(!GetTexture() || !GetSurface()) {
        return;
    }

    UpdateTexture(GetTexture(), NULL, GetSurface()->pixels, GetSurface()->pitch);
}
Example #14
0
void CMainWindow::OpenMaterialManager()
{
    if(!m_model)
        return;
    CMaterialManager matMngr(this);
    matMngr.SetMaterials(m_model->GetMaterials(), m_textures);
    matMngr.exec();

    auto newTextures = matMngr.GetTextures();
    for(auto it=newTextures.begin(); it!=newTextures.end(); it++)
    {
        if(m_textures[it->first] != it->second)
        {
            m_textures[it->first] = it->second;
            if(!it->second.empty())
            {
                m_textureImages[it->first].reset(new QImage(it->second.c_str()));
                (*(m_textureImages[it->first])) = m_textureImages[it->first]->convertToFormat(QImage::Format_RGB32);
            } else {
                m_textureImages[it->first].reset(nullptr);
            }
            emit UpdateTexture(m_textureImages[it->first].get(), it->first);
        }
    }
}
Example #15
0
void Sprite::Initialize(bool ShouldInitTexture)
{
	UvBuffer = nullptr;

	if (ShouldInitTexture)
		UpdateTexture();
}
void CMistyFog2::Update(CWorldEffectsSystem *system, float elapseTime)
{
	CMistyFog	*current;
	int			x, y;

	if (originContents & CONTENTS_OUTSIDE && !(originContents & CONTENTS_WATER))
	{
		if (mFadeAlpha < 1.0)
		{
			mFadeAlpha += elapseTime / 2.0;
		}
		if (mFadeAlpha > 1.0)
		{
			mFadeAlpha = 1.0;
		}
	}
	else
	{
		if (mFadeAlpha > 0.0)
		{
			mFadeAlpha -= elapseTime / 2.0;
		}

		if (mFadeAlpha <= 0.0)
		{
			return;
		}
	}

	for(y=0;y<MISTYFOG_HEIGHT;y++)
	{
		for(x=0;x<MISTYFOG_WIDTH;x++)
		{
			mColors[y][x][3] = 0.0;
		}
	}

	CWorldEffect::Update(system, elapseTime);

	current = (CMistyFog *)mSlave;
	while(current)
	{
		UpdateTexture(current);
		UpdateTexture((CMistyFog *)current->GetSlave());
		current = (CMistyFog *)current->GetNext();
	}
}
Example #17
0
void CglFont::End()
{
	if (!inBeginEnd) {
		LOG_L(L_ERROR, "called End() without Begin()");
		return;
	}
	inBeginEnd = false;

	if (va.drawIndex() == 0) {
		glPopAttrib();
		if (threadSafety)
			vaMutex.unlock();
		return;
	}

	GLboolean inListCompile;
	glGetBooleanv(GL_LIST_INDEX, &inListCompile);
	if (!inListCompile) {
		UpdateTexture();
	}

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, GetTexture());

	// Because texture size can change, texture coordinats are absolute in texels.
	// We could use also just use GL_TEXTURE_RECTANGLE
	// but then all shaders would need to detect so and use different funcs & types if supported -> more work
	glMatrixMode(GL_TEXTURE);
	glPushMatrix();
	glCallList(textureSpaceMatrix);
	glMatrixMode(GL_MODELVIEW);

	if (va2.drawIndex() > 0) {
		if (stripOutlineColors.size() > 1) {
			ColorMap::iterator sci = stripOutlineColors.begin();
			va2.DrawArray2dT(GL_QUADS,TextStripCallback,&sci);
		} else {
			glColor4fv(outlineColor);
			va2.DrawArray2dT(GL_QUADS);
		}
	}

	if (stripTextColors.size() > 1) {
		ColorMap::iterator sci = stripTextColors.begin();
		va.DrawArray2dT(GL_QUADS,TextStripCallback,&sci);//FIXME calls a 0 length strip!
	} else {
		if (setColor) glColor4fv(textColor);
		va.DrawArray2dT(GL_QUADS);
	}

	// pop texture matrix
	glMatrixMode(GL_TEXTURE);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);

	glPopAttrib();
	if (threadSafety)
		vaMutex.unlock();
}
void VScrollBarOverlayWindow::ThumbOutsideSlider()
{
  if (HasState(ThumbState::INSIDE_SLIDER))
  {
    RemoveState(ThumbState::INSIDE_SLIDER);
    UpdateTexture();
  }
}
void VScrollBarOverlayWindow::ThumbInsideSlider()
{
  if (!HasState(ThumbState::INSIDE_SLIDER))
  {
    AddState(ThumbState::INSIDE_SLIDER);
    UpdateTexture();
  }
}
Example #20
0
long
PlacesVScrollBar::PostLayoutManagement(long LayoutResult)
{
  long ret = nux::VScrollBar::PostLayoutManagement(LayoutResult);

  UpdateTexture();
  return ret;
}
void VScrollBarOverlayWindow::MouseDragging()
{
  if (current_action_ != ThumbAction::DRAGGING)
  {
    current_action_ = ThumbAction::DRAGGING;
    UpdateTexture();
  }
}
Example #22
0
void Sprite::Initialize(bool ShouldInitTexture)
{
    UvBuffer = nullptr;

	if (ShouldInitTexture)
		UpdateTexture();
	else
		UvBuffer = Renderer::GetDefaultTextureBuffer();
}
void Checkbox::Render(Rect& rectArea)
{
    RenderCheck(rectArea);

    if (!m_text.IsInit())
        UpdateTexture();

    m_text.Render(rectArea);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CFaceEditMaterialPage::Init( void )
{
	//
	// Connect dialog control objects to their control IDs.
	//
	m_shiftX.SubclassDlgItem( IDC_SHIFTX, this );
	m_shiftY.SubclassDlgItem( IDC_SHIFTY, this );
	m_scaleX.SubclassDlgItem( IDC_SCALEX, this );
	m_scaleY.SubclassDlgItem( IDC_SCALEY, this );
	m_rotate.SubclassDlgItem( IDC_ROTATE, this );
	m_cHideMask.SubclassDlgItem( IDC_HIDEMASK, this );
	m_cExpand.SubclassDlgItem( IDC_EXPAND, this );
	m_cLightmapScale.SubclassDlgItem( IDC_LIGHTMAP_SCALE, this );

	//
	// Set spin ranges.
	//
	CWnd *pWnd = GetDlgItem(IDC_SPINSHIFTX);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(MAX_TEXTUREWIDTH, -MAX_TEXTUREWIDTH));

	pWnd = GetDlgItem(IDC_SPINSHIFTY);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(MAX_TEXTUREHEIGHT, -MAX_TEXTUREHEIGHT));

	pWnd = GetDlgItem(IDC_SPINROTATE);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(359, -359));

	pWnd = GetDlgItem(IDC_SPINSCALEX);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(UD_MAXVAL, UD_MINVAL));

	pWnd = GetDlgItem(IDC_SPINSCALEY);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(UD_MAXVAL, UD_MINVAL));

	pWnd = GetDlgItem(IDC_SPIN_LIGHTMAP_SCALE);
	::PostMessage(pWnd->m_hWnd, UDM_SETRANGE, 0, MAKELONG(UD_MAXVAL, 1));

	// set the initial switch mode
	OnSwitchMode( CFaceEditSheet::ModeLiftSelect );

	//
	// set up controls
	//
	m_TextureGroupList.SubclassDlgItem( IDC_TEXTUREGROUPS, this );
	m_TextureList.SubclassDlgItem( IDC_TEXTURES, this );
	m_TexturePic.SubclassDlgItem( IDC_TEXTUREPIC, this );

	m_pCurTex = NULL;

	//
	// initially update the texture controls
	//
	NotifyGraphicsChanged();
	UpdateTexture();

	// initialized!
	m_bInitialized = TRUE;
}
Example #25
0
void TextField::OnAttributeChanged(const CString& cszAttributeName) throw()
{
   if (Parent() == NULL)
      return;

   if (cszAttributeName == TextFieldAttr::Text ||
       cszAttributeName == TextFieldAttr::BackColor ||
       cszAttributeName == TextFieldAttr::Color)
      UpdateTexture();
}
void Checkbox::OnAttributeChanged(const CString& cszAttributeName) throw()
{
    if (Parent() == nullptr)
        return;

    if (cszAttributeName == CheckboxAttr::Text ||
            cszAttributeName == CheckboxAttr::BackColor ||
            cszAttributeName == CheckboxAttr::Color)
        UpdateTexture();
}
Example #27
0
void SpriteText::Set(const std::string& text, int colorR, int colorG, int colorB)
{

	m_text = text;

	m_color.r = colorR;
	m_color.g = colorG;
	m_color.b = colorB;
	UpdateTexture();
}
void CGLWorkspace::AddImage(CGLImage *image)
{
	image->SetParentWorkspace(this);
	iImages.append (image);
	iLayout->PrepareNewImageGeometry(image);
	UpdateTexture();
	if(CGLWidget::GetInstance())
	{
		CGLWidget::GetInstance()->updateGL();
	}

}
Example #29
0
//================================================================================
// Constructor
//================================================================================
CInternalLight::CInternalLight( int index, const char *pTextureName )
{
    m_nLightHandle = CLIENTSHADOW_INVALID_HANDLE;
    m_bIsOn = false;
    m_iEntIndex = index;
    m_flCurrentPullBackDist = 1.0f;
    m_flDie.Invalidate();

    // Iniciamos la textura de la luz
    if ( pTextureName )
        UpdateTexture( pTextureName );
}
Example #30
0
void Sprite::SetCropByPixels(int32_t x1, int32_t x2, int32_t y1, int32_t y2)
{
    if (mImage)
    {
        mCrop_x1 = (float)x1 / (float)mImage->w;
        mCrop_x2 = (float)x2 / (float)mImage->w;
        mCrop_y1 = (float)y1 / (float)mImage->h;
        mCrop_y2 = (float)y2 / (float)mImage->h;

        DirtyTexture = true;
        UpdateTexture();
    }
}