Ejemplo n.º 1
0
void MySample::CreateInstancingControlButtons()
{
    CPUTGuiControllerOGL *pGUI = (CPUTGuiControllerOGL*)CPUTGetGuiController();
    CPUTButton *pButton;

	if(isInstanced)
	{
		pGUI->CreateButton(_L("Enable Instancing     "), TOGGLE_INSTANCING, ID_MAIN_PANEL, &pButton);
		pButton->SetAutoArranged(true);
		pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);
	}
	else
	{
		pGUI->CreateButton(_L("Disable Instancing"), TOGGLE_INSTANCING, ID_MAIN_PANEL, &pButton);
		pButton->SetAutoArranged(true);
		pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);
	}

	pToggleButton = pButton;
    pGUI->CreateButton(_L("Add Row                 "), ROW_INCREASE, ID_MAIN_PANEL, &pButton);
    pButton->SetAutoArranged(true);
    pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);

    pGUI->CreateButton(_L("Remove Row          "), ROW_DECREASE, ID_MAIN_PANEL, &pButton);
    pButton->SetAutoArranged(true);
    pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);

    pGUI->CreateButton(_L("Add Column           "), COLUMN_INCREASE, ID_MAIN_PANEL, &pButton);
    pButton->SetAutoArranged(true);
    pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);
   
    pGUI->CreateButton(_L("Remove Column    "), COLUMN_DECREASE, ID_MAIN_PANEL, &pButton);
    pButton->SetAutoArranged(true);
    pButton->SetDimensions(INSTANCING_BUTTON_SIZE, INSTANCING_BUTTON_SIZE);
}
Ejemplo n.º 2
0
// Pop up a message box with specified title/text
//-----------------------------------------------------------------------------
void CPUT_OGL::DrawLoadingFrame()
{
    DEBUG_PRINT(_L("DrawLoadingFrame()"));
    // fill first frame with clear values so render order later is ok
    const float srgbClearColor[] = { 0.0993f, 0.0993f, 0.0993f, 1.0f };
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);


    CPUTGuiControllerOGL *pGUIController = CPUTGuiControllerOGL::GetController();
    CPUTText *pText = NULL;
    pGUIController->CreateText(_L("Just a moment, now loading..."), 999, 0, &pText);

    pGUIController->EnableAutoLayout(false);
    int textWidth, textHeight;
    pText->GetDimensions(textWidth, textHeight);
    int width,height;
    mpWindow->GetClientDimensions(&width, &height);
    pText->SetPosition(width/2-textWidth/2, height/2);

    pGUIController->Draw();
    pGUIController->DeleteAllControls();
    pGUIController->EnableAutoLayout(true);
    
    // present loading screen
    Present();
    
}
Ejemplo n.º 3
0
// Instancing Controls for Touch interface
void MySample::PositionInstancingControlButtons(int width, int height)
{
    int offset = INSTANCING_BUTTON_SIZE * 2;
    int top = height - 2 * offset;
    int left = 0;

    CPUTGuiControllerOGL *pGUI = (CPUTGuiControllerOGL*)CPUTGetGuiController();
    
    CPUTControl* pControl = NULL;
    pControl = pGUI->GetControl(ROW_INCREASE);
    pControl->SetPosition(left + 0 * offset, top + 0 * offset);

    pControl = pGUI->GetControl(ROW_DECREASE);
    pControl->SetPosition(left + 1 * offset, top + 0 * offset);

    pControl = pGUI->GetControl(COLUMN_INCREASE);
    pControl->SetPosition(left + 0 * offset, top + 1 * offset);
	
    pControl = pGUI->GetControl(COLUMN_DECREASE);
    pControl->SetPosition(left + 1 * offset, top + 1 * offset);
	
    pControl = pGUI->GetControl(TOGGLE_INSTANCING);
    pControl->SetPosition(left + 2 * offset, top + 0 * offset);
}
Ejemplo n.º 4
0
void MySample::Create()
{
	CPUTAssetLibrary *pAssetLibrary = CPUTAssetLibrary::GetAssetLibrary();
    cString ExecutableDirectory;
    CPUTFileSystem::GetExecutableDirectory(&ExecutableDirectory);
    ExecutableDirectory.append(_L(ASSET_LOCATION));
    pAssetLibrary->SetMediaDirectoryName(ExecutableDirectory);

#ifdef ENABLE_GUI
    CPUTGuiControllerOGL *pGUI = (CPUTGuiControllerOGL*)CPUTGetGuiController();
    std::string mediaDirectory = ws2s(pAssetLibrary->GetMediaDirectoryName());
    std::string fontDirectory("Font/");
    CPUTFont *pFont = CPUTFont::CreateFont(SYSTEM_LOCATION + fontDirectory, "arial_64.fnt");

    pGUI->SetFont(pFont);

    //
    // Create some controls
    //   
	CPUTDropdown *pDropdownMethod;
	
	pGUI->CreateText(_L("Test Font"), ID_IGNORE_CONTROL_ID, ID_MAIN_PANEL, &pTextMethod);
	pTextMethod->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
	CreateInstancingControlButtons();
#endif

	CPUTFileSystem::GetExecutableDirectory(&ExecutableDirectory);
    ExecutableDirectory.append(_L(ASSET_LOCATION));
    pAssetLibrary->SetMediaDirectoryName(ExecutableDirectory);


    int width, height;
    mpWindow->GetClientDimensions(&width, &height);
    DEBUG_PRINT(_L("Resize Window"));

    ResizeWindow(width, height);

    mpScene = new CPUTScene();
    DEBUG_PRINT(_L("Load Scene"));

    // Load the scene
    if (CPUTFAILED(mpScene->LoadScene(SCENE_FILE)))
    {
        LOGI("Failed to Load Scene, try loading asset set individually");
        CPUTAssetSet *pAssetSet = NULL;
        pAssetSet = pAssetLibrary->GetAssetSet( ASSET_SET_FILE );
        mpScene->AddAssetSet(pAssetSet);
        pAssetSet->Release();
    }
    LOGI("Loaded the scene");

    // Get the camera. Get the first camera encountered in the scene or
    // if there are none, create a new one.
    unsigned int numAssets = mpScene->GetNumAssetSets();
    for (unsigned int i = 0; i < numAssets; ++i) {
        CPUTAssetSet *pAssetSet = mpScene->GetAssetSet(i);
        if (pAssetSet->GetCameraCount() > 0) {
            mpCamera = pAssetSet->GetFirstCamera();
            break;
        }
    }

    // Create the camera
    if (mpCamera == NULL)
    {
        mpCamera = new CPUTCamera();
        pAssetLibrary->AddCamera( _L(""), _L("SampleStart Camera"), _L(""), mpCamera );
		
		mpCamera->SetPosition( 0.0f, cameraY, 100.0f );

        // Set the projection matrix for all of the cameras to match our window.
        // TODO: this should really be a viewport matrix.  Otherwise, all cameras will have the same FOV and aspect ratio, etc instead of just viewport dimensions.
        mpCamera->SetAspectRatio(((float)width)/((float)height));
    }

    mpCamera->SetFov(DegToRad(90.0)); // TODO: Fix converter's FOV bug (Maya generates cameras for which fbx reports garbage for fov)
    mpCamera->SetFarPlaneDistance(100000.0f);
    mpCamera->Update();

    mpCameraController = new CPUTCameraControllerFPS();
    mpCameraController->SetCamera(mpCamera);
    mpCameraController->SetLookSpeed(0.004f);
    mpCameraController->SetMoveSpeed(150.0f);

	// retrieve function pointer
    glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) ( eglGetProcAddress( "glDrawElementsInstanced" ) );


    if( glDrawElementsInstancedEXT == NULL )
    {
        LOGE( "Failed to load extension pointer" );
    }
	
	currentRowCount = NUM_ROWS / 1.5;
	currentColCount = NUM_COLUMNS;
	
	LOGI("Getting handles for materials");

	// get handles to switch instancing / non instancing
	pAssetLibrary->PrintAssetLibrary();

	supportMaterial = pAssetLibrary->GetMaterialByName("instanceV2/Material/concreteMultiMaterial.mtl");
	techMaterial = pAssetLibrary->GetMaterialByName("instanceV2/Material/techALowMultiMataterial.mtl");

	isInstanced = true;
	
	CPUTModel *pModel = pAssetLibrary->GetModelByName( _L( ".instangeGrptechALow" ) );
	pModel->SetDrawModelCallBack((DrawModelCallBackFunc)drawCallback);
	pModel = pAssetLibrary->GetModelByName( _L( ".instangeGrpconcrete" ) );
	pModel->SetDrawModelCallBack((DrawModelCallBackFunc)drawCallback);

	UINT supportCount = supportMaterial->GetMaterialEffectCount();
	UINT techCount = techMaterial->GetMaterialEffectCount();

	glFrontFace(GL_CW);
    UpdateMatrixBuffers();
}