//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ) {
    if (currentMode == MODE_CONTROLLED_BY_MOUSE) {
        imageSectionHeading = ofRadToDeg(atan2(y-ofGetWindowHeight()/2, x-ofGetWindowWidth()/2));
        generateVBOs();
    }

}
//--------------------------------------------------------------
void testApp::setup() {

    // Set the mode for the program
//    currentMode = MODE_CONTROLLED_BY_MOUSE;
    currentMode = MODE_CONTROLLED_BY_ARDUINO;

    // Find the minimum dimension of the window for scaling the graphics
    // to fit on the screen
    minWindowDimension = min(ofGetWindowWidth(), ofGetWindowHeight());

    // Load the image
    image.loadImage("TownSunset.jpg");
    imageSectionCenter = ofVec2f(image.getWidth()/2, image.getHeight()/2);
    minImageDimension = min(image.getWidth(), image.getHeight());

    // Set up the initial variables that indicate where to sample the image
    imageSectionHeading = 90;
    triangleSlices = 20;
    triangleAngularWidth = 360.0/triangleSlices;
    rotationalSpeed = 15;

    // Generate the meshes that are used to take a slice of the image and
    // display it rotated and flipped around a circle
    vboMeshOriginal.setMode(OF_PRIMITIVE_TRIANGLES);
    vboMeshMirrored.setMode(OF_PRIMITIVE_TRIANGLES);
    generateVBOs();

    if (currentMode == MODE_CONTROLLED_BY_ARDUINO) initializeSerialReading();
}
Beispiel #3
0
void CPBox::ensureInitialized()
{
    if(!m_funcs) {
        m_funcs = new QOpenGLFunctions(QOpenGLContext::currentContext());
        generateVBOs();
        createShaderProgram();
    }
}
//--------------------------------------------------------------
void testApp::update() {
    if (currentMode == MODE_CONTROLLED_BY_ARDUINO) {
        processSerial();
        rotationalSpeed = ofMap(potValue, 0, 1023, -maxSpeed, maxSpeed);
        float elapsedTime = ofGetLastFrameTime();
        imageSectionHeading += rotationalSpeed * elapsedTime;
        generateVBOs();
    }

}