vbo.hpp 3.07 KB
Newer Older
Mathieu Faverge's avatar
Mathieu Faverge committed
1 2 3 4 5 6 7 8
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
Thibault Soucarre's avatar
Thibault Soucarre committed
9
**
Mathieu Faverge's avatar
Mathieu Faverge committed
10 11 12 13 14
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
Thibault Soucarre's avatar
Thibault Soucarre committed
15
**
Mathieu Faverge's avatar
Mathieu Faverge committed
16 17 18 19 20 21 22 23 24 25
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
Thibault Soucarre's avatar
Thibault Soucarre committed
26
**
Mathieu Faverge's avatar
Mathieu Faverge committed
27 28 29 30 31 32 33 34 35 36 37 38 39
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
**
**        - COULOMB Kevin
**        - FAVERGE Mathieu
**        - JAZEIX Johnny
**        - LAGRASSE Olivier
**        - MARCOUEILLE Jule
**        - NOISETTE Pascal
**        - REDONDY Arthur
Thibault Soucarre's avatar
Thibault Soucarre committed
40
**        - VUCHENER Clément
Mathieu Faverge's avatar
Mathieu Faverge committed
41 42
**
*/
43 44 45 46 47 48
/*!
 *\file vbo.hpp
 */

#ifndef VBO_HPP
#define VBO_HPP
49 50 51
#include <vector>
#include "common/common.hpp"
using namespace std;
52

53
//macro used by OpenGL
54
#define BUFFER_OFFSET(a) ((char*)NULL + (a))
55 56 57 58 59 60

/*!
 * \brief Manage the Vertex Buffer Object.
 */
class Vbo{

61
private:
62 63 64 65
    GLuint _vboID;
    GLuint _vaoID;
    vector<Element_pos> _vertex;
    vector<Element_col> _colors;
66
    vector<char> _shaded;
67
    vector<float> _shaded2;
68 69
    GLenum _mode;
    int _nbVertex;
Olivier Lagrasse's avatar
Olivier Lagrasse committed
70 71 72 73 74

    /*!
     * \brief The default constructor. Cannot be use for instantiation.
     */

75 76
public:

77 78 79 80 81 82 83
    enum Type{
        TRIANGLES,
        QUADS,
        LINES
    };


84 85 86 87 88 89
    /***********************************
     *
     * Constructor and destructor.
     *
     **********************************/

Olivier Lagrasse's avatar
Olivier Lagrasse committed
90 91
   /*!
     * \brief Constructor.
92
     */
93
    Vbo();
94 95
    Vbo(GLenum mode);

96 97 98 99 100 101 102 103 104 105 106 107 108 109
    /*!
     * \brief The destructor.
     */
    virtual ~Vbo();



    /***********************************
     *
     * Buffer filling.
     *
     **********************************/


110
    int add(Element_pos x, Element_pos y, Element_col r, Element_col g, Element_col b);
111
    int add(Element_pos x, Element_pos y, char b);
112
    int add(Element_pos x, Element_pos y, float b);
Olivier Lagrasse's avatar
Olivier Lagrasse committed
113

114 115 116
    void lock();
    void unlock();
    int getNbVertex();
117
    void setNbVertex(int);
118
    void config(int glsl);
119

120 121
};

122
 #endif