Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "tango-gl/drawable_object.h"
00018 #include "tango-gl/shaders.h"
00019
00020 namespace tango_gl {
00021
00022 void DrawableObject::SetShader() {
00023 shader_program_ =
00024 util::CreateProgram(shaders::GetBasicVertexShader().c_str(),
00025 shaders::GetBasicFragmentShader().c_str());
00026 if (!shader_program_) {
00027 LOGE("Could not create program.");
00028 }
00029 uniform_mvp_mat_ = glGetUniformLocation(shader_program_, "mvp");
00030 attrib_vertices_ = glGetAttribLocation(shader_program_, "vertex");
00031 uniform_color_ = glGetUniformLocation(shader_program_, "color");
00032 }
00033
00034 void DrawableObject::DeleteGlResources() {
00035 if (shader_program_) {
00036 glDeleteShader(shader_program_);
00037 }
00038 }
00039
00040 void DrawableObject::SetColor(float red, float green, float blue) {
00041 red_ = red;
00042 green_ = green;
00043 blue_ = blue;
00044 }
00045 void DrawableObject::SetColor(const Color& color) {
00046 SetColor(color.r, color.g, color.b);
00047 }
00048
00049 void DrawableObject::SetAlpha(const float alpha) { alpha_ = alpha; }
00050
00051 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices) {
00052 vertices_ = vertices;
00053 }
00054
00055 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices,
00056 const std::vector<GLushort>& indices) {
00057 vertices_ = vertices;
00058 indices_ = indices;
00059 }
00060
00061 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices,
00062 const std::vector<GLfloat>& normals) {
00063 vertices_ = vertices;
00064 normals_ = normals;
00065 }
00066 }