Ignore:
Timestamp:
Mar 23, 2012, 1:31:05 AM (13 years ago)
Author:
ldelgass
Message:

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/PerfQuery.h

    r2870 r2877  
    1616 * ======================================================================
    1717 */
    18 #ifndef _PERFQUERY_H_
    19 #define _PERFQUERY_H_
     18#ifndef PERFQUERY_H
     19#define PERFQUERY_H
    2020
    2121#include <stdio.h>
     
    2525#include "Trace.h"
    2626
    27 //check if occlusion query is supported
    28 inline bool check_query_support()
    29 {
    30     int bitsSupported = -1;
    31     glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
    32                     &bitsSupported);
    33     if (bitsSupported == 0) {
    34         TRACE("occlusion query not supported!\n");
    35         return false;
    36     } else {
    37         TRACE("Occlusion query with %d bits supported\n", bitsSupported);
    38         return true;
    39     }
    40 }
    41 
    4227class PerfQuery
    4328{
    4429public:
    45     GLuint id;
    46     int pixel;
    47    
    4830    PerfQuery();
    4931    ~PerfQuery();
    50    
     32
    5133    void enable();      //start counting how many pixels are rendered
    5234    void disable();     //stop counting
    5335
    5436    void reset()
    55     { 
    56         pixel = 0;
     37    {
     38        pixel = 0;
    5739    }
    5840
    59     int get_pixel_count()
     41    int getPixelCount()
    6042    {
    61         return pixel;           //return current pixel count
     43        return pixel;           //return current pixel count
    6244    }
     45
     46    static bool checkQuerySupport();
     47
     48    GLuint id;
     49    int pixel;
    6350};
    6451
     52//check if occlusion query is supported
     53inline bool PerfQuery::checkQuerySupport()
     54{
     55    if (!GLEW_ARB_occlusion_query) {
     56        TRACE("ARB_occlusion_query extension not supported\n");
     57        return false;
     58    }
     59    int bitsSupported = -1;
     60    glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
     61                    &bitsSupported);
     62    if (bitsSupported == 0) {
     63        TRACE("occlusion query not supported!\n");
     64        return false;
     65    } else {
     66        TRACE("Occlusion query with %d bits supported\n", bitsSupported);
     67        return true;
     68    }
     69}
    6570#endif
    6671
Note: See TracChangeset for help on using the changeset viewer.