Пример #1
0
SlkToken::SlkToken(Dsl::IScriptSource& source, Dsl::ErrorAndStringBuffer& errorAndStringBuffer) :mSource(&source), mErrorAndStringBuffer(&errorAndStringBuffer)
{
  MyAssert(mSource);
  MyAssert(mErrorAndStringBuffer);

  mIterator = mSource->GetIterator();

  mWhiteSpaces = " \t\r\n";
  mDelimiters = ",;";
  mBeginParentheses = "([{";
  mEndParentheses = ")]}";
  mOperators = "~`!%^&*-+=|<>/?:";
  mSpecialChars = " \t\r\n,;([{)]}~`!%^&*-+=|<>/?:";


  mLineNumber = 1;
  mLastLineNumber = 1;

  mCurToken = 0;
  mLastToken = 0;
  mTokenCharIndex = 0;

  mCurComment = 0;
  mCommentCharIndex = 0;
  mCommentNum = 0;
  mCommentOnNewLine = FALSE;

  setCanFinish(FALSE);
  setStringDelimiter("", "");
  setScriptDelimiter("", "");
}
Пример #2
0
wxTreeItemId PanelObjectList::AddObject(void* pObject, PanelObjectListCallbackLeftClick pLeftClickFunction, PanelObjectListCallbackRightClick pRightClickFunction, wxTreeItemId parentid, const char* desc)
{
    MyAssert( pObject != 0 );

    wxTreeItemId newid;

    // get the root count before adding the item for check below.
    wxTreeItemId idroot = m_pTree_Objects->GetRootItem();
    int count = (int)m_pTree_Objects->GetChildrenCount( idroot, false );

    // insert the Object under it's parent node
    {
        TreeItemDataGenericObjectInfo* pData = MyNew TreeItemDataGenericObjectInfo();
        pData->m_pObject = pObject;
        pData->m_pLeftClickFunction = pLeftClickFunction;
        pData->m_pRightClickFunction = pRightClickFunction;

        newid = m_pTree_Objects->AppendItem( parentid, desc, -1, -1, pData );
        MyAssert( newid.IsOk() );

        // if inserting the first item, then expand the tree.
        if( count == 0 )
        {
            m_pTree_Objects->Expand( idroot );
        }
    }

    UpdateRootNodeObjectCount();

    return newid;
}
Пример #3
0
void MyTweener::SetChar(int index, char startvalue, char endvalue)
{
    MyAssert( m_ListOfVars[index] != 0 );
    MyAssert( m_ListOfVars[index]->m_VarType == MTVT_Char );

    ( (TweenChar*)m_ListOfVars[index] )->m_StartValue = startvalue;
    ( (TweenChar*)m_ListOfVars[index] )->m_EndValue = endvalue;
}
Пример #4
0
void MyTweener::SetInt(int index, int startvalue, int endvalue)
{
    MyAssert( m_ListOfVars[index] != 0 );
    MyAssert( m_ListOfVars[index]->m_VarType == MTVT_Int );

    ( (TweenInt*)m_ListOfVars[index] )->m_StartValue = startvalue;
    ( (TweenInt*)m_ListOfVars[index] )->m_EndValue = endvalue;
}
Пример #5
0
void MyTweener::SetFloat(int index, float startvalue, float endvalue)
{
    MyAssert( m_ListOfVars[index] != 0 );
    MyAssert( m_ListOfVars[index]->m_VarType == MTVT_Float );

    ( (TweenFloat*)m_ListOfVars[index] )->m_StartValue = startvalue;
    ( (TweenFloat*)m_ListOfVars[index] )->m_EndValue = endvalue;
}
Пример #6
0
void MySprite::Draw(MyMatrix* matviewproj, ShaderGroup* pShaderOverride)
{
    if( m_pMaterial == 0 || m_pMaterial->GetShader() == 0 )
        return;

    MyAssert( m_pVertexBuffer != 0 && m_pIndexBuffer != 0 );

    if( m_pVertexBuffer->m_Dirty )
        m_pVertexBuffer->Rebuild( 0, m_pVertexBuffer->m_DataSize );
    if( m_pIndexBuffer->m_Dirty )
        m_pIndexBuffer->Rebuild( 0, m_pIndexBuffer->m_DataSize );
    MyAssert( m_pIndexBuffer->m_Dirty == false && m_pVertexBuffer->m_Dirty == false );

    Shader_Base* pShader = 0;
    if( pShaderOverride )
    {
        // if an override for the shader is sent in, it's already active and doesn't want anything other than position set.
        pShader = (Shader_Base*)pShaderOverride->GlobalPass( 0, 4 );

        MyAssert( pShader );
        if( pShader == 0 )
            return;

        pShader->SetupAttributes( m_pVertexBuffer, m_pIndexBuffer, false );
        pShader->ProgramPosition( matviewproj, &m_Position );

        MyDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0 );
        pShader->DeactivateShader( m_pVertexBuffer );
    }
    else
    {
        pShader = (Shader_Base*)m_pMaterial->GetShader()->GlobalPass();

        MyAssert( pShader );
        if( pShader == 0 )
            return;

        // Enable blending if necessary. TODO: sort draws and only set this once.
        if( m_pMaterial->IsTransparent( pShader ) )
        {
            glEnable( GL_BLEND );
            glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        }

        if( pShader->ActivateAndProgramShader(
                m_pVertexBuffer, m_pIndexBuffer, GL_UNSIGNED_SHORT,
                matviewproj, &m_Position, m_pMaterial ) )
        {
            pShader->ProgramFramebufferSize( (float)g_GLStats.m_CurrentFramebufferWidth, (float)g_GLStats.m_CurrentFramebufferHeight );

            MyDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0 );
            pShader->DeactivateShader( m_pVertexBuffer );
        }

        // always disable blending
        glDisable( GL_BLEND );
    }
}
Пример #7
0
void MaterialManager::ReloadMaterial(MaterialDefinition* pMaterial)
{
    MyAssert( pMaterial );
    MyAssert( pMaterial->m_pFile );
    MyAssert( pMaterial->m_pFile->m_FileLoadStatus != FileLoadStatus_Success );

    m_MaterialsStillLoading.MoveTail( pMaterial );
    pMaterial->m_FullyLoaded = false;
}
Пример #8
0
// returns true if a new texture needs to be created.
bool FBODefinition::Setup(unsigned int width, unsigned int height, int minfilter, int magfilter, bool needcolor, int depthbits, bool depthreadable)
{
    MyAssert( width <= 4096 );
    MyAssert( height <= 4096 );

    unsigned int NewTextureWidth = 0;
    unsigned int NewTextureHeight = 0;

    // loop from 64 to 4096 and find appropriate size.
    for( unsigned int pow=6; pow<12; pow++ )
    {
        unsigned int powsize = (unsigned int)(1 << pow);

        if( powsize >= width && NewTextureWidth == 0 )
            NewTextureWidth = powsize;
        if( powsize >= height && NewTextureHeight == 0 )
            NewTextureHeight = powsize;
    }

    bool newtextureneeded = false;
    bool newfilteroptions = false;

    if( m_TextureWidth != NewTextureWidth || m_TextureHeight != NewTextureHeight )
        newtextureneeded = true;

    if( m_NeedColorTexture != needcolor || m_DepthBits != depthbits || m_DepthIsTexture != depthreadable )
        newtextureneeded = true;

    if( newtextureneeded == false && (m_MinFilter != minfilter || m_MagFilter != magfilter) )
        newfilteroptions = true;

    m_TextureWidth = NewTextureWidth;
    m_TextureHeight = NewTextureHeight;

    m_Width = width;
    m_Height = height;
    m_MinFilter = minfilter;
    m_MagFilter = magfilter;

    m_NeedColorTexture = needcolor;
    m_DepthBits = depthbits;
    m_DepthIsTexture = depthreadable;

    // if filter options changed, reset them on the texture
    if( newfilteroptions == true )
    {
        glBindTexture( GL_TEXTURE_2D, m_pColorTexture->m_TextureID );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_MinFilter );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_MagFilter );
        glBindTexture( GL_TEXTURE_2D, 0 );
    }

    return newtextureneeded;
}
Пример #9
0
void MaterialManager::RegisterMaterialCreatedCallback(void* pObj, MaterialCreatedCallbackFunc pCallback)
{
    MyAssert( pCallback != 0 );
    MyAssert( m_pMaterialCreatedCallbackList.Count() < MAX_REGISTERED_CALLBACKS );

    MaterialCreatedCallbackStruct callbackstruct;
    callbackstruct.pObj = pObj;
    callbackstruct.pFunc = pCallback;

    m_pMaterialCreatedCallbackList.Add( callbackstruct );
}
void* ComponentAnimationPlayer2D::OnValueChanged(ComponentVariable* pVar, bool changedByInterface, bool finishedChanging, double oldValue, ComponentVariableValue* pNewValue)
{
    void* oldpointer = 0;

    //if( pVar->m_Offset == MyOffsetOf( this, &m_TimeBetweenFrames ) )
    //{
    //    MyAssert( pVar->m_ControlID != -1 );
    //}

    if( strcmp( pVar->m_Label, "Animation File" ) == 0 )
    {
        if( changedByInterface )
        {
#if MYFW_USING_WX
            wxString text = g_pPanelWatch->GetVariableProperties( pVar->m_ControlID )->GetTextCtrl()->GetValue();
            if( text == "" || text == "none" || text == "no file" )
            {
                g_pPanelWatch->ChangeDescriptionForPointerWithDescription( pVar->m_ControlID, "no file" );
                oldpointer = m_pAnimationFile;
                // TODO: undo/redo
                this->SetAnimationFile( 0 );
            }
#endif //MYFW_USING_WX
        }
        else
        {
            MyAssert( false );
            // TODO: implement this block
        }
    }

    return oldpointer;
}
Пример #11
0
Component3DJointSlider& Component3DJointSlider::operator=(const Component3DJointSlider& other)
{
    MyAssert( &other != this );

    ComponentBase::operator=( other );

    // TODO: replace this with a CopyComponentVariablesFromOtherObject... or something similar.
    m_pSecondCollisionObject = other.m_pSecondCollisionObject;

    m_AxisA = other.m_AxisA;
    m_AxisB = other.m_AxisB;

    m_MotorEnabled = other.m_MotorEnabled;
    m_MotorSpeed = other.m_MotorSpeed;
    m_MotorMaxForce = other.m_MotorMaxForce;

    m_TranslationLimitEnabled = other.m_TranslationLimitEnabled;
    m_TranslationLimitMin = other.m_TranslationLimitMin;
    m_TranslationLimitMax = other.m_TranslationLimitMax;

    m_pJoint = other.m_pJoint;
    m_pBody = other.m_pBody;
    m_pSecondBody = other.m_pSecondBody;

    return *this;
}
Пример #12
0
void MaterialManager::FreeAllMaterials()
{
    while( CPPListNode* pNode = m_MaterialsStillLoading.GetHead() )
    {
        MyAssert( false );
        MyAssert( ((MaterialDefinition*)pNode)->GetRefCount() == 1 );
        ((MaterialDefinition*)pNode)->Release();
    }

    while( CPPListNode* pNode = m_Materials.GetHead() )
    {
        MyAssert( false );
        MyAssert( ((MaterialDefinition*)pNode)->GetRefCount() == 1 );
        ((MaterialDefinition*)pNode)->Release();
    }
}
Пример #13
0
void MenuSlider::Draw(MyMatrix* pMatProj, MyMatrix* pMatView)
{
    float centerx = m_PosX;
    float top = m_PosY;
    // TODO: take more justifications and vertical/horizontal into account for top and left.
    //       should ideally be done once instead of every frame.
    //if( m_Justification & Justify_Left )
    //{
    //    centerx += m_BarThickness/2;
    //}

    float emptypos = (m_PosY - m_VisualRange);

    MyAssert( m_pSprite );
    //m_pSprite = g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable];

    if( m_pSprite )
    {
        BufferManager* pBufferManager = m_pGameCore->GetManagers()->GetBufferManager();
        m_pSprite->Create( pBufferManager, "MenuSlider", m_BarThickness, m_VisualRange, 0, 1, 0, 1, Justify_CenterX|Justify_Top );
        MyMatrix world;
        world.SetIdentity();
        world.SetTranslation( centerx, top, 0 );
        //FIX m_pSprite->SetTint( m_Colors[MSCT_BarColor] );
        m_pSprite->Draw( pMatProj, pMatView, &world ); //&g_pGame->m_OrthoMatrix );

        m_pSprite->Create( pBufferManager, "MenuSlider", m_HandleWidth, m_HandleHeight, 0, 1, 0, 1, Justify_CenterX|Justify_Top );
        world.SetTranslation( centerx, emptypos + m_ValuePerc*m_VisualRange, 0 );
        //FIX m_pSprite->SetTint( m_Colors[MSCT_HandleColor] );
        m_pSprite->Draw( pMatProj, pMatView, &world ); //&g_pGame->m_OrthoMatrix );
    }
}
Пример #14
0
MaterialDefinition* MaterialManager::LoadMaterial(const char* fullpath)
{
    MyAssert( fullpath );

    MaterialDefinition* pMaterial;

    // check if this file was already loaded.
    pMaterial = FindMaterialByFilename( fullpath );
    if( pMaterial )
    {
        pMaterial->AddRef();
        return pMaterial;
    }

    pMaterial = MyNew MaterialDefinition();
    m_MaterialsStillLoading.AddTail( pMaterial );
    
    pMaterial->m_pFile = g_pFileManager->RequestFile( fullpath );

#if MYFW_USING_WX
    g_pPanelMemory->AddMaterial( pMaterial, "Loading", pMaterial->m_pFile->m_FilenameWithoutExtension, MaterialDefinition::StaticOnLeftClick, MaterialDefinition::StaticOnRightClick, MaterialDefinition::StaticOnDrag );
    g_pPanelMemory->SetLabelEditFunction( g_pPanelMemory->m_pTree_Materials, pMaterial, MaterialDefinition::StaticOnLabelEdit );
#endif

    return pMaterial;
}
Пример #15
0
void MyTweenPool::AddFloat(float* var, float startvalue, float endvalue, double tweentime, MyTweenType tweentype, double delay, bool updatewhiledelayed, int id)
{
    MyAssert( m_NumFloatsInUse < m_Floats.m_ListOfVars.Length() );

    m_Floats.SetFloat( m_NumFloatsInUse, var, startvalue, endvalue, tweentime, tweentype, delay + m_Floats.m_TimePassed, updatewhiledelayed, id );
    m_NumFloatsInUse++;
}
Пример #16
0
wxTreeItemId PanelObjectList::AddObject(void* pObject, PanelObjectListCallbackLeftClick pLeftClickFunction, PanelObjectListCallbackRightClick pRightClickFunction, const char* category, const char* desc)
{
    MyAssert( pObject != 0 );

    wxTreeItemId idroot = m_pTree_Objects->GetRootItem();
    //int count = (int)m_pTree_Objects->GetChildrenCount( idroot, false );

    // see if the category exists
    wxTreeItemId idcategory;
    {
        wxTreeItemIdValue cookie;
        idcategory = m_pTree_Objects->GetFirstChild( idroot, cookie );
        while( idcategory.IsOk() )
        {
            wxString catstr = m_pTree_Objects->GetItemText( idcategory );
            if( catstr == category )
                break;

            idcategory = m_pTree_Objects->GetNextChild( idroot, cookie );
        }
    }
    
    // insert the category if necessary
    if( idcategory.IsOk() == false )
    {
        idcategory = m_pTree_Objects->AppendItem( idroot, category, -1, -1, 0 );
    }

    return AddObject( pObject, pLeftClickFunction, pRightClickFunction, idcategory, desc );
}
Пример #17
0
void EditorCommand_PanelWatchColorChanged::Do()
{
    MyAssert( m_Type == PanelWatchType_ColorFloat || m_Type == PanelWatchType_ColorByte );

    double oldvalue = 0;

    if( m_Type == PanelWatchType_ColorFloat )
    {
        *(ColorFloat*)m_Pointer = m_NewColor;

        // TODO: same as below for colorfloats
    }
    else
    {
        // store the old color in a local var.
        // send the pointer to that var via callback in the double.
        // TODO: make 64-bit friendly, along with potentially a lot of other things.
        ColorByte oldcolor = *(ColorByte*)m_Pointer;
        *(int*)&oldvalue = (int)&oldcolor;

        // Update the ColorByte stored at the pointer.
        *(ColorByte*)m_Pointer = m_NewColor.AsColorByte();
    }

    g_pPanelWatch->UpdatePanel();

    // this could likely be dangerous, the object might not be in focus anymore and how it handles callbacks could cause issues.
    if( m_pCallbackObj && m_pOnValueChangedCallBackFunc )
    {
        m_pOnValueChangedCallBackFunc( m_pCallbackObj, m_ControlID, true, oldvalue );
    }
}
Пример #18
0
TextureDefinition* TextureManager::CreateTexture(const char* texturefilename, int minfilter, int magfilter, int wraps, int wrapt)
{
    MyAssert( texturefilename );

    LOGInfo( LOGTag, "CreateTexture - %s\n", texturefilename );

    // find the texture if it already exists:
    TextureDefinition* pTextureDef = FindTexture( texturefilename );
    if( pTextureDef != 0 )
    {
        pTextureDef->AddRef();
        return pTextureDef;
    }

    // Create a new texture and add it to m_TexturesStillLoading
    pTextureDef = MyNew TextureDefinition();
    pTextureDef->m_ManagedByTextureManager = true;
    strcpy_s( pTextureDef->m_Filename, MAX_PATH, texturefilename );
    pTextureDef->m_MinFilter = minfilter;
    pTextureDef->m_MagFilter = magfilter;
    pTextureDef->m_WrapS = wraps;
    pTextureDef->m_WrapT = wrapt;

    m_TexturesStillLoading.AddTail( pTextureDef );

    // if the file load hasn't started... start the file load.
    MyAssert( pTextureDef->m_pFile == 0 );
#if 0 //MYFW_ANDROID
    //LOGInfo( LOGTag, "Loading Texture: pTextureDef->m_pFile %d\n", pTextureDef->m_pFile );
    if( pTextureDef->m_pFile == 0 )
    {
        pTextureDef->m_pFile = RequestTexture( pTextureDef->m_Filename, pTextureDef );
        //textureloaded = true;
    }
#else
    if( pTextureDef->m_pFile == 0 )
    {
        //LOGInfo( LOGTag, "Loading Texture: RequestFile\n" );
        pTextureDef->m_pFile = RequestFile( pTextureDef->m_Filename );
        //LOGInfo( LOGTag, "Loading Texture: ~RequestFile\n" );
    }
#endif

    return pTextureDef;
}
Пример #19
0
void cJSONExt_ReplaceStringInJSONObject(cJSON* object, const char* newstring)
{
    MyAssert( !(object->type&cJSON_IsReference) && object->valuestring );
    if( !(object->type&cJSON_IsReference) && object->valuestring )
    {
        cJSON_free( object->valuestring );
        object->valuestring = cJSON_strdup( newstring );
    }
}
Пример #20
0
Vertex_Base* MySprite::GetVerts(bool markdirty)
{
    MyAssert( m_pVertexBuffer );

    if( markdirty )
        m_pVertexBuffer->m_Dirty = true;

    return (Vertex_Base*)m_pVertexBuffer->m_pData;
}
Пример #21
0
void TextureManager::FreeAllTextures(bool shuttingdown)
{
    for( CPPListNode* pNode = m_LoadedTextures.GetHead(); pNode; )
    {
        TextureDefinition* pTextureDef = (TextureDefinition*)pNode;
        pNode = pNode->GetNext();

        MyAssert( pTextureDef->GetRefCount() == 1 );
        pTextureDef->Release();
    }

    for( CPPListNode* pNode = m_TexturesStillLoading.GetHead(); pNode; )
    {
        TextureDefinition* pTextureDef = (TextureDefinition*)pNode;
        pNode = pNode->GetNext();

        MyAssert( pTextureDef->GetRefCount() == 1 );
        pTextureDef->Release();
    }

    for( CPPListNode* pNode = m_InitializedFBOs.GetHead(); pNode; )
    {
        FBODefinition* pFBODef = (FBODefinition*)pNode;
        pNode = pNode->GetNext();

        if( pFBODef->m_OnlyFreeOnShutdown == false || shuttingdown )
        {
            MyAssert( pFBODef->GetRefCount() == 1 );
            pFBODef->Release();
        }
    }

    for( CPPListNode* pNode = m_UninitializedFBOs.GetHead(); pNode; )
    {
        FBODefinition* pFBODef = (FBODefinition*)pNode;
        pNode = pNode->GetNext();

        if( pFBODef->m_OnlyFreeOnShutdown == false || shuttingdown )
        {
            MyAssert( pFBODef->GetRefCount() == 1 );
            pFBODef->Release();
        }
    }
}
Пример #22
0
ScoreChunk::ScoreChunk(MyActivePool<ScoreChunk*>* pPool)
: m_Color(255, 255, 255, 255)
, m_ShadowColor(0, 0, 0, 128)
{
    Reset();

    MyAssert( pPool );

    m_pScoreChunkPool = pPool;
}
Пример #23
0
int SoundPlayer::LoadSound(const char* buffer, unsigned int buffersize)
{
    LOGInfo( LOGTag, "NaCL SoundPlayer::LoadSound, buffersize:%d\n", buffersize );

    MyAssert( m_NumAudioBuffersLoaded < MAX_AUDIO_FILES );

    m_WaveDescriptors[m_NumAudioBuffersLoaded] = WaveLoader::ParseWaveBuffer( buffer, buffersize );
    MyAssert( m_WaveDescriptors[m_NumAudioBuffersLoaded].valid );

    LOGInfo( LOGTag, "NaCL SoundPlayer parsed, bytes:%d, channels:%d, samples:%d, size:%d\n", 
        m_WaveDescriptors[m_NumAudioBuffersLoaded].bytespersample,
        m_WaveDescriptors[m_NumAudioBuffersLoaded].numchannels,
        m_WaveDescriptors[m_NumAudioBuffersLoaded].samplerate,
        m_WaveDescriptors[m_NumAudioBuffersLoaded].datasize );

    m_NumAudioBuffersLoaded++;

    return m_NumAudioBuffersLoaded-1;
}
Пример #24
0
void EditorCommand_PanelWatchPointerChanged::Undo()
{
    MyAssert( m_Type == PanelWatchType_PointerWithDesc );

    *m_pPointer = m_OldValue;

    g_pPanelWatch->UpdatePanel();

    // this could likely be dangerous, the object might not be in focus anymore and how it handles callbacks could cause issues.
    if( m_pCallbackObj && m_pOnValueChangedCallBackFunc )
        m_pOnValueChangedCallBackFunc( m_pCallbackObj, m_ControlID, true, 0 );
}
Пример #25
0
SlkToken::SlkToken(Dsl::IScriptSource& source, Dsl::ErrorAndStringBuffer& errorAndStringBuffer) :mSource(&source), mErrorAndStringBuffer(&errorAndStringBuffer)
{
  MyAssert(mSource);
  MyAssert(mErrorAndStringBuffer);

  mIterator = mSource->GetIterator();

  mWhiteSpaces = " \t\r\n";
  mDelimiters = "()[]{},;";
  mOperators = "~`!%^&*-+=|<>/?:";

  mLineNumber = 1;
  mLastLineNumber = 1;
  mIsExternScript = FALSE;

  mCurToken = 0;
  mLastToken = 0;
  mTokenCharIndex = 0;

  setCanFinish(FALSE);
}
Пример #26
0
// will url encode var and value.
void WebRequestObject::RequestAddPair(const char* var, int value)
{
    MyAssert( IsBusy() == false );
    if( IsBusy() )
        return;

    char valuestring[20];
    sprintf_s( valuestring, 20, "%d", value );

    RequestAddPair( var, valuestring );

    //LOGInfo( LOGTag, "WebRequestObject - RequestAddPair %s\n", m_PageWanted );
}
Пример #27
0
void MySprite9::Draw(MyMatrix* matviewproj)
{
    if( m_pMaterial == 0 || m_pMaterial->GetShader() == 0 )

    MyAssert( m_pVertexBuffer != 0 && m_pIndexBuffer != 0 );

    if( m_pVertexBuffer->m_Dirty )
        m_pVertexBuffer->Rebuild( 0, m_pVertexBuffer->m_DataSize );
    if( m_pIndexBuffer->m_Dirty )
        m_pIndexBuffer->Rebuild( 0, m_pIndexBuffer->m_DataSize );
    MyAssert( m_pIndexBuffer->m_Dirty == false && m_pVertexBuffer->m_Dirty == false );

    Shader_Base* pShader = (Shader_Base*)m_pMaterial->GetShader()->GlobalPass();
    if( pShader == 0 )
        return;

    // Enable blending if necessary. TODO: sort draws and only set this once.
    if( m_pMaterial->IsTransparent( pShader ) )
    {
        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    }

    if( pShader->ActivateAndProgramShader(
            m_pVertexBuffer, m_pIndexBuffer, GL_UNSIGNED_SHORT, 
            matviewproj, &m_Position, m_pMaterial ) )
    {
#if USE_D3D
        g_pD3DContext->DrawIndexed( 6, 0, 0 );
        //g_pD3DContext->Draw( 6, 0 );
#else
        MyDrawElements( GL_TRIANGLE_STRIP, 24, GL_UNSIGNED_SHORT, 0 );
#endif
        pShader->DeactivateShader( m_pVertexBuffer );
    }

    // always disable blending
    glDisable( GL_BLEND );
}
Пример #28
0
bool MySprite::Setup(MyMatrix* matviewproj)
{
    if( m_pMaterial == 0 )
        return false;

    MyAssert( m_pVertexBuffer != 0 && m_pIndexBuffer != 0 );

    if( m_pVertexBuffer->m_Dirty )
        m_pVertexBuffer->Rebuild( 0, m_pVertexBuffer->m_DataSize );
    if( m_pIndexBuffer->m_Dirty )
        m_pIndexBuffer->Rebuild( 0, m_pIndexBuffer->m_DataSize );
    MyAssert( m_pIndexBuffer->m_Dirty == false && m_pVertexBuffer->m_Dirty == false );

    //TextureDefinition* pTexture = GetTexture();

    if( m_pMaterial->GetShader() == 0 )
        return false;

    Shader_Base* pShader = (Shader_Base*)m_pMaterial->GetShader()->GlobalPass();
    if( pShader == 0 )
        return false;

    // Enable blending if necessary. TODO: sort draws and only set this once.
    if( m_pMaterial->IsTransparent( pShader ) )
    {
        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    }

    bool activated = pShader->ActivateAndProgramShader(
                        m_pVertexBuffer, m_pIndexBuffer, GL_UNSIGNED_SHORT,
                        matviewproj, &m_Position, m_pMaterial );

    // always disable blending
    glDisable( GL_BLEND );

    return activated;
}
Пример #29
0
void WebRequestObject::RequestStart(const char* page)
{
    MyAssert( IsBusy() == false );
    if( IsBusy() )
        return;

    ClearResult();
    Reset();

    sprintf_s( m_PageWanted, MAX_URLLength, page );
    strcat_s( m_PageWanted, MAX_URLLength, "?" );

    //LOGInfo( LOGTag, "WebRequestObject - RequestStart %s\n", m_PageWanted );
}
Пример #30
0
EditorCommand_PanelWatchPointerChanged::EditorCommand_PanelWatchPointerChanged(void* newvalue, PanelWatch_Types type, void** ppointer, int controlid, PanelWatchCallbackValueChanged callbackfunc, void* callbackobj)
{
    MyAssert( type == PanelWatchType_PointerWithDesc );

    m_NewValue = newvalue;
    m_Type = type;
    m_pPointer = ppointer;
    m_ControlID = controlid;

    m_OldValue = *ppointer;

    m_pOnValueChangedCallBackFunc = callbackfunc;
    m_pCallbackObj = callbackobj;
}