Commit 620c9fa1 authored by Thibault Soucarre's avatar Thibault Soucarre

New class Shader. Render_alternate can draw containers, states and links....

New class Shader. Render_alternate can draw containers, states and links. Scaling and position of the camera aren't correct. Files vertexshader and fragmentshader should be copied to the directory of the binary file. No changes when using Render_opengl
parent c6475b04
......@@ -249,12 +249,14 @@ IF(VITE_ENABLE_VBO)
SET(VITE_HDRS
${VITE_HDRS}
render/vbo.hpp
render/Shader.hpp
render/Render_alternate.hpp
)
SET(VITE_SRCS
${VITE_SRCS}
render/vbo.cpp
render/Shader.cpp
render/Render_alternate.cpp
)
ENDIF(VITE_ENABLE_VBO)
......
......@@ -45,7 +45,7 @@
*\brief This is the console interface C source code.
*/
#include <GL/glew.h>
#include <queue>
#include <string>
#include <iostream>
......
......@@ -67,10 +67,12 @@
#include "render/Ruler.hpp"
#include "render/Render_alternate.hpp"
#include "render/GanttDiagram.hpp"
#include "render/Shader.hpp"
/* -- */
#include "core/Core.hpp"
#include "render/vbo.hpp"
#include <iostream>
#define PI 3.14159265
using namespace std;
......@@ -81,7 +83,7 @@ static bool _draw_container;
static bool _draw_ruler;
static bool _draw_arrow;
static bool _draw_event;
const int Render_alternate::DRAWING_TIMER_DEFAULT = 10;
//const int Render_alternate::DRAWING_TIMER_DEFAULT = 10;
/***********************************
*
......@@ -94,16 +96,10 @@ const int Render_alternate::DRAWING_TIMER_DEFAULT = 10;
**********************************/
Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format)
: Hook_event(this, core, parent, format){
_arrows.clear();
_circles.clear();
_texts.clear();
_vbos.clear();
: Hook_event(this, core, parent, format), _containers(GL_QUADS), _states(GL_QUADS), _events(GL_POLYGON), _arrows(GL_LINE), _counters(GL_LINE), _shader("vertexshader.vertexshader", "fragmentshader.fragmentshader"), _modelview(glm::mat4(1.0)){
setAutoFillBackground(false);
}
......@@ -121,16 +117,22 @@ Render_alternate::~Render_alternate(){
**********************************/
void Render_alternate::initializeGL() {
glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if(err!=GLEW_OK)
std::cout << "ERROR : GlewInit failed" << std::endl;
_shader.charger();
glClearColor(0.5f, 0.5f, 0.55f, 0.0f);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_DEPTH_TEST);
glClearStencil(0);
//glClearStencil(0);
std::cout << "init" << std::endl;
if(_core == NULL)
std::cout << "_core = NULL" << std::endl;
_core->waitGUIInit->quit();
std::cout << "init ok" << std::endl;
_modelview = glm::scale(_modelview, glm::vec3(0.01,-0.01,1));
}
void Render_alternate::resizeGL(int width, int height) {
......@@ -160,199 +162,252 @@ void Render_alternate::resizeGL(int width, int height) {
void Render_alternate::paintGL(){
//glClearColor(0.0, 1.0, 0.0, 1.0);
resizeGL(Render_alternate::QGLWidget::width(), Render_alternate::QGLWidget::height());
Render_alternate::QGLWidget::setFocus(Qt::ActiveWindowFocusReason);/* give the focus to the render area for mouse and keyboard events */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//select shader program
glUseProgram(_shader.getProgramID());
std::cout << "paintGL" << std::endl;
/* drawing containers*/
_containers.lock();
//_modelview = glm::translate(_modelview, glm::vec3(0.0f, _ruler_y + _ruler_height -_y_state_translate, _z_container));
//_modelview = glm::scale(_modelview, glm::vec3(_x_scale_container_state/0.20, _y_state_scale, 1.0));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glDrawArrays(GL_QUADS, 0, _containers.getNbVertex());
_containers.unlock();
/*drawing states*/
_states.lock();
glm::mat4 tmp = _modelview;
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, 0.0, 0.0));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glDrawArrays(GL_QUADS, 0, _states.getNbVertex());
_states.unlock();
_modelview = tmp;
/*drawing links*/
/*_arrows.lock();
tmp = _modelview;
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, 0 , 0));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glDrawArrays(GL_LINES, 0, _arrows.getNbVertex());
_arrows.unlock();
_modelview = tmp;*/
int n = _links.size()/4;
for(int i=0; i<n ; i++){
_arrows.lock();
//save current modelview
tmp = _modelview;
//change matrix
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, 0 , 0));
_modelview = glm::translate(_modelview, glm::vec3(_links[4*i+2], _links[4*i+3], 0));
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
_modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));
//draw the arrow
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glDrawArrays(GL_LINES, 0,6);
_arrows.unlock();
//restore matrix
_modelview = tmp;
}
// _containers.display(_modelview);
//rendu
//deselect shader
glUseProgram(0);
// Render_alternate::QGLWidget::setFocus(Qt::ActiveWindowFocusReason);/* give the focus to the render area for mouse and keyboard events */
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// glClearDepth(1.0);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glLoadIdentity();
if(DRAWING_STATE_WAITING == _state){/* A wait is drawn */
/* turn around y axis */
_wait_angle+=0.1f;
if (_wait_angle>=360) _wait_angle=0.0f;
// if(DRAWING_STATE_WAITING == _state){/* A wait is drawn */
glPushMatrix();
// /* turn around y axis */
// _wait_angle+=0.1f;
// if (_wait_angle>=360) _wait_angle=0.0f;
glScalef(15, 15, 0);
// glPushMatrix();
glRotatef(-_wait_angle,0, 1, 0);
glRotatef(_wait_angle_y, 1, 0, 0);
// glScalef(15, 15, 0);
// glRotatef(-_wait_angle,0, 1, 0);
// glRotatef(_wait_angle_y, 1, 0, 0);
glPopMatrix();
// glPopMatrix();
}else if (DRAWING_STATE_DRAWING == _state){/* A trace is drawn */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
{
glTranslated(0.0, Info::Render::height, 100.0);
glRotated(180.0, 1.0, 0.0, 0.0);
// }else if (DRAWING_STATE_DRAWING == _state){/* A trace is drawn */
// glMatrixMode(GL_MODELVIEW);
// glLoadIdentity();
// glPushMatrix();
// {
// glTranslated(0.0, Info::Render::height, 100.0);
// glRotated(180.0, 1.0, 0.0, 0.0);
glPushMatrix();
{
glTranslated(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, 0.0);
glScalef(_x_state_scale, _y_state_scale, 1.0);
// glPushMatrix();
// {
for (unsigned int i=0 ;
i<_vbos.size() ;
i++){
_vbos[i]->display();
}
}
glPopMatrix();
// glTranslated(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, 0.0);
// glScalef(_x_state_scale, _y_state_scale, 1.0);
call_ruler();
// for (unsigned int i=0 ;
// i<_vbos.size() ;
// i++){
// _vbos[i]->display();
// }
// }
// glPopMatrix();
// call_ruler();
if (false == Info::Render::_no_arrows)/* display arrows */
draw_stored_arrows();
if (false == Info::Render::_no_events)/* display events */
draw_stored_circles();
// if (false == Info::Render::_no_arrows)/* display arrows */
// draw_stored_arrows();
}
glPopMatrix();
// if (false == Info::Render::_no_events)/* display events */
// draw_stored_circles();
glPushMatrix();
{
glTranslated(0.0, 0.0, 100.0);/* not accurate */
// }
// glPopMatrix();
if (_mouse_pressed){
// glPushMatrix();
// {
// glTranslated(0.0, 0.0, 100.0);/* not accurate */
// if (_mouse_pressed){
glTranslated(0.0, 0.0, _z_container_under);
Element_pos old_x, old_y, new_x, new_y;
// glTranslated(0.0, 0.0, _z_container_under);
// Element_pos old_x, old_y, new_x, new_y;
old_x = _mouse_x*(Info::Render::width/Info::Screen::width);
old_y = Info::Render::height - _mouse_y*(Info::Render::height/Info::Screen::height);
new_x = _new_mouse_x*(Info::Render::width/Info::Screen::width);
new_y = Info::Render::height - _new_mouse_y*(Info::Render::height/Info::Screen::height);
#ifdef DEBUG_MODE_RENDER_OPENGL
// old_x = _mouse_x*(Info::Render::width/Info::Screen::width);
// old_y = Info::Render::height - _mouse_y*(Info::Render::height/Info::Screen::height);
// new_x = _new_mouse_x*(Info::Render::width/Info::Screen::width);
// new_y = Info::Render::height - _new_mouse_y*(Info::Render::height/Info::Screen::height);
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl;
#endif
// #ifdef DEBUG_MODE_RENDER_OPENGL
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
// cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl;
// #endif
/* Square for selection */
glBegin(GL_QUADS);
{
glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y);
glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y);
}
glEnd();
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
// /* Square for selection */
// glBegin(GL_QUADS);
// {
// glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y);
// glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y);
// glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y);
// glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y);
// }
// glEnd();
}/* end if (true==_mouse_pressed) */
}
glPopMatrix();
// glDisable(GL_BLEND);
// }/* end if (true==_mouse_pressed) */
// }
// glPopMatrix();
}else{
message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
}
glFlush();
// }else{
// message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende;
// }
// glFlush();
/* Check the errors */
GLenum glerror;
glerror = glGetError();
if(glerror != GL_NO_ERROR)
message << tr("Render area : the following OpengGL error occured: ").toStdString() << (char *)gluErrorString(glerror) << Message::endw;
// /* Check the errors */
// GLenum glerror;
// glerror = glGetError();
// if(glerror != GL_NO_ERROR)
// message << tr("Render area : the following OpengGL error occured: ").toStdString() << (char *)gluErrorString(glerror) << Message::endw;
if(DRAWING_STATE_WAITING == _state)/* A wait is drawn, do not take car about the ruler drawing */
return;
QFont arial_font = QFont("Arial", 10);
qglColor(Qt::white);//QColor(0, 0, 0));
// if(DRAWING_STATE_WAITING == _state)/* A wait is drawn, do not take car about the ruler drawing */
// return;
// QFont arial_font = QFont("Arial", 10);
// qglColor(Qt::white);//QColor(0, 0, 0));
/* Draw container text */
const unsigned int texts_size = _texts.size();
for (unsigned int i=0 ; i<texts_size ; i++){
const QFontMetrics metric(arial_font);
const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/3.);
renderText ( render_to_screen_x(_texts[i].x * _x_scale_container_state/0.20),
render_to_screen_y( trace_to_render_y(_texts[i].y) + 0.5),
text_elided,
arial_font);
}
/* Draw ruler text */
std::ostringstream buf_txt;
Element_pos graduation_diff;
Element_pos coeff_prefix;
graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
coeff_prefix = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
// /* Draw container text */
// const unsigned int texts_size = _texts.size();
// for (unsigned int i=0 ; i<texts_size ; i++){
// const QFontMetrics metric(arial_font);
// const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/3.);
// renderText ( render_to_screen_x(_texts[i].x * _x_scale_container_state/0.20),
// render_to_screen_y( trace_to_render_y(_texts[i].y) + 0.5),
// text_elided,
// arial_font);
// }
// painter.setFont(QFont("Arial", 14));
// /* Draw ruler text */
// std::ostringstream buf_txt;
// Element_pos graduation_diff;
// Element_pos coeff_prefix;
// graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
// coeff_prefix = Ruler::get_coeff_for_common_prefix(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
arial_font.setPointSize(14);
// // painter.setFont(QFont("Arial", 14));
buf_txt.str("");/* flush the buffer */
buf_txt << "min: " << (double)Info::Render::_x_min_visible;
// arial_font.setPointSize(14);
renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_min_visible)),
render_to_screen_y(3),
buf_txt.str().c_str(),
arial_font);
// buf_txt.str("");/* flush the buffer */
// buf_txt << "min: " << (double)Info::Render::_x_min_visible;
buf_txt.str("");/* flush the buffer */
buf_txt << "max: " << (double)Info::Render::_x_max_visible;
// renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_min_visible)),
// render_to_screen_y(3),
// buf_txt.str().c_str(),
// arial_font);
renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_max_visible))-130,
render_to_screen_y(3),
buf_txt.str().c_str(),
arial_font);
// buf_txt.str("");/* flush the buffer */
// buf_txt << "max: " << (double)Info::Render::_x_max_visible;
buf_txt.str("");
buf_txt << Ruler::get_common_part_string(Info::Render::_x_min_visible, coeff_prefix) << "--";
// renderText (render_to_screen_x(trace_to_render_x(Info::Render::_x_max_visible))-130,
// render_to_screen_y(3),
// buf_txt.str().c_str(),
// arial_font);
renderText (render_to_screen_x(
trace_to_render_x(
(Info::Render::_x_min_visible +
Info::Render::_x_max_visible) / 2)),
render_to_screen_y(3),
buf_txt.str().c_str(),
arial_font);
// buf_txt.str("");
// buf_txt << Ruler::get_common_part_string(Info::Render::_x_min_visible, coeff_prefix) << "--";
arial_font.setPointSize(10);
// renderText (render_to_screen_x(
// trace_to_render_x(
// (Info::Render::_x_min_visible +
// Info::Render::_x_max_visible) / 2)),
// render_to_screen_y(3),
// buf_txt.str().c_str(),
// arial_font);
for (Element_pos i = Info::Render::_x_min_visible ;
i < Info::Render::_x_max_visible ;
i+=graduation_diff){
// arial_font.setPointSize(10);
buf_txt.str("");/* flush the buffer */
buf_txt << Ruler::get_variable_part(i, coeff_prefix, 2);
// for (Element_pos i = Info::Render::_x_min_visible ;
// i < Info::Render::_x_max_visible ;
// i+=graduation_diff){
renderText (render_to_screen_x(trace_to_render_x(i)+1),
render_to_screen_y(8),
buf_txt.str().c_str(),
arial_font);
}
// buf_txt.str("");/* flush the buffer */
// buf_txt << Ruler::get_variable_part(i, coeff_prefix, 2);
// renderText (render_to_screen_x(trace_to_render_x(i)+1),
// render_to_screen_y(8),
// buf_txt.str().c_str(),
// arial_font);
// }
}
......@@ -403,83 +458,83 @@ bool Render_alternate::unbuild(){
**********************/
/* enable some OpenGL features*/
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
// glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);/* enable blending for the alpha color */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable(GL_BLEND);/* enable blending for the alpha color */
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor3d(1.0, 1.0, 1.0);/* init color to white */
// glColor3d(1.0, 1.0, 1.0);/* init color to white */
/*****************************
*
* Init render area attributes
*
*****************************/
// /*****************************
// *
// * Init render area attributes
// *
// *****************************/
_state = DRAWING_STATE_WAITING;/* change the drawing state */
// _state = DRAWING_STATE_WAITING;/* change the drawing state */
_wait_angle=0.0f;/* begin with 0 rad angle */
_wait_angle_y=0.0f;/* begin with 0 rad angle */
// _wait_angle=0.0f;/* begin with 0 rad angle */
// _wait_angle_y=0.0f;/* begin with 0 rad angle */
/* init measurement attributes */
Info::Container::x_max = 0;
Info::Container::y_max = 0;
Info::Container::x_min = 0;
Info::Container::y_min = 0;
// /* init measurement attributes */
// Info::Container::x_max = 0;
// Info::Container::y_max = 0;
// Info::Container::x_min = 0;
// Info::Container::y_min = 0;
// Info::Render::_ui_render_min_value->setText("");
// Info::Render::_ui_render_max_value->setText("");
// // Info::Render::_ui_render_min_value->setText("");
// // Info::Render::_ui_render_max_value->setText("");
Info::Entity::x_max = 0;
Info::Entity::x_min = 0;
// _state_x_max = 0;
_state_y_max = 0;
// _state_x_min = 0;
_state_y_min = 0;
// Info::Entity::x_max = 0;
// Info::Entity::x_min = 0;
// // _state_x_max = 0;
// _state_y_max = 0;
// // _state_x_min = 0;
// _state_y_min = 0;
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
// /* clear lists to store container texts */
// _text_pos.clear();
// _text_value.clear();
_arrows.clear();
_circles.clear();
_texts.clear();
// _arrows.clear();
// _circles.clear();
// _texts.clear();
for (unsigned int i=0 ;
i<_vbos.size() ;
i++){
delete _vbos[i];
}
_vbos.clear();
// for (unsigned int i=0 ;
// i<_vbos.size() ;
// i++){
// delete _vbos[i];
// }
// _vbos.clear();
/* clear the event vector */
// _events.clear();
// /* clear the event vector */
// // _events.clear();
/* clear the arrow vector */
// _arrows.clear();
// /* clear the arrow vector */
// // _arrows.clear();
/* empty the selection stack */
while(false == _previous_selection.empty())
_previous_selection.pop();
// /* empty the selection stack */
// while(false == _previous_selection.empty())
// _previous_selection.pop();
if (NULL == _render_instance)
return true;
// if (NULL == _render_instance)
// return true;
/* Now, timer is set */
if (_wait_timer == NULL){
_wait_angle = 0.0f;
// /* Now, timer is set */
// if (_wait_timer == NULL){
// _wait_angle = 0.0f;
/* _wait_timer = new QTimer(this);
connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
_wait_timer->start(_wait_spf);*/
}
// /* _wait_timer = new QTimer(this);
// connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
// _wait_timer->start(_wait_spf);*/
// }
return true;//_render_instance->display_unbuild();
// return true;//_render_instance->display_unbuild();
}
......@@ -499,39 +554,39 @@ bool Render_alternate::unbuild(){
GLuint Render_alternate::draw_wait() {
GLuint object;
GLuint texture;
// GLuint object;
// GLuint texture;
glGenTextures(1, &texture);/* create the texture and link it with the list previously created */
// glGenTextures(1, &texture);/* create the texture and link it with the list previously created */
QFile texture_file(QString(":/img/img/logo") + QDate::currentDate().toString("MMdd") + QString(".png"));
// QFile texture_file(QString(":/img/img/logo") + QDate::currentDate().toString("MMdd") + QString(".png"));
if (true == texture_file.exists())/* The texture exists */
texture = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
else/* use the default picture */
texture = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
// if (true == texture_file.exists())/* The texture exists */
// texture = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
// else/* use the default picture */
// texture = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
/* apply some parameters on the texture */
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// /* apply some parameters on the texture */
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
// glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);/* enable blending for the alpha color */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable(GL_BLEND);/* enable blending for the alpha color */
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* Now, timer is set */
if (_wait_timer == NULL){
_wait_angle = 0.0f;
/*
_wait_timer = new QTimer(this);
connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
_wait_timer->start(_wait_spf);*/
}
// /* Now, timer is set */
// if (_wait_timer == NULL){
// _wait_angle = 0.0f;
// /*
// _wait_timer = new QTimer(this);
// connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
// _wait_timer->start(_wait_spf);*/
// }
return object;
// return object;
}
......@@ -588,9 +643,9 @@ void Render_alternate::call_ruler(){
void Render_alternate::set_color(float r, float g, float b){
_red = r;
_green = g;
_blue = b;
_r = r;
_g = g;
_b = b;
}
void Render_alternate::draw_text(const Element_pos x, const Element_pos y, const Element_pos, const std::string s){
......@@ -602,46 +657,46 @@ void Render_alternate::draw_text(const Element_pos x, const Element_pos y, const
buf.y = render_to_trace_y(y);/* Cancel previous transformation. */
buf.value = s;
_texts.push_back(buf);
//_texts.push_back(buf);
}
void Render_alternate::draw_quad(Element_pos x, Element_pos y, Element_pos z, Element_pos w, Element_pos h){
int state;
Element_pos data[8];
Element_pos offset_x;
const Element_pos offset_y = -_ruler_y - _ruler_height;
offset_x = 0;
if (!_draw_container)
if(_draw_container){
std::cout << "container : " << x << " " << y << " " << w << " " << h <<std::endl;
_containers.add(x+offset_x , y+offset_y , _r,_g,_b);
_containers.add(x+offset_x+w, y+offset_y , _r,_g,_b);
_containers.add(x+offset_x+w, y+offset_y+h, _r,_g,_b);
_containers.add(x+offset_x , y+offset_y+h, _r,_g,_b);
}
else if(_draw_states){
offset_x = -_default_entity_x_translate;
_states.add(x+offset_x , y+offset_y , _r, _g, _b);
_states.add(x+offset_x+w, y+offset_y , _r, _g, _b);
_states.add(x+offset_x+w, y+offset_y+h, _r, _g, _b);
_states.add(x+offset_x , y+offset_y+h, _r, _g, _b);
data[0] = x + offset_x;
data[1] = y + offset_y;
data[2] = x + offset_x;
data[3] = y + h + offset_y;
data[4] = x + w + offset_x;
data[5] = y + h + offset_y;
data[6] = x + w + offset_x;
data[7] = y + offset_y;