~callelejdfors/pyglew/trunk

« back to all changes in this revision

Viewing changes to src/storagesize.hh

  • Committer: Calle Lejdfors
  • Date: 2007-10-16 11:29:27 UTC
  • Revision ID: calle.lejdfors@cs.lth.se-20071016112927-b3xqwgsxy6r3zk7p
Tags: release-0.1.2
Added all project files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
//////////////////////////////////////////////////////////////////////////////////////////
 
3
// Copyright (C) 2005 Carl Johan Lejdfors                                               //
 
4
//                                                                                      //
 
5
// This program is free software; you can redistribute it and/or modify                 //
 
6
// it under the terms of the GNU General Public License as published by                 //
 
7
// the Free Software Foundation; either version 2 of the License, or                    //
 
8
// (at your option) any later version.                                                  //
 
9
//                                                                                      //
 
10
// This program is distributed in the hope that it will be useful,                      //
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of                       //
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                        //
 
13
// GNU General Public License for more details.                                         //
 
14
//                                                                                      //
 
15
// You should have received a copy of the GNU General Public License                    //
 
16
// along with this program; if not, write to the Free Software                          //
 
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            //
 
18
//                                                                                      //
 
19
// Please send all bugreports to: Carl Johan Lejdfors <calle.lejdfors@cs.lth.se>        //
 
20
//////////////////////////////////////////////////////////////////////////////////////////
 
21
 
 
22
#include "pyglew_exception.hh"
 
23
 
 
24
#ifndef __storagesize_hh__
 
25
#define __storagesize_hh__
 
26
 
 
27
size_t storagesize( GLenum type ) {
 
28
  switch ( type ) {
 
29
  case GL_UNSIGNED_BYTE:
 
30
    return sizeof(GLubyte);
 
31
  case GL_BYTE:
 
32
    return sizeof(GLbyte);
 
33
  case GL_UNSIGNED_SHORT:
 
34
    return sizeof(GLushort);
 
35
  case GL_SHORT:
 
36
    return sizeof(GLushort);
 
37
  case GL_UNSIGNED_INT:
 
38
    return sizeof(GLuint);
 
39
  case GL_INT:
 
40
    return sizeof(GLint);
 
41
  case GL_FLOAT:
 
42
    return sizeof(GLfloat);
 
43
  default:
 
44
    throw pyglew_exception("Error when determining storagesize for %d", type);
 
45
  };
 
46
}
 
47
 
 
48
#endif /* __storagesize_hh__ */