Changeset 3875 for trunk


Ignore:
Timestamp:
Aug 20, 2013 5:52:39 PM (11 years ago)
Author:
ldelgass
Message:

Add config.h option USE_ARB_PROGRAMS, which will use ARB_vertex/fragment_program
extensions as the Cg compile target instead of NV_vertex_program3 and
NV_fragment_program2. Note that glyph texture style rendering in flows will not
work if this define is set (however, the default style is line arrows which will
work).

Location:
trunk/packages/vizservers/nanovis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Shader.cpp

    r3630 r3875  
    1212#include <util/FilePath.h>
    1313
     14#include "config.h"
    1415#include "Shader.h"
    1516#include "Trace.h"
     
    1819using namespace nv::util;
    1920
     21/**
     22 * These correspond to NV_vertex_program3 and NV_fragment_program2:
     23 * CG_PROFILE_VP40
     24 * CG_PROFILE_FP40
     25 *
     26 * These correspond to ARB_vertex_program and ARB_fragment_program:
     27 * CG_PROFILE_ARBVP1
     28 * CG_PROFILE_ARBFP1
     29 *
     30 * Generic GLSL targets:
     31 * CG_PROFILE_GLSLV
     32 * CG_PROFILE_GLSLF
     33 */
     34#ifdef USE_ARB_PROGRAMS
     35CGprofile Shader::_defaultVertexProfile = CG_PROFILE_ARBVP1;
     36CGprofile Shader::_defaultFragmentProfile = CG_PROFILE_ARBFP1;
     37#else
    2038CGprofile Shader::_defaultVertexProfile = CG_PROFILE_VP40;
    2139CGprofile Shader::_defaultFragmentProfile = CG_PROFILE_FP40;
     40#endif
    2241CGcontext Shader::_cgContext = NULL;
    2342
  • trunk/packages/vizservers/nanovis/Shader.h

    r3630 r3875  
    4949    void loadFragmentProgram(const char *fileName);
    5050
     51    bool isVertexProgramLoaded()
     52    {
     53        return (getVP() == NULL);
     54    }
     55
     56    bool isFragmentProgramLoaded()
     57    {
     58        return (getFP() == NULL);
     59    }
     60
    5161    void setVPParameter1f(const char *name, float val)
    5262    {
     
    284294    void resetPrograms();
    285295
    286 
    287296    CGprogram getVP()
    288297    {
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r3630 r3875  
    6565    _queryVelocityFP.loadFragmentProgram("queryvelocity.cg");
    6666
    67     _particleShader.loadVertexProgram("velocityslicevp.cg");
    68     _particleShader.loadFragmentProgram("velocityslicefp.cg");
     67    // Delay loading of shaders only required for glyph style rendering
     68    if (_renderMode == GLYPHS) {
     69        _particleShader.loadVertexProgram("velocityslicevp.cg");
     70        _particleShader.loadFragmentProgram("velocityslicefp.cg");
     71    }
    6972
    7073    createRenderTarget();
     
    362365                    continue;
    363366                }
    364                 if (length > 1.0e-6) {
     367                if (length > 0.0) {
    365368                    Vector3f vnorm = vel.normalize();
    366369                    Vector3f rotationAxis = refVec.cross(vnorm);
     
    414417        glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
    415418
     419        // FIXME: This vertex shader won't compile with ARB_vertex_program,
     420        // so it should use GLSL
     421        if (!_particleShader.isVertexProgramLoaded()) {
     422            _particleShader.loadVertexProgram("velocityslicevp.cg");
     423        }
     424        if (!_particleShader.isFragmentProgramLoaded()) {
     425            _particleShader.loadFragmentProgram("velocityslicefp.cg");
     426        }
     427
    416428        _particleShader.bind();
    417429        _particleShader.setVPTextureParameter("vfield", _vectorFieldGraphicsID);
     
    458470    Vector3f bmin, bmax;
    459471    volume->getBounds(bmin, bmax);
    460     _origin = bmin;
     472    _origin.set(bmin.x, bmin.y, bmin.z);
    461473    _scale.set(bmax.x-bmin.x, bmax.y-bmin.y, bmax.z-bmin.z);
    462474
  • trunk/packages/vizservers/nanovis/config.h

    r3599 r3875  
    3838
    3939/*
     40 * If defined, use ARB_vertex_program and ARB_fragment_program as Cg
     41 * profile target, otherwise NV_vertex_program3 and NV_fragment_program2
     42 * are required
     43 */
     44//#define USE_ARB_PROGRAMS
     45
     46/*
    4047 * Keep statistics
    4148 */
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r3630 r3875  
    504504    }
    505505#endif
    506     // FIXME: should use ARB programs or (preferably) a GLSL profile for portability
     506    // FIXME: should use GLSL for portability
     507#ifdef USE_ARB_PROGRAMS
     508    if (!GLEW_ARB_vertex_program ||
     509        !GLEW_ARB_fragment_program) {
     510        ERROR("ARB_vertex_program and ARB_fragment_program extensions are required");
     511        return false;
     512    }
     513#else
    507514    if (!GLEW_NV_vertex_program3 ||
    508515        !GLEW_NV_fragment_program2) {
     
    510517        return false;
    511518    }
     519#endif
    512520
    513521    if (!FilePath::getInstance()->setPath(path)) {
Note: See TracChangeset for help on using the changeset viewer.