diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2013-03-11 22:03:47 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2013-03-11 22:03:47 +0000 |
commit | a24a7fc7497f61828952b67b1daf85067725b663 (patch) | |
tree | 9c75628eaa1e2591005866a1aaefc6c3a28dc46f | |
parent | bec8869883710493ddf2fd88ae79c3befe41dc9b (diff) | |
download | 2013-gpudataviz-a24a7fc7497f61828952b67b1daf85067725b663.tar.gz 2013-gpudataviz-a24a7fc7497f61828952b67b1daf85067725b663.tar.bz2 2013-gpudataviz-a24a7fc7497f61828952b67b1daf85067725b663.zip |
Ajout alpha blending (avec fonction auto a finir)
git-svn-id: file:///var/svn/2013-gpudataviz/trunk@23 371a6b4a-a258-45f8-9dcc-bdd82ce0ac9d
-rw-r--r-- | src/gpudataviz.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/gpudataviz.cpp b/src/gpudataviz.cpp index a9ddfae..52b68e5 100644 --- a/src/gpudataviz.cpp +++ b/src/gpudataviz.cpp @@ -99,7 +99,10 @@ void MyGTKGLSceneWidget::on_realize() { EXIT_IF_FAIL(3, Gdk::GL::query_gl_extension("GL_ARB_vertex_buffer_object") ); EXIT_IF_FAIL(4, glewInit() == 0 ); - size_t mesh_width=512, mesh_height=512, group_size=256; // TODO : not here + //size_t mesh_width=256, mesh_height=256, group_size=256; // TODO : not here + //size_t mesh_width=512, mesh_height=512, group_size=256; // TODO : not here + size_t mesh_width=1024, mesh_height=1024, group_size=256; // TODO : not here + //size_t mesh_width=4096, mesh_height=4096, group_size=256; // TODO : not here GLuint gl_vbo=0; GLsizeiptr gl_vbo_data_size = mesh_width * mesh_height * sizeof(cl_float4); @@ -160,6 +163,8 @@ void MyGTKGLSceneWidget::on_realize() { EXIT_IF_FAIL(6, cl_res==0); knames.clear(); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Projection setup is done at on_configure_event // Camera setup (ie initial MODELVIEW matrix) is done at on_expose_event @@ -224,7 +229,40 @@ bool MyGTKGLSceneWidget::on_expose_event(GdkEventExpose* event) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Drawing all the stuff - glColor4f(0.40f,0.78f,0.97f,1.0f); +/* +TODO : find an auto func for alpha that corresponds to this values + +m_w m_h s_w s_h t_z alpha +1024 1024 1280 1000 -2 0.5 +1024 1024 1024 768 -2 0.125 +1024 1024 320 200 -2 0.025 + +1024 1024 1280 1000 -2 0.5 +1024 1024 1280 1000 -3.5 0.05 +1024 1024 1280 1000 -6.5 0.025 + +4096 4096 1280 1000 -2 0.015625 +1024 1024 1280 1000 -2 0.25 +512 512 1280 1000 -2 0.5 +256 256 1280 1000 -2 0.75 +*/ + + float m_w=this->clKit.getMeshWidth(); + float m_h=this->clKit.getMeshHeight(); + float s_w=this->get_width(); + float s_h=this->get_height(); + float t_z=this->camera.tz; + + float c1=((1024+1024)/(m_w+m_h)); + float c2=((s_w*s_h)/(1280*1024)); + float c3=(4/(t_z*t_z)); + + float alpha=0.5*c1*c2*c3; + + std::cout << "c1 == " << c1 << " c2 == " << c2 << " c3 == " << c3 << " alpha == " << alpha << std::endl;; + + + glColor4f(0.40f,0.78f,0.97f,alpha); glBindBuffer(GL_ARRAY_BUFFER, this->clKit.getGLVBO()); glVertexPointer(4, GL_FLOAT, 0, (GLvoid *) 0); glEnableClientState(GL_VERTEX_ARRAY); @@ -344,6 +382,7 @@ bool MyGTKGLSceneWidget::do_mouse_logic(GdkEventType type, guint state, guint x, if (this->camera.tz + 0.5f <= -0.5f) { this->camera.tz += 0.5f; + std::cout << "camera.tz == " << this->camera.tz << std::endl; redraw=true; } } @@ -352,6 +391,7 @@ bool MyGTKGLSceneWidget::do_mouse_logic(GdkEventType type, guint state, guint x, MOUSE_WHEEL(GDK_SCROLL_DOWN, 0, 0) { if (this->camera.tz - 0.5f >= -9.0f) { this->camera.tz -= 0.5f; + std::cout << "camera.tz == " << this->camera.tz << std::endl; redraw=true; } } |