// Called every frame
void ULeapMotionImageComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
	Super::TickComponent( DeltaTime, TickType, ThisTickFunction );

	// ...
	if (!bIsPaused)
	{
		UpdateImageTexture();
	}
}
Пример #2
0
int main(int, char **)
{
    int argc = 2;
    const char* argv[] = { "main", "-glDebug" };
    glutInit(&argc, const_cast<char**>(&argv[0]));
    
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(g_winWidth, g_winHeight);
    glutInitWindowPosition(0, 0);

    g_win = glutCreateWindow(argv[0]);
    
#ifndef __APPLE__
    glewInit();
    if (!glewIsSupported("GL_VERSION_2_0"))
    {
        std::cout << "OpenGL 2.0 not supported" << std::endl;
        exit(1);
    }
#endif

    // Step 1: Initilize the OpenGL engine

    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);           // 4-byte pixel alignment

#ifndef __APPLE__
    glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE);     //
    glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE);   // avoid any kind of clamping
    glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); //
#endif

    glEnable(GL_TEXTURE_2D);
    glClearColor(0, 0, 0, 0);                        // background color
    glClearStencil(0);                               // clear stencil buffer

    // Step 2: Allocate the needed textures

    AllocateImageTexture();

    AllocateDefaultLut3D();

    // Step 3: Create the frame buffer and render buffer

    GLuint fboId;

    // create a framebuffer object, you need to delete them when program exits.
    glGenFramebuffers(1, &fboId);
    glBindFramebuffer(GL_FRAMEBUFFER, fboId);


    GLuint rboId;

    // create a renderbuffer object to store depth info
    glGenRenderbuffers(1, &rboId);
    glBindRenderbuffer(GL_RENDERBUFFER, rboId);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F_ARB, g_winWidth, g_winHeight);
    glBindRenderbuffer(GL_RENDERBUFFER, 0);

    // attach a texture to FBO color attachement point
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, g_imageTexID, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_3D, g_lut3dTexID, 0);

    // attach a renderbuffer to depth attachment point
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboId);

    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Step 4: Execute all the unit tests

    unsigned failures = 0;

    const UnitTests & tests = GetUnitTests();
    const size_t numTests = tests.size();
    for(size_t idx=0; idx<numTests; ++idx)
    {
        OCIOGPUTest* test = tests[idx];
        test->setup();

        const unsigned curr_failures = failures;
 
        // Set the rendering destination to FBO
        glBindFramebuffer(GL_FRAMEBUFFER, fboId);
        
        // Clear buffer
        glClearColor(0.1f, 0.1f, 0.1f, 0.1f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        std::cerr << "Test [" << test->group() << "] [" << test->name() << "] - ";

        try
        {
            // Update the image texture
            UpdateImageTexture();

            // Update the GPU shader program
            UpdateOCIOGLState(test->getProcessor());

            // Enable the shader program, and its textures
            glUseProgram(g_program);
            glUniform1i(glGetUniformLocation(g_program, "tex1"), 1);
            glUniform1i(glGetUniformLocation(g_program, "tex2"), 2);

            // Process the image texture into the rendering buffer
            Reshape();
            Redisplay();

            // Validate the processed image using the rendering buffer
            ValidateImageTexture(test->getProcessor(), test->getErrorThreshold());
        }
        catch(OCIO::Exception & ex)
        {
            ++failures;
            std::cerr << "FAILED - " << ex.what() << std::endl;
        }
        catch(...)
        {
            ++failures;
            std::cerr << "FAILED - Unexpected error" << std::endl;
        }

        if(curr_failures==failures)
        {
            std::cerr << "PASSED" << std::endl;
        }

        glUseProgram(0);

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }

    std::cerr << std::endl << failures << " tests failed" << std::endl << std::endl;
}