source: trunk/gui/vizservers/nanovis/global.h @ 390

Last change on this file since 390 was 377, checked in by qiaow, 19 years ago

Added PerfQuery? class for tracking number of pixels rendered on screen

File size: 2.5 KB
Line 
1/*
2 * ======================================================================
3 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
4 *           Purdue Rendering and Perceptualization Lab (PURPL)
5 *
6 *  Copyright (c) 2004-2006  Purdue Research Foundation
7 *
8 *  See the file "license.terms" for information on usage and
9 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 * ======================================================================
11 */
12
13
14//system wide global or static functions
15
16#ifndef _GLOBAL_H_
17#define _GLOBAL_H_
18
19#include <GL/glew.h>
20#include <Cg/cgGL.h>
21
22
23#define CHECK_FRAMEBUFFER_STATUS()                            \
24  {                                                           \
25    GLenum status;                                            \
26    status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); \
27    switch(status) {                                          \
28      case GL_FRAMEBUFFER_COMPLETE_EXT:                       \
29        break;                                                \
30      case GL_FRAMEBUFFER_UNSUPPORTED_EXT:                    \
31        /* choose different formats */                        \
32        break;                                                \
33      default:                                                \
34        /* programming error; will fail on all hardware */    \
35        fprintf(stderr, "programming error\n");               \
36        assert(0);                                            \
37     }                                                        \
38   }
39
40
41static CGprogram loadProgram(CGcontext context, CGprofile profile, CGenum program_type, char *filename)
42{
43  CGprogram program = cgCreateProgramFromFile(context, program_type, filename, profile, NULL, NULL);
44  cgGLLoadProgram(program);
45  return program;
46}
47
48static void draw_quad(int w, int h, int tw, int th)
49{
50    glBegin(GL_QUADS);
51    glTexCoord2f(0,         0);         glVertex2f(0,        0);
52    glTexCoord2f((float)tw, 0);         glVertex2f((float)w, 0);
53    glTexCoord2f((float)tw, (float)th); glVertex2f((float)w, (float) h);
54    glTexCoord2f(0,         (float)th); glVertex2f(0,        (float) h);
55    glEnd();
56}
57
58
59//query opengl information
60static void system_info(){
61  fprintf(stderr, "-----------------------------------------------------------\n");
62  fprintf(stderr, "OpenGL driver: %s %s\n", glGetString(GL_VENDOR), glGetString(GL_VERSION));
63  fprintf(stderr, "Graphics hardware: %s\n", glGetString(GL_RENDERER));
64  fprintf(stderr, "-----------------------------------------------------------\n");
65}
66
67
68#endif
Note: See TracBrowser for help on using the repository browser.