| 1 |
BALL_INLINE |
| 2 |
void GLRenderer::initTransparent() |
| 3 |
{ |
| 4 |
render_mode_ = RENDER_MODE_TRANSPARENT; |
| 5 |
glEnable(GL_DEPTH_TEST); |
| 6 |
glEnable(GL_BLEND); |
| 7 |
glDepthMask(GL_TRUE); |
| 8 |
} |
| 9 |
|
| 10 |
BALL_INLINE |
| 11 |
void GLRenderer::initSolid() |
| 12 |
{ |
| 13 |
render_mode_ = RENDER_MODE_SOLID; |
| 14 |
glEnable(GL_DEPTH_TEST); |
| 15 |
glDisable(GL_BLEND); |
| 16 |
glDepthMask(GL_TRUE); |
| 17 |
} |
| 18 |
|
| 19 |
BALL_INLINE |
| 20 |
void GLRenderer::initAlwaysFront() |
| 21 |
{ |
| 22 |
render_mode_ = RENDER_MODE_ALWAYS_FRONT; |
| 23 |
glDisable(GL_DEPTH_TEST); |
| 24 |
glDisable(GL_BLEND); |
| 25 |
glDepthMask(GL_TRUE); |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
// ############################ NAMING ################################### |
| 31 |
BALL_INLINE |
| 32 |
GLRenderer::Name GLRenderer::getName(const GeometricObject& object) |
| 33 |
{ |
| 34 |
const NameHashMap::Iterator name_iterator = object_to_name_.find(&object); |
| 35 |
|
| 36 |
if (name_iterator != object_to_name_.end()) |
| 37 |
{ |
| 38 |
return name_iterator->second; |
| 39 |
} |
| 40 |
|
| 41 |
const Name name = ++all_names_; |
| 42 |
|
| 43 |
object_to_name_.insert(NameHashMap::ValueType(&object, name)); |
| 44 |
name_to_object_.insert(GeometricObjectHashMap::ValueType(name, &object)); |
| 45 |
|
| 46 |
return name; |
| 47 |
} |
| 48 |
|
| 49 |
BALL_INLINE |
| 50 |
GeometricObject* GLRenderer::getObject(GLRenderer::Name name) const |
| 51 |
{ |
| 52 |
const GeometricObjectHashMap::ConstIterator it = name_to_object_.find(name); |
| 53 |
if (it == name_to_object_.end()) return 0; |
| 54 |
|
| 55 |
return (GeometricObject*) it->second; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
BALL_INLINE |
| 60 |
void GLRenderer::clearNames_() |
| 61 |
{ |
| 62 |
name_to_object_.clear(); |
| 63 |
object_to_name_.clear(); |
| 64 |
|
| 65 |
all_names_ = 0; |
| 66 |
} |
| 67 |
////////////////////////////////////////////////////////// |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
BALL_INLINE |
| 72 |
float GLRenderer::getXScale() const |
| 73 |
{ return x_scale_;} |
| 74 |
|
| 75 |
BALL_INLINE |
| 76 |
float GLRenderer::getYScale() const |
| 77 |
{ return y_scale_;} |
| 78 |
|
| 79 |
BALL_INLINE |
| 80 |
GLRenderer::RenderMode GLRenderer::getRenderMode() const |
| 81 |
{ return render_mode_;} |
| 82 |
|
| 83 |
BALL_INLINE |
| 84 |
void GLRenderer::setColor4ub_(const GeometricObject& object) |
| 85 |
{ setColorRGBA_(object.getColor()); } |
| 86 |
|
| 87 |
BALL_INLINE |
| 88 |
void GLRenderer::normalVector3_(const Vector3& v) |
| 89 |
{ glNormal3f((GLfloat)v.x, (GLfloat)v.y, (GLfloat)v.z);} |
| 90 |
|
| 91 |
BALL_INLINE |
| 92 |
void GLRenderer::vertexVector3_(const Vector3& v) |
| 93 |
{ glVertex3f((GLfloat)v.x, (GLfloat)v.y, (GLfloat)v.z); } |
| 94 |
|
| 95 |
BALL_INLINE |
| 96 |
void GLRenderer::translateVector3_(const Vector3& v) |
| 97 |
{ glTranslatef((GLfloat)v.x, (GLfloat)v.y, (GLfloat)v.z); } |
| 98 |
|
| 99 |
BALL_INLINE |
| 100 |
void GLRenderer::scaleVector3_(const Vector3& v) |
| 101 |
{ glScalef((GLfloat)v.x, (GLfloat)v.y, (GLfloat)v.z); } |
| 102 |
|
| 103 |
BALL_INLINE |
| 104 |
void GLRenderer::rotateVector3Angle_(const Vector3& v, Real angle) |
| 105 |
{ glRotatef(angle, v.x, v.y, v.z); } |
| 106 |
|
| 107 |
BALL_INLINE |
| 108 |
void GLRenderer::scale_(float f) |
| 109 |
{ glScalef(f, f, f);} |
| 110 |
|
| 111 |
BALL_INLINE |
| 112 |
void GLRenderer::setColorRGBA_(const ColorRGBA& color) |
| 113 |
{ |
| 114 |
//if (color == *last_color_) return; |
| 115 |
glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); |
| 116 |
// last_color_ = &color; |
| 117 |
} |
| 118 |
|
| 119 |
BALL_INLINE |
| 120 |
bool GLRenderer::vertexBuffersEnabled() const |
| 121 |
{ |
| 122 |
return use_vertex_buffer_; |
| 123 |
} |
| 124 |
|
| 125 |
BALL_INLINE |
| 126 |
DrawingMode GLRenderer::getDrawingMode() const { return drawing_mode_;} |