コード例 #1
0
void GameConsole::applyPendingPropertyChanges() {
    if( !pendingPropertyChanges.isEmpty() ) {
        qCDebug( phxControl ) << "Applying pending property changes";
    }

    // Call each setter again if a pending change was set
    if( pendingPropertyChanges.contains( "aspectRatioMode" ) ) {
        setAspectRatioMode( pendingPropertyChanges[ "aspectRatioMode" ].toInt() );
    }

    if( pendingPropertyChanges.contains( "playbackSpeed" ) ) {
        setPlaybackSpeed( pendingPropertyChanges[ "playbackSpeed" ].toReal() );
    }

    if( pendingPropertyChanges.contains( "source" ) ) {
        setSource( pendingPropertyChanges[ "source" ].toMap() );
    }

    if( pendingPropertyChanges.contains( "volume" ) ) {
        setVolume( pendingPropertyChanges[ "volume" ].toReal() );
    }

    if( pendingPropertyChanges.contains( "vsync" ) ) {
        setVsync( pendingPropertyChanges[ "vsync" ].toBool() );
    }

    pendingPropertyChanges.clear();
}
コード例 #2
0
void MeshPrimitiveTest::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        if (x < 75 && y < 50)
        {
            // Toggle Vsync if the user touches the top left corner
            setVsync(!isVsync());
        }
        else
        {
            _touchPoint.set(x, y);
        }
        break;
    case Touch::TOUCH_RELEASE:
        _touchPoint.set(-1.0f, -1.0f);
        break;
    case Touch::TOUCH_MOVE:
        if (_touchPoint.x > 0.0f && _touchPoint.y > 0.0f)
        {
            float deltaX = x - _touchPoint.x;
            float deltaY = y - _touchPoint.y;
            _tilt.x -= deltaX;
            _tilt.y += deltaY;
            _touchPoint.set(x, y);
        }
        break;
    };
}
コード例 #3
0
void Audio3DTest::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        if (x < 75 && y < 50)
        {
            // Toggle Vsync if the user touches the top left corner
            setVsync(!isVsync());
        }
        _prevX = x;
        _prevY = y;
        break;
    case Touch::TOUCH_RELEASE:
        _prevX = 0;
        _prevY = 0;
        break;
    case Touch::TOUCH_MOVE:
    {
        int deltaX = x - _prevX;
        int deltaY = y - _prevY;
        _prevX = x;
        _prevY = y;
        float pitch = -MATH_DEG_TO_RAD(deltaY * 0.5f);
        float yaw = MATH_DEG_TO_RAD(deltaX * 0.5f);
        _fpCamera.rotate(yaw, pitch);
        break;
    }   
    };
}
コード例 #4
0
ファイル: TerrainSample.cpp プロジェクト: 03050903/GamePlay
void TerrainSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    if (evt == Touch::TOUCH_PRESS)
    {
        // If the FPS region is touched, toggle vsync (if platform supports it)
        if (x >= 65 && x < 300 && y >= 18 && y <= 48)
        {
            _vsync = !_vsync;
            setVsync(_vsync);
        }
        else if (_mode != MODE_LOOK)
        {
            // Ray sample
            Ray pickRay;
            _scene->getActiveCamera()->pickRay(Rectangle (0, 0, getWidth(), getHeight()), x, y, &pickRay);

            PhysicsController::HitResult hitResult;
            TerrainHitFilter hitFilter(_terrain);
            if (Game::getInstance()->getPhysicsController()->rayTest(pickRay, 1000000, &hitResult, &hitFilter) && hitResult.object == _terrain->getNode()->getCollisionObject())
            {
                Node* clone = NULL;
                PhysicsCollisionShape::Definition rbShape;

                switch (_mode)
                {
                case MODE_DROP_SPHERE:
                    {
                        clone = _sphere->clone();
                        rbShape = PhysicsCollisionShape::sphere();
                    }
                    break;

                case MODE_DROP_BOX:
                    {
                        clone = _box->clone();
                        rbShape = PhysicsCollisionShape::box();
                    }
                    break;
                }

                if (clone)
                {
                    clone->setScale(10,10,10);
                    clone->setTranslation(hitResult.point.x, hitResult.point.y + 50, hitResult.point.z);
                    PhysicsRigidBody::Parameters rbParams(1);
                    clone->setCollisionObject(PhysicsCollisionObject::RIGID_BODY, rbShape, &rbParams);
                    _scene->addNode(clone);
                    clone->release();

                    _shapes.push_back(clone);

                    _mode = MODE_LOOK;
                    setMessage(NULL);
                }
            }
        }
    }
}
コード例 #5
0
void FormsSample::initialize()
{
    setMultiTouch(true);
    setVsync(false);

    _formSelect = Form::create("res/common/forms/formSelect.form");
    _formSelect->setFocus();

    RadioButton* form0Button = static_cast<RadioButton*>(_formSelect->getControl("form0"));
    form0Button->addListener(this, Control::Listener::CLICK);

    RadioButton* form1Button = static_cast<RadioButton*>(_formSelect->getControl("form1"));
    form1Button->addListener(this, Control::Listener::CLICK);

    RadioButton* form2Button = static_cast<RadioButton*>(_formSelect->getControl("form2"));
    form2Button->addListener(this, Control::Listener::CLICK);
    
    RadioButton* form3Button = static_cast<RadioButton*>(_formSelect->getControl("form3"));
    form3Button->addListener(this, Control::Listener::CLICK);

    RadioButton* form4Button = static_cast<RadioButton*>(_formSelect->getControl("form4"));
    form4Button->addListener(this, Control::Listener::CLICK);
    
    RadioButton* form5Button = static_cast<RadioButton*>(_formSelect->getControl("form5"));
    form5Button->addListener(this, Control::Listener::CLICK);
    for (unsigned int i = 0; i < _formFiles.size(); i++)
    {
		Form* form = Form::create(_formFiles[i]);
        form->setEnabled(false);
        _forms.push_back(form);
    }
    _formIndex = 0;

    // Create a form programmatically.
    createSampleForm();

    Button* button = static_cast<Button*>(_forms[0]->getControl("testButton"));
    button->setFocus();

    // Create a scene with a camera node.
    Camera* camera = Camera::createPerspective(45.0f, (float)getWidth() / (float)getHeight(), 0.25f, 100.0f);
    _scene = Scene::create();
    Node* cameraNode = _scene->addNode("Camera");
    cameraNode->setCamera(camera);
    _scene->setActiveCamera(camera);
    SAFE_RELEASE(camera);
    _formNodeParent = _scene->addNode("FormParent");
    _formNode = Node::create("Form");
    _formNodeParent->addChild(_formNode);
    
    formChanged();

    _gamepad = getGamepad(0);
    // This is needed because the virtual gamepad is shared between all samples.
    // SamplesGame always ensures the virtual gamepad is disabled when a sample is exited.
    if (_gamepad && _gamepad->isVirtual())
        _gamepad->getForm()->setEnabled(true);
}
コード例 #6
0
ファイル: OWindow.cpp プロジェクト: Uliori/Origami
NS_O_BEGIN

OWindow::OWindow(const char* title, uint width, uint height, OApplication *app)
    :m_Title(title), m_Width(width), m_Height(height), m_Closed(false), m_Application(app)
{

    if (!init()) {
        OErrLog("Window initialization failed !");
        return;
    }
    setVsync(true);

    refreshInput();
}
コード例 #7
0
ファイル: CreateSceneSample.cpp プロジェクト: 1timmy/GamePlay
void CreateSceneSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        if (x < 75 && y < 50)
        {
            // Toggle Vsync if the user touches the top left corner
            setVsync(!isVsync());
        }
        break;
    case Touch::TOUCH_RELEASE:
        break;
    case Touch::TOUCH_MOVE:
        break;
    };
}
コード例 #8
0
ファイル: TriangleSample.cpp プロジェクト: 1timmy/GamePlay
void TriangleSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        if (x < 75 && y < 50)
        {
            // Toggle Vsync if the user touches the top left corner
            setVsync(!isVsync());
        }
        else
        {
            // Reverse the spin direction if the user touches the screen.
            _spinDirection *= -1.0f;
        }
        break;
    case Touch::TOUCH_RELEASE:
        break;
    case Touch::TOUCH_MOVE:
        break;
    };
}
コード例 #9
0
void multidrawindirect_app::onKey(int key, int action)
{
    if (action)
    {
        switch (key)
        {
            case 'P':
                paused = !paused;
                break;
            case 'V':
                vsync = !vsync;
                setVsync(vsync);
                break;
            case 'D':
                mode = MODE(mode + 1);
                if (mode > MODE_MAX)
                    mode = MODE_FIRST;
                break;
            case 'R':
                load_shaders();
                break;
        }
    }
}
コード例 #10
0
ファイル: Window.cpp プロジェクト: compix/Mesh-Decimator
bool Window::init(bool enableVsync, int oglMajorVersion, int oglMinorVersion)
{
    if (SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        SDL_ERROR_CHECK();
        return false;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);

    m_window = SDL_CreateWindow("Hello World!",
                                       SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                       m_width, m_height,
                                       SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);

    if (!m_window)
    {
        SDL_ERROR_CHECK();
        return false;
    }

#ifndef EMSCRIPTEN
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, oglMajorVersion);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, oglMinorVersion);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif

    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    m_context = SDL_GL_CreateContext(m_window);
    if (!m_context)
    {
        SHOW_ERROR("Failed to create OpenGL context. Make sure your GPU supports OpenGL " << oglMajorVersion << "." << oglMinorVersion);

        std::stringstream ss;
        ss << "Failed to create OpenGL context. Make sure your GPU supports OpenGL " << oglMajorVersion << "." << oglMinorVersion;
        showErrorBox("Context Creation Error", ss.str());
        return false;
    }

    setVsync(enableVsync);

	glewExperimental = GL_TRUE;
    GLenum err = glewInit();
	
    if (err != GLEW_OK)
    {
#ifdef EMSCRIPTEN
        SHOW_ERROR("Error " << err << " occured when initializing glew: \n");
#else
        const GLubyte *errString = gluErrorString(err);
        SHOW_ERROR("Error " << err << " occured when initializing glew: \n" << errString);
        std::stringstream ss;
        ss << "Error " << err << " occured when initializing glew: \n" << errString;
        showErrorBox("GLEW Initialization Error", ss.str());
#endif
        return false;
    }

    // OpenGL 3.2+ might mistakenly report an invalid enum error. Ignore it:
    glGetError();
    SDL_ERROR_CHECK();

    return true;
}