Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 92c0db369067be4564842a49ecddf55546a2e356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* 	gl.h
	This file is part of the Osirion project
*/

#ifndef __INCLUDED_OSIRIONGL_H__
#define __INCLUDED_OSIRIONGL_H__

// OpenGL headers
#include <GL/gl.h>

// project headers
#include "common/vector3f.h"
#include "common/color.h"

/// wrapper namespace for OpenGL operations
/*! The GL namespace provides a wrapper to the OpenGL library functions.
 *  All methods take floats or Vector3f and Color as parameters.
 */
namespace gl
{
	/// initialize the OpenGL subsystem
	void init();

	/// shutdown the OpenGL subsystem
	void shutdown();

	/// enum to denote Vertex drawing modes
	enum Primitive {
		Points=GL_POINTS,
		Lines=GL_LINES,
		LineStrip=GL_LINE_STRIP,
		LineLoop=GL_LINE_LOOP,
		Triangles=GL_TRIANGLES,
		TriangleStrip=GL_TRIANGLE_STRIP,
		TriangleFan=GL_TRIANGLE_FAN,
		Quads=GL_QUADS,
		QuadStrip=GL_QUAD_STRIP,
		Polygon=GL_POLYGON
	};


	/// glViewPort
	void viewport(GLint x, GLint y, GLsizei width, GLsizei height );

	/// set the color used to clear to buffer 
	void clearcolor(Color const &color);
	/// set the color used to clear to buffer 
	void clearcolor(const float r, const float g, const float b, const float a);

	/// clear buffers to preset values
	void clear (GLbitfield mask);

	/// glMatrixMode
	void matrixmode(GLenum mode);

	/// glEnable
	void enable(GLenum cap);

	/// glShadeModel
	void shademodel(GLenum mode);

	/// glCullFace
	void cullface(GLenum mode);

	/// glFrontFace
	void frontface(GLenum mode);


	/// glDepthMask
	void depthmask(GLenum mode);

	/// Delimite the start of a sequence of verteces describing a primitive or group of primitives
	/*!	@param primitive The type of drawing primitive
	 *  @see end()
	 */
	void begin(Primitive primitive);

	/// Delimit the end of a sequence of verteces describing a primitive or group of primitives
	/*! @see begin()
	 */
	void end();

	/// Add the next vertex the the current drawing operation
	/*! From the glVertex() description:
	 *  vertex() commands are used within begin()/end() pairs to specify point,
	 *	line, and polygon vertices.  The current color, normal, and texture
	 *	coordinates are associated with the vertex when vertex() is called.
	 */
	void vertex(const Vector3f& vector);
	
	void vertex(const float x, const float y, const float z);
	
	/// Multiply the current matrix by a general rotation matrix
	/*! @param angle The angle of the rotation, in degrees [0-360]
	 *  @param vector The rotation axes, relative to the origin (0,0,0)
	 */
	void rotate(const float angle, const Vector3f& vector);

	/// Multiply the current matrix by a general rotation matrix
	/*! @param angle The angle of the rotation, in degrees
	 *  @param x The x-coordinate of the rotation vector
	 *  @param y The y-coordinate of the rotation vector
	 *  @param z The z-coordinate of the rotation vector
	 */
	void rotate(const float angle, const float x, const float y, const float z);

	/// Multiply the current matrix by a general translation matrix
	/*! @param vector The translation vector, relative to the origin (0,0,0)
	 */
	void translate(const Vector3f& vector);

	/// Multiply the current matrix by a general translation matrix
	/*!
	 * @param x The x-coordinate of the translation vector
	 * @param y The y-coordinate of the translation vector
	 * @param z The z-coordinate of the translation vector
	 */
	void translate(const float x, const float y, const float z);

	/// Multiply the current matrix by a general scaling matrix
	/*! @param vector The scale factor for all 3 axes
	 */
	void scale(const Vector3f& vector);

	/// Multiply the current matrix by a general scaling matrix
	/*!
	 * @param x x-scaling factor
	 * @param y y-scaling factor
	 * @param z z-scaling factor
	 */
	void scale(const float x, const float y, const float z);

	/// Specify the drawing color for the next GL functions
	/*! @param color the new drawing color
	 */
	void color(Color const & color);
		
	/*! @param r red value of the new drawing color
	 *  @param g green value of the new drawing color
	 *  @param b blue value of the new drawing color
	 *  @param a alpha value of the new drawing color
	 */
	void color(const float r, const float g, const float b, const float a=1.0f);
	
	/// Push the current transformation matrix to the stack
	void push();
	
	/// Replace the transformation matrix with the top from the stack
	void pop();
	
	/// Replace the transformation matrix with the identity matrtix
	void loadidentity();

	/// Perspective matrix
	void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar);
};

#endif // __INCLUDED_OSIRIONGL_H__