Ignore:
Timestamp:
Mar 19, 2012, 9:04:34 PM (13 years ago)
Author:
ldelgass
Message:

remove global.h header. Move global Cg context handle into NvShader? as a
static member. Move LoadCgSourceProgram? to NvShader?.cpp, but make shader
classes use the methods NvShader::loadVertex/FragmentProgram instead.
There are still some users of LoadCgSourceProgram? left that need the context
handle.

File:
1 edited

Legend:

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

    r2863 r2870  
    6363#include "HeightMap.h"
    6464#include "NvCamera.h"
     65#include "NvEventLog.h"
     66#include "RenderContext.h"
     67#include "NvShader.h"
    6568#include "NvColorTableRenderer.h"
    66 #include "NvEventLog.h"
    6769#include "NvFlowVisRenderer.h"
    6870#include "NvLIC.h"
     
    7476#include "PointSet.h"
    7577#endif
    76 #include "RenderContext.h"
    7778#include "Switch.h"
    7879#include "Trace.h"
     
    8485
    8586#define SIZEOF_BMP_HEADER   54
    86 
    87 extern void NvInitCG(); // in Shader.cpp
    8887
    8988/// Indicates "up" axis
     
    192191
    193192PerfQuery *perf = NULL;                        //perfromance counter
    194 
    195 CGprogram m_passthru_fprog;
    196 CGparameter m_passthru_scale_param, m_passthru_bias_param;
    197193
    198194// Variables for mouse events
     
    360356    removeAllData();
    361357
     358    NvShader::exitCg();
     359
    362360#ifdef EVENTLOG
    363361    NvExitEventLog();
     
    373371    closelog();
    374372    exit(code);
    375 }
    376 
    377 CGprogram
    378 LoadCgSourceProgram(CGcontext context, const char *fileName, CGprofile profile,
    379                     const char *entryPoint)
    380 {
    381     const char *path = R2FilePath::getInstance()->getPath(fileName);
    382     if (path == NULL) {
    383         ERROR("can't find program \"%s\"\n", fileName);
    384     }
    385     TRACE("cg program compiling: %s\n", path);
    386     CGprogram program;
    387     program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile,
    388                                       entryPoint, NULL);
    389     cgGLLoadProgram(program);
    390     CGerror LastError = cgGetError();
    391     if (LastError) {
    392         ERROR("Error message: %s\n", cgGetLastListing(context));
    393     }
    394     TRACE("successfully compiled program: %s\n", path);
    395     delete [] path;
    396     return program;
    397373}
    398374
     
    719695void CgErrorCallback(void)
    720696{
    721     CGerror lastError = cgGetError();
    722 
    723     if (lastError) {
    724         TRACE("\n---------------------------------------------------\n");
    725         TRACE("%s\n\n", cgGetErrorString(lastError));
    726         TRACE("%s\n", cgGetLastListing(g_context));
    727         TRACE("-----------------------------------------------------\n");
     697    if (!NvShader::printErrorInfo()) {
    728698        TRACE("Cg error, exiting...\n");
    729         cgDestroyContext(g_context);
    730699        DoExit(-1);
    731700    }
     
    735704{
    736705    // print system information
    737     system_info();
     706    TRACE("-----------------------------------------------------------\n");
     707    TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
     708          glGetString(GL_VERSION));
     709    TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER));
     710    TRACE("-----------------------------------------------------------\n");
    738711
    739712    if (path == NULL) {
     
    758731    ImageLoaderFactory::getInstance()->addLoaderImpl("bmp", new BMPImageLoaderImpl());
    759732
    760     NvInitCG();
     733    NvShader::initCg();
    761734    NvShader::setErrorCallback(CgErrorCallback);
    762735
     
    774747    licRenderer = new NvLIC(NMESH, NPIX, NPIX, lic_axis,
    775748                            Vector3(lic_slice_x, lic_slice_y, lic_slice_z),
    776                             g_context);
     749                            NvShader::getCgContext());
    777750
    778751    grid = new Grid();
     
    841814    renderContext = new graphics::RenderContext();
    842815
    843     //create n 2D plane renderer
     816    //create a 2D plane renderer
    844817    plane_renderer = new PlaneRenderer(win_width, win_height);
    845818#if PROTOTYPE
Note: See TracChangeset for help on using the changeset viewer.