// 'Draw' this control into the supplied vertex buffer object
//--------------------------------------------------------------------------------
void CPUTSlider::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize)
{
    // don't bother drawing if control is invisible, bad buffer pointers, etc
    if(!mControlVisible)
    {
        return;
    }
    if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
    {
        return;
    }
    if(!mpMirrorBufferActive || !mpMirrorBufferPressed)
    {
        return;
    }
    
    // Do we have enough room to put this control into the output buffer?
    int VertexCopyCount = GetOutputVertexCount();
    ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size.") );

    switch(mControlState)
    {
    case CPUT_CONTROL_ACTIVE:
        // copy the active+idle button into the stream
        if(CPUT_SLIDER_NIB_PRESSED == mSliderState)
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferPressed, sizeof(CPUTGUIVertex)*VertexCopyCount);
        }        
        else
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*VertexCopyCount);
        }
        
        break;
    case CPUT_CONTROL_INACTIVE:
        // copy the inactive button into the stream
        memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*VertexCopyCount);
        break;

    default:
        // error! unknown state
        ASSERT(0,_L("CPUTCheckbox: Control is in unknown state"));
        return;
    }

    // move the uber-buffer index the tail of what we just added
    // each new quad has 6 verts in it (and each vert has 3+2 floats in it).
    *pInsertIndex+=VertexCopyCount;


    // now do the text
    // draw the text
    if(mpControlText)
    {
        mpControlText->DrawIntoBuffer((CPUTGUIVertex*) pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);
    }

    // we'll mark the control as no longer being 'dirty'
    mControlGraphicsDirty = false;
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------
void CPUTText::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize)
{
    if(!mControlVisible)
    {
        return;
    }

    if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
    {
        return;
    }

    if(!mpMirrorBuffer) //  || !mpMirrorBufferDisabled)
    {
        return;
    }

    // Do we have enough room to put the text vertexes into the output buffer?
    int VertexCopyCount = GetOutputVertexCount();
    ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many characters to fit in allocated GUI string vertex buffer.\n\nIncrease CPUT_GUI_BUFFER_STRING_SIZE size.") );
    
    // copy the string quads into the target buffer
    memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBuffer, sizeof(CPUTGUIVertex)*6*mNumCharsInString);
    *pInsertIndex+=6*mNumCharsInString;
}
// 'Draw' this control into the supplied vertex buffer object
//--------------------------------------------------------------------------------
void CPUTCheckbox::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize)
{
    if(!mControlVisible)
    {
        return;
    }

    if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
    {
        return;
    }

    // Do we have enough room to put this control into the output buffer?
    int VertexCopyCount = GetOutputVertexCount();
    ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size.") );

    switch(mControlState)
    {
    case CPUT_CONTROL_ACTIVE:
        // copy the active+idle button into the stream
        if(CPUT_CHECKBOX_UNCHECKED == mCheckboxState)
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*6);
        }        

        // copy the pressed button into the stream
        if(CPUT_CHECKBOX_CHECKED == mCheckboxState)
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferPressed, sizeof(CPUTGUIVertex)*6);
        }
        
        break;
    case CPUT_CONTROL_INACTIVE:
        // copy the inactive button into the stream
        memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*6);
        break;

    default:
        // error! unknown state
        ASSERT(0,_L("CPUTCheckbox: Control is in unknown state"));
        return;
    }

    // move the index the correct number of floats to account
    // for 1 new quad, each quad with 6 verts in it (and each vert with 3+2 floats in it).
    *pInsertIndex+=6;


    // now do the text
    // draw the text
    if(mpCheckboxText)
    {
        mpCheckboxText->DrawIntoBuffer(pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);
    }

    // we'll mark the control as no longer being 'dirty'
    mControlGraphicsDirty = false;

}
Exemplo n.º 4
0
// 'Draw' this control into the supplied vertex buffer object
//--------------------------------------------------------------------------------
void CPUTButton::Draw(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize)
{
    if(!mControlVisible)
    {
        return;
    }

    // invalid output buffer pointers?
    if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
    {
        return;
    }

    // invalid buffer pointers?
    if(!mpMirrorBufferActive || !mpMirrorBufferPressed || !mpMirrorBufferDisabled)
    {
        return;
    }

    // Do we have enough room to put this control into the output buffer?
    int VertexCopyCount = GetOutputVertexCount();
    ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), "Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size." );
    
    switch(mControlState)
    {
    case CPUT_CONTROL_ACTIVE:
        // copy the active+idle button into the stream
        if(CPUT_BUTTON_NEUTRAL == mButtonState)
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*VertexCopyCount);
        }        

        // copy the pressed button into the stream
        if(CPUT_BUTTON_PRESSED == mButtonState)
        {
            memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferPressed, sizeof(CPUTGUIVertex)*VertexCopyCount);
        }
        
        break;
    case CPUT_CONTROL_INACTIVE:
        // copy the inactive button into the stream
        memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*VertexCopyCount);
        break;

    default:
        // error! unknown state
        ASSERT(0,"CPUTButton: Control is in unknown state");
        return;
    }

    // move the index the correct number of floats to account
    // for 9 new quads, each quad with 6 verts in it (and each vert with 3+2 floats in it).
    *pInsertIndex+= VertexCopyCount;

    if(mpButtonText)
        mpButtonText->Draw(pVertexBufferMirror, pInsertIndex, pMaxBufferSize);
}
Exemplo n.º 5
0
//--------------------------------------------------------------------------------
void CPUTDropdown::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize)
{
    if(!mControlVisible)
    {
        return;
    }

    if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
    {
        return;
    }

    if(!mpMirrorBufferActive )
    {
        return;    
    }

    // Do we have enough room to put this control into the output buffer?
    int VertexCopyCount = GetOutputVertexCount();
    ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size.") );
    
    switch(mControlState)
    {
    case CPUT_CONTROL_ACTIVE:          
        // copy the standard part of the control (selected box) - first 9 quads
        memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*6*9);
        *pInsertIndex+= 6*9;

        if((CPUT_DROPDOWN_GUI_MOUSE_PRESSED == mControlGuiState) )//&& (0 != mpListOfSelectableItems.size()))
        {
            // copy the 'down' button
            memcpy(&pVertexBufferMirror[*pInsertIndex], &mpMirrorBufferActive[10*6], sizeof(CPUTGUIVertex)*6*1);
        }
        else
        {
            // copy the 'up' button 
            memcpy(&pVertexBufferMirror[*pInsertIndex], &mpMirrorBufferActive[9*6], sizeof(CPUTGUIVertex)*6*1);
        }
        *pInsertIndex+= 6*1;

        // tray is down, draw it, +1 for the highlit item
        if((CPUT_DROPDOWN_GUI_MOUSE_PRESSED == mControlGuiState) && (0 != mpListOfSelectableItems.size()))
        {
            int QuadsInTray = 6;
            memcpy(&pVertexBufferMirror[*pInsertIndex], &mpMirrorBufferActive[11*6], sizeof(CPUTGUIVertex)*6*(QuadsInTray+1));
            *pInsertIndex+= 6*(QuadsInTray+1);
        }

        break;

    case CPUT_CONTROL_INACTIVE:
        // copy the inactive images into the stream
        memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*6*10);
        *pInsertIndex+= 6*10;
        break;

    default:
        // error! unknown state
        ASSERT(0,_L("CPUTButton: Control is in unknown state"));
        return;
    }


    // -- draw the text --
    // draw selected item in the selection list
    if(NULL!=mpSelectedItemCopy)
    {
        mpSelectedItemCopy->DrawIntoBuffer((CPUTGUIVertex*)pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);        
    }

    // draw the tray items
    if((CPUT_DROPDOWN_GUI_MOUSE_PRESSED == mControlGuiState) && (0 != mpListOfSelectableItems.size()))
    {
        for(UINT i=0;i<mpListOfSelectableItems.size();i++)
        {
            mpListOfSelectableItems[i]->DrawIntoBuffer((CPUTGUIVertex*)pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);
        }
    }
}