Exemplo n.º 1
0
void DFlashFader::Tick ()
{
	if (ForWho == NULL || ForWho->player == NULL)
	{
		Destroy ();
		return;
	}
	if (level.time >= StartTic+TotalTics)
	{
		SetBlend (1.f);
		Destroy ();
		return;
	}
	SetBlend ((float)(level.time - StartTic) / (float)TotalTics);
}
Exemplo n.º 2
0
void MythRenderOpenGL1::DrawBitmapPriv(uint *textures, uint texture_count,
                                       const QRectF *src, const QRectF *dst,
                                       uint prog)
{
    if (prog && !m_programs.contains(prog))
        prog = 0;

    uint first = textures[0];

    EnableShaderObject(prog);
    SetBlend(false);
    SetColor(255, 255, 255, 255);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    EnableTextures(first);
    uint active_tex = 0;
    for (uint i = 0; i < texture_count; i++)
    {
        if (m_textures.contains(textures[i]))
        {
            ActiveTexture(GL_TEXTURE0 + active_tex++);
            glBindTexture(m_textures[textures[i]].m_type, textures[i]);
        }
    }

    UpdateTextureVertices(first, src, dst);
    glVertexPointer(2, GL_FLOAT, 0, m_textures[first].m_vertex_data);
    glTexCoordPointer(2, GL_FLOAT, 0, m_textures[first].m_vertex_data + TEX_OFFSET);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    ActiveTexture(GL_TEXTURE0);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}
Exemplo n.º 3
0
BOOL CFloatingInfoWnd::Create()
{
	

	
	RECT rcWA;
	SystemParametersInfo (SPI_GETWORKAREA, 0, &rcWA, FALSE);
	RECT rc = {rcWA.right - 1 - 150, rcWA.bottom - 1 - 100, rcWA.right - 1, rcWA.bottom - 1};

	DWORD dwLStyle = fsSysGetOsMajorVersion () < 5 ? 0 : WS_EX_LAYERED;

	if (FALSE == CFrameWnd::CreateEx (WS_EX_TOPMOST|WS_EX_TOOLWINDOW|dwLStyle,
			AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW),	(HBRUSH)(COLOR_WINDOW+1), NULL),
			LS (L_ACTIVEDLDS),
			WS_OVERLAPPED|WS_CLIPSIBLINGS|WS_SYSMENU|WS_THICKFRAME,
			rc, NULL, 0))
		return FALSE;

	SetBlend (_App.DownloadsInfoWndBlend ());

	

	_App.View_ReadWndPlacement (this, "FloatingInfoWnd", fsAppSettings::RWPA_FORCE_SWHIDE);

	

	return TRUE;
}
Exemplo n.º 4
0
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush,
                                     const QPen &linePen, int alpha)
{
    SetBlend(true);
    DisableTextures();
    glEnableClientState(GL_VERTEX_ARRAY);

    if (fillBrush.style() != Qt::NoBrush)
    {
        SetColor(fillBrush.color().red(), fillBrush.color().green(),
                 fillBrush.color().blue(), fillBrush.color().alpha());
        GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, area);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }

    if (linePen.style() != Qt::NoPen)
    {
        SetColor(linePen.color().red(), linePen.color().green(),
                 linePen.color().blue(), linePen.color().alpha());
        glLineWidth(linePen.width());
        GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, area);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_LINE_LOOP, 0, 4);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
}
Exemplo n.º 5
0
bool UIDirect3D9Window::Initialise2DState(void)
{
    LOG(VB_GENERAL, LOG_INFO, "Initialising 2D state");

    m_d3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    m_d3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    m_d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    m_d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

    m_d3dDevice->SetRenderState(D3DRS_AMBIENT,       D3DCOLOR_XRGB(255,255,255));
    m_d3dDevice->SetRenderState(D3DRS_CULLMODE,      D3DCULL_NONE);
    m_d3dDevice->SetRenderState(D3DRS_ZENABLE,       D3DZB_FALSE);
    m_d3dDevice->SetRenderState(D3DRS_LIGHTING,      FALSE);
    m_d3dDevice->SetRenderState(D3DRS_DITHERENABLE,  TRUE);
    m_d3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
    m_d3dDevice->SetRenderState(D3DRS_SRCBLEND,      D3DBLEND_SRCALPHA);
    m_d3dDevice->SetRenderState(D3DRS_DESTBLEND,     D3DBLEND_INVSRCALPHA);

    SetBlend(true);

    if (FAILED(m_d3dDevice->GetRenderTarget(0, &m_defaultRenderTarget)))
    {
        LOG(VB_GENERAL, LOG_ERR, "Failed to get default render target");
        return false;
    }

    return true;
}
Exemplo n.º 6
0
bool FrameFunc()
{
	float dt=hge->Timer_GetDelta();
	int i;

	// Process keys

	switch(hge->Input_GetKey())
	{
		case HGEK_UP:		if(nObjects<MAX_OBJECTS) nObjects+=100; break;
		case HGEK_DOWN:		if(nObjects>MIN_OBJECTS) nObjects-=100; break;
		case HGEK_SPACE:	SetBlend(++nBlend); break;
		case HGEK_ESCAPE:	return true;
	}

	// Update the scene

	for(i=0;i<nObjects;i++)
	{
		pObjects[i].x+=pObjects[i].dx*dt;
		if(pObjects[i].x>SCREEN_WIDTH || pObjects[i].x<0) pObjects[i].dx=-pObjects[i].dx;
		pObjects[i].y+=pObjects[i].dy*dt;
		if(pObjects[i].y>SCREEN_HEIGHT || pObjects[i].y<0) pObjects[i].dy=-pObjects[i].dy;
		pObjects[i].scale+=pObjects[i].dscale*dt;
		if(pObjects[i].scale>2 || pObjects[i].scale<0.5) pObjects[i].dscale=-pObjects[i].dscale;
		pObjects[i].rot+=pObjects[i].drot*dt;
	}

	return false;
}
Exemplo n.º 7
0
void UIDirect3D9Window::DrawTexture(D3D9Texture *Texture, QRectF *Dest, QSizeF *Size, bool &PositionChanged)
{
    static const float studiorange  = 219.0f / 255.0f;
    static const float studiooffset = 16.0f / 255.0f;

    if (!Texture || !Dest || !m_d3dDevice || !Size)
        return;

    SetBlend(true);

    if (PositionChanged || !Texture->m_verticesUpdated)
    {
        PositionChanged = false;
        UpdateVertices(Texture, Dest, Size);
    }

    // TODO some basic state tracking
    // TODO null pointer checks

    D3DXVECTOR4 color;
    color.x = m_transforms[m_currentTransformIndex].color;
    color.y = m_studioLevels ? studiorange : 1.0f;
    color.z = m_studioLevels ? studiooffset : 0.0f;
    color.w = m_transforms[m_currentTransformIndex].alpha;
    m_defaultShader->m_vertexConstants->SetMatrix(m_d3dDevice, "Projection", m_currentProjection);
    m_defaultShader->m_vertexConstants->SetMatrix(m_d3dDevice, "Transform", &m_transforms[m_currentTransformIndex].m);
    m_defaultShader->m_pixelConstants->SetVector(m_d3dDevice, "Color", &color);
    //uint index = m_defaultShader->m_pixelConstants->GetSamplerIndex("MySampler");
    m_d3dDevice->SetTexture(0, (LPDIRECT3DBASETEXTURE9)Texture->m_texture);
    m_d3dDevice->SetVertexShader(m_defaultShader->m_vertexShader);
    m_d3dDevice->SetPixelShader(m_defaultShader->m_pixelShader);
    m_d3dDevice->SetStreamSource(0, Texture->m_vertexBuffer, 0, 5 * sizeof(float));
    m_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 4);
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------//
// LoadVars
//
//---------------------------------------------------------------------------//  
void CMGEffect::LoadVars(CNodeFile::CNode *pNode)
{
  // Main vars
  m_CBAdjustToBPM->SetChecked(pNode->AsBool("adjusttobpm"   ));
  m_SBAdjustToBPM->Set       (pNode->AsInt ("adjusttobpmnum"));

  pNode = pNode->FirstNode("vars");
  if (!pNode) return;

  // Common vars
  CNodeFile::CNode *pNodeFXVars = pNode->FirstNode("effect");
  m_TBSpeed  ->SetPos  (pNodeFXVars->FirstNode("speed"  ) ? pNodeFXVars->FirstNode("speed"  )->AsInt("value") * 1.f/200.f : SpeedToTab(1.0f));
  m_TBAlpha  ->SetPos  (pNodeFXVars->FirstNode("alpha"  ) ? pNodeFXVars->FirstNode("alpha"  )->AsInt("value") * 1.f/200.f : 1.f);
               SetBlend(pNodeFXVars->FirstNode("blend"  ) ? pNodeFXVars->FirstNode("blend"  )->AsInt("value") : 0);
  m_CBQuality->Select  (pNodeFXVars->FirstNode("quality") ? pNodeFXVars->FirstNode("quality")->AsInt("value") : 0);
  m_SBFade   ->Set     (pNodeFXVars->FirstNode("fade"   ) ? pNodeFXVars->FirstNode("fade"   )->AsInt("value") : 250);

  // FX Vars
  m_VJFXVars->Load(pNodeFXVars);

  // Object Vars
  CNodeFile::CNode *pNodeObjVars = pNode->FirstNode("objvars");
  CNodeFile::CNode *pNodeObjVar = pNodeObjVars->FirstNode("objvar");
  while (pNodeObjVar)
  {
    long iScope = pNodeObjVar->AttrAsInt("scope", -1);
    int iObj   = pNodeObjVar->AttrAsInt("obj",   -1);
    if (iScope != -1 && iObj != -1 && iScope < (int)m_VJScopeVars.size() && iObj < (int)m_VJScopeVars[iScope].size())
      m_VJScopeVars[iScope][iObj]->Load(pNodeObjVar);
    pNodeObjVar = pNodeObjVar->NextNode("objvar");
  }
}
Exemplo n.º 9
0
CRenderingContext::CRenderingContext(CRenderer* pRenderer, bool bInherit)
{
	m_pRenderer = pRenderer;

	m_clrRender = ::Color(255, 255, 255, 255);

	s_aContexts.push_back();

	if (bInherit && s_aContexts.size() > 1)
	{
		CRenderContext& oLastContext = s_aContexts[s_aContexts.size()-2];
		CRenderContext& oThisContext = GetContext();

		oThisContext.m_mProjection = oLastContext.m_mProjection;
		oThisContext.m_mView = oLastContext.m_mView;
		oThisContext.m_mTransformations = oLastContext.m_mTransformations;

		oThisContext.m_hMaterial = oLastContext.m_hMaterial;
		oThisContext.m_pFrameBuffer = oLastContext.m_pFrameBuffer;
		tstrncpy(oThisContext.m_szProgram, PROGRAM_LEN, oLastContext.m_szProgram, PROGRAM_LEN);
		oThisContext.m_pShader = oLastContext.m_pShader;

		oThisContext.m_rViewport = oLastContext.m_rViewport;
		oThisContext.m_eBlend = oLastContext.m_eBlend;
		oThisContext.m_flAlpha = oLastContext.m_flAlpha;
		oThisContext.m_bDepthMask = oLastContext.m_bDepthMask;
		oThisContext.m_bDepthTest = oLastContext.m_bDepthTest;
		oThisContext.m_eDepthFunction = oLastContext.m_eDepthFunction;
		oThisContext.m_bCull = oLastContext.m_bCull;
		oThisContext.m_bWinding = oLastContext.m_bWinding;

		m_pShader = oThisContext.m_pShader;

		if (m_pShader)
			m_iProgram = m_pShader->m_iProgram;
		else
			m_iProgram = 0;
	}
	else
	{
		m_pShader = NULL;

		BindTexture(0);
		UseMaterial(CMaterialHandle());
		UseFrameBuffer(NULL);
		UseProgram("");

		SetViewport(Rect(0, 0, Application()->GetWindowWidth(), Application()->GetWindowHeight()));
		SetBlend(BLEND_NONE);
		SetAlpha(1);
		SetDepthMask(true);
		SetDepthTest(true);
		SetDepthFunction(DF_LESS);
		SetBackCulling(true);
		SetWinding(true);
	}
}
Exemplo n.º 10
0
void RendererCommon::ApplyRenderState(const SRenderState& RenderState) {
  SetCullMode(RenderState.m_CullMode);
  SetZEnable(RenderState.m_ZEnable);
  SetZWriteEnable(RenderState.m_ZWriteEnable);
  SetAlphaBlendEnable(RenderState.m_AlphaBlendEnable);

  if (m_RenderState.m_AlphaBlendEnable == EABE_True) {
    SetBlend(RenderState.m_SrcBlend, RenderState.m_DestBlend);
  }
}
Exemplo n.º 11
0
CRenderingContext::~CRenderingContext()
{
	TAssert(s_aContexts.size());

	s_aContexts.pop_back();

	if (s_aContexts.size())
	{
		CRenderContext& oContext = GetContext();

		UseMaterial(oContext.m_hMaterial);
		UseFrameBuffer(oContext.m_pFrameBuffer);
		UseProgram(oContext.m_pShader);

		if (*oContext.m_szProgram)
		{
			oContext.m_bProjectionUpdated = false;
			oContext.m_bViewUpdated = false;
			oContext.m_bTransformUpdated = false;
		}

		SetViewport(oContext.m_rViewport);
		SetBlend(oContext.m_eBlend);
		SetAlpha(oContext.m_flAlpha);
		SetDepthMask(oContext.m_bDepthMask);
		SetDepthTest(oContext.m_bDepthTest);
		SetDepthFunction(oContext.m_eDepthFunction);
		SetBackCulling(oContext.m_bCull);
		SetWinding(oContext.m_bWinding);
	}
	else
	{
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, 0);

		glBindFramebuffer(GL_FRAMEBUFFER, 0);
		if (m_pRenderer)
			glViewport(0, 0, (GLsizei)m_pRenderer->m_iWidth, (GLsizei)m_pRenderer->m_iHeight);
		else
			glViewport(0, 0, (GLsizei)Application()->GetWindowWidth(), (GLsizei)Application()->GetWindowHeight());

		glUseProgram(0);

		glDisablei(GL_BLEND, 0);

		glDepthMask(true);
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_CULL_FACE);
		glDepthFunc(GL_LESS);

		glFrontFace(GL_CCW);
	}
}
Exemplo n.º 12
0
void MythRenderOpenGL2::DrawBitmapPriv(uint *textures, uint texture_count,
                                       const QRectF *src, const QRectF *dst,
                                       uint prog)
{
    if (prog && !m_shader_objects.contains(prog))
        prog = 0;
    if (prog == 0)
        prog = m_shaders[kShaderDefault];

    uint first = textures[0];

    EnableShaderObject(prog);
    SetShaderParams(prog, &m_projection[0][0], "u_projection");
    SetShaderParams(prog, &m_transforms.top().m[0][0], "u_transform");
    SetBlend(false);

    EnableTextures(first);
    uint active_tex = 0;
    for (uint i = 0; i < texture_count; i++)
    {
        if (m_textures.contains(textures[i]))
        {
            ActiveTexture(GL_TEXTURE0 + active_tex++);
            glBindTexture(m_textures[textures[i]].m_type, textures[i]);
        }
    }

    m_glBindBuffer(GL_ARRAY_BUFFER, m_textures[first].m_vbo);
    UpdateTextureVertices(first, src, dst);
    m_glBufferData(GL_ARRAY_BUFFER, kVertexSize, NULL, GL_STREAM_DRAW);
    void* target = m_glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
    if (target)
        memcpy(target, m_textures[first].m_vertex_data, kVertexSize);
    m_glUnmapBuffer(GL_ARRAY_BUFFER);

    m_glEnableVertexAttribArray(VERTEX_INDEX);
    m_glEnableVertexAttribArray(TEXTURE_INDEX);

    m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE,
                            VERTEX_SIZE * sizeof(GLfloat),
                            (const void *) kVertexOffset);
    m_glVertexAttrib4f(COLOR_INDEX, 1.0, 1.0, 1.0, 1.0);
    m_glVertexAttribPointer(TEXTURE_INDEX, TEXTURE_SIZE, GL_FLOAT, GL_FALSE,
                            TEXTURE_SIZE * sizeof(GLfloat),
                            (const void *) kTextureOffset);

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    m_glDisableVertexAttribArray(TEXTURE_INDEX);
    m_glDisableVertexAttribArray(VERTEX_INDEX);
    m_glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Exemplo n.º 13
0
void GLRenderState::Bind()
{
  SetBlend(srcBlend, dstBlend);
  SetBlendFunc(blendFunc);
  SetAlphaTest(alphaTest, alphaRef);
  SetCull(cullMode);
  SetDepthTest(depthTest);
  SetDepthWrite(depthWrite);

/*
  if(!curState)
  {

    curState = this;
    return;
  }

  if(curState->GetSrcBlend()  != srcBlend ||
     curState->GetDstBlend()  != dstBlend)
  {
    SetBlend(srcBlend, dstBlend);
  }

  if(curState->GetBlendFunc() != blendFunc)
  {
    SetBlendFunc(blendFunc);
  }

  if(curState->GetAlphaTest() != alphaTest ||
     curState->GetAlphaRef()   != alphaRef)
  {
    SetAlphaTest(alphaTest, alphaRef);
  }

  if(curState->GetDepthTest() != depthTest)
  {
    SetDepthTest(depthTest);
  }

  if(curState->GetDepthWrite() != depthWrite)
  {
    SetDepthWrite(depthWrite);
  }

  if(curState->GetCullMode() != cullMode)
  {
    SetCull(cullMode);
  }
*/
  curState = this;
}
Exemplo n.º 14
0
void MythRenderOpenGL2::DrawRectPriv(const QRect &area, bool drawFill,
                                     const QColor &fillColor,  bool drawLine,
                                     int lineWidth, const QColor &lineColor,
                                     int prog)
{
    if (prog && !m_shader_objects.contains(prog))
        prog = 0;
    if (prog == 0)
        prog = m_shaders[kShaderSimple];

    EnableShaderObject(prog);
    SetShaderParams(prog, &m_projection[0][0], "u_projection");
    SetBlend(true);
    DisableTextures();

    m_glEnableVertexAttribArray(VERTEX_INDEX);

    if (drawFill)
    {
        m_glVertexAttrib4f(COLOR_INDEX,
                           fillColor.red() / 255.0,
                           fillColor.green() / 255.0,
                           fillColor.blue() / 255.0,
                           fillColor.alpha() / 255.0);
        GetCachedVBO(GL_TRIANGLE_STRIP, area);
        m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE,
                                VERTEX_SIZE * sizeof(GLfloat),
                               (const void *) kVertexOffset);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
        m_glBindBuffer(GL_ARRAY_BUFFER, 0);
    }

    if (drawLine)
    {
        glLineWidth(lineWidth);
        m_glVertexAttrib4f(COLOR_INDEX,
                           lineColor.red() / 255.0,
                           lineColor.green() / 255.0,
                           lineColor.blue() / 255.0,
                           lineColor.alpha() / 255.0);
        GetCachedVBO(GL_LINE_LOOP, area);
        m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE,
                                VERTEX_SIZE * sizeof(GLfloat),
                               (const void *) kVertexOffset);
        glDrawArrays(GL_LINE_LOOP, 0, 4);
        m_glBindBuffer(GL_ARRAY_BUFFER, 0);
    }

    m_glDisableVertexAttribArray(VERTEX_INDEX);
}
Exemplo n.º 15
0
void CTransVM::Update()
{
	if ( IClientEntity* pMe = Ifaces.pfnGetLocalPlayer() )
	{
		unsigned char blend = static_cast<unsigned char>( r_drawviewmodel->GetInt() );
		if ( blend==1 ) blend = 255;

		unsigned int index;

		// Overwrite alpha blend for the weapon entity
		index = reinterpret_cast<EHANDLE*>( (char*)pMe + off.hActiveWeapon )->entryindex();
		if ( IClientEntity* pWeapon = Ifaces.pEntityList->GetClientEntity( index ) )
		{
			SetBlend( pWeapon, blend );
		}

		// Overwrite alpha blend for the viewmodel
		index = reinterpret_cast<EHANDLE*>( (char*)pMe + off.hViewModel )->entryindex();
		if ( IClientEntity* pViewModel = Ifaces.pEntityList->GetClientEntity( index ) )
		{
			SetBlend( pViewModel, blend );
		}
	}
}
Exemplo n.º 16
0
mob2d_node::mob2d_node(pSprite sprite)
{
    angle = 0.0f;
	m_sprite = sprite;
	frame = x = y = 0;
    scale_x = scale_y = 1.0f;
    layer = 0.0f;

    animation = shader = "ERROR";

    draw_to_screen = false;
    loop = draw = true;

	SetBlend(255, 255, 255);
}
Exemplo n.º 17
0
void MythRenderOpenGL2::DrawBitmapPriv(uint tex, const QRect *src,
                                       const QRect *dst, uint prog, int alpha,
                                       int red, int green, int blue)
{
    if (prog && !m_shader_objects.contains(prog))
        prog = 0;
    if (prog == 0)
        prog = m_shaders[kShaderDefault];

    EnableShaderObject(prog);
    SetShaderParams(prog, &m_projection[0][0], "u_projection");
    SetShaderParams(prog, &m_transforms.top().m[0][0], "u_transform");
    SetBlend(true);

    EnableTextures(tex);
    glBindTexture(m_textures[tex].m_type, tex);

    m_glBindBuffer(GL_ARRAY_BUFFER, m_textures[tex].m_vbo);
    UpdateTextureVertices(tex, src, dst);
    m_glBufferData(GL_ARRAY_BUFFER, kVertexSize, NULL, GL_STREAM_DRAW);
    void* target = m_glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
    if (target)
        memcpy(target, m_textures[tex].m_vertex_data, kVertexSize);
    m_glUnmapBuffer(GL_ARRAY_BUFFER);

    m_glEnableVertexAttribArray(VERTEX_INDEX);
    m_glEnableVertexAttribArray(TEXTURE_INDEX);

    m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE,
                            VERTEX_SIZE * sizeof(GLfloat),
                            (const void *) kVertexOffset);
    m_glVertexAttrib4f(COLOR_INDEX, red / 255.0, green / 255.0, blue / 255.0, alpha / 255.0);
    m_glVertexAttribPointer(TEXTURE_INDEX, TEXTURE_SIZE, GL_FLOAT, GL_FALSE,
                            TEXTURE_SIZE * sizeof(GLfloat),
                            (const void *) kTextureOffset);

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    m_glDisableVertexAttribArray(TEXTURE_INDEX);
    m_glDisableVertexAttribArray(VERTEX_INDEX);
    m_glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Exemplo n.º 18
0
void UIDirect3D9Window::DrawTexture(D3D9Shader *Shader, D3D9Texture *Texture, QRectF *Dest, QSizeF *Size, bool &PositionChanged)
{
    if (!Shader || !Texture || !Dest || !m_d3dDevice || !Size)
        return;

    if (PositionChanged || !Texture->m_verticesUpdated)
    {
        PositionChanged = false;
        UpdateVertices(Texture, Dest, Size);
    }

    SetBlend(true);
    Shader->m_vertexConstants->SetMatrix(m_d3dDevice, "Projection", m_currentProjection);
    Shader->m_vertexConstants->SetMatrix(m_d3dDevice, "Transform", &m_transforms[m_currentTransformIndex].m);
    m_d3dDevice->SetTexture(0, (LPDIRECT3DBASETEXTURE9)Texture->m_texture);
    m_d3dDevice->SetVertexShader(Shader->m_vertexShader);
    m_d3dDevice->SetPixelShader(Shader->m_pixelShader);
    m_d3dDevice->SetStreamSource(0, Texture->m_vertexBuffer, 0, 5 * sizeof(float));
    m_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 4);
}
Exemplo n.º 19
0
void MythRenderOpenGL1::DrawBitmapPriv(uint tex, const QRect *src,
                                       const QRect *dst, uint prog, int alpha,
                                       int red, int green, int blue)
{
    if (prog && !m_programs.contains(prog))
        prog = 0;

    EnableShaderObject(prog);
    SetBlend(true);
    SetColor(red, green, blue, alpha);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    EnableTextures(tex);
    glBindTexture(m_textures[tex].m_type, tex);
    UpdateTextureVertices(tex, src, dst);
    glVertexPointer(2, GL_FLOAT, 0, m_textures[tex].m_vertex_data);
    glTexCoordPointer(2, GL_FLOAT, 0, m_textures[tex].m_vertex_data + TEX_OFFSET);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}
Exemplo n.º 20
0
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush,
                                     const QPen &linePen, int alpha)
{
    SetBlend(true);
    DisableTextures();
    EnableShaderObject(0);
    glEnableClientState(GL_VERTEX_ARRAY);

    int lineWidth = linePen.width();
    QRect r(area.left() + lineWidth, area.top() + lineWidth,
            area.width() - (lineWidth * 2), area.height() - (lineWidth * 2));

    if (fillBrush.style() != Qt::NoBrush)
    {
        int a = 255 * (((float)alpha / 255.0f) *
                       ((float)fillBrush.color().alpha() / 255.0f));
        SetColor(fillBrush.color().red(), fillBrush.color().green(),
                 fillBrush.color().blue(), a);
        GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, r);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }

    if (linePen.style() != Qt::NoPen)
    {
        int a = 255 * (((float)alpha / 255.0f) *
                       ((float)linePen.color().alpha() / 255.0f));
        SetColor(linePen.color().red(), linePen.color().green(),
                 linePen.color().blue(), a);
        glLineWidth(linePen.width());
        GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, r);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_LINE_LOOP, 0, 4);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
}
Exemplo n.º 21
0
void CMGEffect::OnBlendColMul () { SetBlend(BL_COLORMULTIPLY); }
Exemplo n.º 22
0
void CMGEffect::OnBlendInvMul () { SetBlend(BL_INVMULTIPLY  ); }
Exemplo n.º 23
0
void CMGEffect::OnBlendMul    () { SetBlend(BL_MULTIPLY     ); }
Exemplo n.º 24
0
void CMGEffect::OnBlendMask   () { SetBlend(BL_MASK         ); }
Exemplo n.º 25
0
void CMGEffect::OnBlendInvDest() { SetBlend(BL_INVERTDEST   ); }
Exemplo n.º 26
0
void CMGEffect::OnBlendInv    () { SetBlend(BL_INVERT       ); }
Exemplo n.º 27
0
void CMGEffect::OnBlendSub    () { SetBlend(BL_SUBTRACTIVE  ); }
Exemplo n.º 28
0
void CMGEffect::OnBlendAdd    () { SetBlend(BL_ADDITIVE     ); }
Exemplo n.º 29
0
//---------------------------------------------------------------------------//
// OnBlend
//
//---------------------------------------------------------------------------//
void CMGEffect::OnBlendAlpha  () { SetBlend(BL_ALPHABLEND   ); }
Exemplo n.º 30
0
//---------------------------------------------------------------------------//
// CreateControls
//
//---------------------------------------------------------------------------//  
void CMGEffect::CreateControls()
{
  m_PanelTitle  = NEW CMGPanel      (this, 0,0,0,25,  MGALIGN_TOP);
  m_GBVars      = NEW CMGGroupBox   (this, 0,0,0,140, MGALIGN_TOP);
  m_PCVars      = NEW CMGPageControl(this, 0,0,0,0,   MGALIGN_CLIENT);

  m_PageVars    = NEW CMGPage(m_PCVars, "Vars");
  m_PageObjects = NEW CMGPage(m_PCVars, "Objects");
  m_PageFilters = NEW CMGPage(m_PCVars, "Filters");
  m_PageOptions = NEW CMGPage(m_PCVars, "Options");

  // FX Title
  CMGLabel *pLTitle = NEW CMGLabel (m_PanelTitle,   2, 2, MGALIGN_NONE, FONT_FX_TITLE, m_FXName);
                      NEW CMGButton(m_PanelTitle, 260, 2, CMGButton::SMALL, "S", boost::bind(&CMGEffect::BtnSaveOnClick, this));

  // Speed
  m_BSpeedx1      = NEW CMGButton  (m_GBVars, 45,10, CMGButton::SMALL, "x1", boost::bind(&CMGEffect::BtnSpeedx1OnClick, this));
  m_LSpeed        = NEW CMGLabel   (m_GBVars, 5, 12, MGALIGN_NONE, FONT_NORMAL, "Speed");
  m_TBSpeed       = NEW CMGTrackBar(m_GBVars, 70,12, 200, false, boost::bind(&CMGEffect::TBSpeedOnChange, this));
  m_BSpeed        = NEW CMGButton  (m_GBVars, 272,10, CMGButton::SMALL, "B", boost::bind(&CMGEffect::BtnLinkSpeedOnClick, this));
  m_CBAdjustToBPM = NEW CMGCheckBox(m_GBVars, 70, 35, "Adjust Speed to BPM", true, boost::bind(&CMGEffect::CBAdjustOnChange, this));
  m_SBAdjustToBPM = NEW CMGSpinBox (m_GBVars, 207,35, 39, 0, 999, 1, boost::bind(&CMGEffect::SBAdjustOnChange, this));
                    NEW CMGLabel   (m_GBVars,  67, 2, MGALIGN_NONE, FONT_MINI, "-5");
                    NEW CMGLabel   (m_GBVars, 168, 2, MGALIGN_NONE, FONT_MINI, "0");
                    NEW CMGLabel   (m_GBVars, 265, 2, MGALIGN_NONE, FONT_MINI, "5");
  // Alpha
  m_LAlpha  = NEW CMGLabel   (m_GBVars, 5,62, MGALIGN_NONE, FONT_NORMAL, "Alpha");
  m_TBAlpha = NEW CMGTrackBar(m_GBVars, 70,62, 200, false, boost::bind(&CMGEffect::TBAlphaOnChange, this));
  m_BAlpha  = NEW CMGButton  (m_GBVars, 272,60, CMGButton::SMALL, "B", boost::bind(&CMGEffect::BAlphaOnClick, this));

  // Blend
  m_BlendButtons[0] = NEW CMGButton(m_GBVars, 70, 80, CMGButton::BLEND, "Alpha",   boost::bind(&CMGEffect::OnBlendAlpha  , this));
  m_BlendButtons[1] = NEW CMGButton(m_GBVars,110, 80, CMGButton::BLEND, "Add",     boost::bind(&CMGEffect::OnBlendAdd    , this));
  m_BlendButtons[2] = NEW CMGButton(m_GBVars,150, 80, CMGButton::BLEND, "Sub",     boost::bind(&CMGEffect::OnBlendSub    , this));
  m_BlendButtons[3] = NEW CMGButton(m_GBVars,190, 80, CMGButton::BLEND, "Inv",     boost::bind(&CMGEffect::OnBlendInv    , this));
  m_BlendButtons[4] = NEW CMGButton(m_GBVars,230, 80, CMGButton::BLEND, "InvDst",  boost::bind(&CMGEffect::OnBlendInvDest, this));
  m_BlendButtons[5] = NEW CMGButton(m_GBVars, 70,100, CMGButton::BLEND, "Mask",    boost::bind(&CMGEffect::OnBlendMask   , this));
  m_BlendButtons[6] = NEW CMGButton(m_GBVars,110,100, CMGButton::BLEND, "Mul",     boost::bind(&CMGEffect::OnBlendMul    , this));
  m_BlendButtons[7] = NEW CMGButton(m_GBVars,150,100, CMGButton::BLEND, "InvMul",  boost::bind(&CMGEffect::OnBlendInvMul , this));
  m_BlendButtons[8] = NEW CMGButton(m_GBVars,190,100, CMGButton::BLEND, "ColMul",  boost::bind(&CMGEffect::OnBlendColMul , this));

  // Set initial vars
  m_TBSpeed->SetPos(SpeedToTab(1.f));
  m_TBAlpha->SetPos(1.f);
  SetBlend(BL_ALPHABLEND);

  // FX Vars
  m_VJFXVars = NEW CMGPanelVars(m_PageVars, m_ID, -1, -1);

  // Object Vars
  CMGPanel *pPanelObjectVarsSup = NEW CMGPanel(m_PageObjects, 0,0,0,54, MGALIGN_TOP);
  m_CBScopes   = NEW CMGComboBox(pPanelObjectVarsSup, 80,4,  140, 100, true, boost::bind(&CMGEffect::CBScopeChange , this));
  m_CBObjects  = NEW CMGComboBox(pPanelObjectVarsSup, 80,28, 140, 100, true, boost::bind(&CMGEffect::CBObjectChange, this));
  m_ScopePanel = NEW CMGPanel   (m_PageObjects, 0,0,0,0, MGALIGN_CLIENT);
  vector<string> Scopes;
  g_pAppMain->VJController()->FXGetVarScopes(m_ID, Scopes);
  for (unsigned i = 0; i < Scopes.size(); i++)
  {
    m_CBScopes->Add(Scopes[i]);
    vector<string>         Objects;
    vector<CMGPanelVars *> Panels;
    g_pAppMain->VJController()->FXGetVarObjects(m_ID, Objects, i);
    for (unsigned j = 0; j < Objects.size(); j++)
    {
      CMGPanelVars *pPanel = NEW CMGPanelVars(NULL, m_ID, i,j);
      Panels.push_back(pPanel);
    }
    m_VJScopeVars.push_back(Panels);
  }

  // FX Filters
  m_FXFilters = NEW CMGFXFilters(m_PageFilters, this);

  // Set first
  if (Scopes.size() > 0)
    m_CBScopes->Select(0);

  // Options
  NEW CMGLabel(m_PageOptions, 7, 12, MGALIGN_NONE, FONT_NORMAL, "Render");
  char pBuffer[100];
  m_CBQuality = NEW CMGComboBox(m_PageOptions, 80,10, 140,100, true, boost::bind(&CMGEffect::CBQualityChange, this));
  sprintf_s(pBuffer, 100, "%dx%d", IAppOptions::GetInstance()->Get("Width",     0), IAppOptions::GetInstance()->Get("Height",    0));
  m_CBQuality->Add(pBuffer);
  sprintf_s(pBuffer, 100, "%dx%d", IAppOptions::GetInstance()->Get("CustTex1W", 0), IAppOptions::GetInstance()->Get("CustTex1H", 0));
  m_CBQuality->Add(pBuffer);
  sprintf_s(pBuffer, 100, "%dx%d", IAppOptions::GetInstance()->Get("CustTex2W", 0), IAppOptions::GetInstance()->Get("CustTex2H", 0));
  m_CBQuality->Add(pBuffer);
  m_CBQuality->Select(0);

             NEW CMGLabel  (m_PageOptions,  7, 42, MGALIGN_NONE, FONT_NORMAL, "Fade (ms)");
  m_SBFade = NEW CMGSpinBox(m_PageOptions, 80, 40, 50, 0, 5000, 50, boost::bind(&CMGEffect::SBFadeChange, this));
}