Пример #1
0
void ParticleUpsampling::initRendering(void)
{
    //glClearColor(0.5f, 0.5f, 0.5f, 1.0f); 
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);    

    NvAssetLoaderAddSearchPath("es2-aurora/ParticleUpsampling");

    m_sceneRenderer = new SceneRenderer(requireMinAPIVersion(NvGfxAPIVersionGL4(), false));

    CHECK_GL_ERROR();
}
Пример #2
0
void ComputeBasicGLSL::initRendering(void) 
{
    NvAssetLoaderAddSearchPath("ComputeBasicGLSL");

    if (!requireMinAPIVersion(NvGfxAPIVersionGL4()))
        return;

    //init shaders
    m_blitProg = NvGLSLProgram::createFromFiles("shaders/plain.vert", "shaders/plain.frag");

    m_computeProg = new NvGLSLProgram;
    int32_t len;
    NvGLSLProgram::ShaderSourceItem sources[1];
    sources[0].type = GL_COMPUTE_SHADER;
    sources[0].src = NvAssetLoaderRead("shaders/invert.glsl", len);
    m_computeProg->setSourceFromStrings(sources, 1);
    NvAssetLoaderFree((char*)sources[0].src);

    //load input texture 
    m_sourceImage = NvImage::CreateFromDDSFile("textures/flower1024.dds");
    m_sourceTexture = NvImage::UploadTexture(m_sourceImage);

    glBindTexture(GL_TEXTURE_2D, m_sourceTexture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glBindTexture(GL_TEXTURE_2D, 0);

    //create output texture with same size and format as input 
    GLint w = m_sourceImage->getWidth();
    GLint h = m_sourceImage->getHeight();
    GLint intFormat = m_sourceImage->getInternalFormat();
    GLint format = m_sourceImage->getFormat();
    GLint type = m_sourceImage->getType();

    glGenTextures(1, &m_resultTexture );
    glBindTexture(GL_TEXTURE_2D, m_resultTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, intFormat, w, h, 0, format, type, 0 );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    CHECK_GL_ERROR();

    glBindTexture(GL_TEXTURE_2D, 0);

    }
Пример #3
0
void ParticleUpsampling::initRendering(void)
{
    printGLString("Version",    GL_VERSION);
    printGLString("Vendor",     GL_VENDOR);
    printGLString("Renderer",   GL_RENDERER);
    printGLString("Extensions", GL_EXTENSIONS);

    GLint depthBits;
    glGetIntegerv(GL_DEPTH_BITS, &depthBits);
    LOGI("depth bits = %d\n", depthBits);

    //glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    NvAssetLoaderAddSearchPath("ParticleUpsampling");

    m_sceneRenderer = new SceneRenderer(requireMinAPIVersion(NvGfxAPIVersionGL4(), false));

    CHECK_GL_ERROR();
}
Пример #4
0
void MultiDrawIndirect::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}
Пример #5
0
// program entry
int32_t main(int32_t argc, char *argv[])
{
    GLFWwindow* window;
    int32_t width, height;

    NvAssetLoaderInit(NULL);

    sWindowIsFocused = true;
    sForcedRenderCount = 0;

    if( !glfwInit() )
    {
        fprintf( stderr, "Failed to initialize GLFW\n" );
        exit( EXIT_FAILURE );
    }

    glfwSetErrorCallback(glfwError);

    NvLinuxPlatformContext* platform = new NvLinuxPlatformContext;

    // add command line arguments
    for (int i = 1; i < argc; i++) {
        platform->m_commandLine.push_back(argv[i]);
    }

    sApp = NvAppFactory(platform);

    NvEGLConfiguration config(NvGfxAPIVersionGL4(), 8, 8, 8, 8, 16, 0);
    sApp->configurationCallback(config);

    // Does not seem to work...
/*
    if (config.api == GLAppContext::Configuration::API_ES)
        glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
    
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, config.majVer);
    //glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
    */

    NvGLLinuxAppContext* context = new NvGLLinuxAppContext(config);

    window = glfwCreateWindow( 1280, 720, "Linux SDK Application", NULL, NULL );
    if (!window)
    {
        fprintf( stderr, "Failed to open GLFW window\n" );
        glfwTerminate();
        exit( EXIT_FAILURE );
    }

    platform->setWindow(window);

    context->setWindow(window);
    sApp->setGLContext(context);

    // Set callback functions
    glfwSetFramebufferSizeCallback(window, reshape);
    glfwSetWindowFocusCallback(window, focus);
    setInputCallbacksGLFW(window);

    context->bindContext();
    glfwSwapInterval( 1 );

    glfwGetFramebufferSize(window, &width, &height);

    int32_t major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
    int32_t minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
    config.apiVer = NvGfxAPIVersion(NvGfxAPI::GL, major, minor);

    glGetIntegerv(GL_RED_BITS, (GLint*)&config.redBits);
    glGetIntegerv(GL_GREEN_BITS, (GLint*)&config.greenBits);
    glGetIntegerv(GL_BLUE_BITS, (GLint*)&config.blueBits);
    glGetIntegerv(GL_ALPHA_BITS, (GLint*)&config.alphaBits);
    glGetIntegerv(GL_DEPTH_BITS, (GLint*)&config.depthBits);
    glGetIntegerv(GL_STENCIL_BITS, (GLint*)&config.stencilBits);

    context->setConfiguration(config);

#if 1
    // get extensions (need for ES2.0)
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
      /* Problem: glewInit failed, something is seriously wrong. */
      fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
      exit(-1);
    }
    fprintf(stdout, "Using GLEW %s\n", glewGetString(GLEW_VERSION));
#endif

    // Parse command-line options
    initGL(argc, argv);

    reshape(window, width, height);

    sApp->mainLoop();

    // Shut down the app before shutting down GL
    delete sApp;

    // Terminate GLFW
    glfwTerminate();

    NvAssetLoaderShutdown();

    // Exit program
    exit( EXIT_SUCCESS );
}
Пример #6
0
void ComputeBasicGLSL::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}
void CascadedShadowMapping::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}
Пример #8
0
void NormalBlendedDecal::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}
Пример #9
0
void TerrainTessellation::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}
Пример #10
0
void ParticleUpsampling::configurationCallback(NvEGLConfiguration& config)
{
    config.depthBits = 24;
    config.stencilBits = 0;
    config.apiVer = NvGfxAPIVersionGL4();
}
Пример #11
0
void FXAA::configurationCallback(NvEGLConfiguration& config)
{ 
    config.depthBits = 24; 
    config.stencilBits = 0; 
    config.apiVer = NvGfxAPIVersionGL4();
}