From 815f1d89620cd1326a1ed21245c6344bd408849e Mon Sep 17 00:00:00 2001 From: Carlo Pinciroli Date: Sun, 31 Mar 2013 00:04:37 +0100 Subject: [PATCH 1/2] Changes to the root README. --- README.asciidoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 8672a49f..103c093a 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -2,7 +2,7 @@ ARGoS README ============= :Author: Carlo Pinciroli :Email: ilpincy@gmail.com -:Date: March 10th, 2013 +:Date: April 1st, 2013 What is ARGoS? --------------- @@ -182,6 +182,10 @@ the file +$HOME/.config/Iridia-ULB/ARGoS.conf+ as follows: # more stuff # +IMPORTANT: You can't install ARGoS system-wide and run the source version at the same time. + If you intend to run ARGoS from the sources, you must uninstall it from the + system. + Debugging the ARGoS simulator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 967356ab936878bb2e1cb58226212f785679b4fe Mon Sep 17 00:00:00 2001 From: Carlo Pinciroli Date: Mon, 1 Apr 2013 20:05:10 +0200 Subject: [PATCH 2/2] New code for texture binding in CQTOpenGLWidget. --- .../qt-opengl/qtopengl_widget.cpp | 130 +++++++++--------- .../qt-opengl/qtopengl_widget.h | 1 + .../qt-opengl/textures/ground.png | Bin 630 -> 2310 bytes 3 files changed, 64 insertions(+), 67 deletions(-) diff --git a/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp b/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp index cf5747f0..a339827a 100644 --- a/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp +++ b/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp @@ -27,9 +27,12 @@ namespace argos { - static const Real ASPECT_RATIO = 4.0f / 3.0f; + static const Real ASPECT_RATIO = 4.0f / 3.0f; static const UInt32 SELECT_BUFFER_SIZE = 128; - + static const Real FLOOR_SIDE = 1000.0f; + static const Real HALF_FLOOR_SIDE = FLOOR_SIDE * 0.5f; + static const Real FLOOR_ELEVATION = -0.001f; + /****************************************/ /****************************************/ @@ -136,6 +139,7 @@ namespace argos { glEnable(GL_LIGHTING); glEnable(GL_CULL_FACE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); qglClearColor(Qt::darkCyan); @@ -179,28 +183,12 @@ namespace argos { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Place the camera */ m_cCamera.Look(); - /* Draw the arena */ + /* Switch anti-aliasing on */ if(m_bAntiAliasing) { glEnable(GL_MULTISAMPLE); } - glPushMatrix(); - glCallList(m_unArenaList); - if(m_bUsingFloorTexture) { - if(m_cSpace.GetFloorEntity().HasChanged()) { - deleteTexture(m_unFloorTexture); - /* Create an image to use as texture */ - m_cSpace.GetFloorEntity().SaveAsImage("/tmp/argos_floor.png"); - /* Use the image as texture */ - m_unFloorTexture = bindTexture(QImage("/tmp/argos_floor.png")); - /* Clear the 'changed' flag on the floor entity */ - m_cSpace.GetFloorEntity().ClearChanged(); - } - else { - glBindTexture(GL_TEXTURE_2D, m_unFloorTexture); - } - glCallList(m_unFloorList); - } - glPopMatrix(); + /* Draw the arena */ + DrawArena(); /* Draw the objects */ CEntity::TVector& vecEntities = m_cSpace.GetRootEntityVector(); for(CEntity::TVector::iterator itEntities = vecEntities.begin(); @@ -217,9 +205,11 @@ namespace argos { CallEntityOperation(*this, *vecEntities[m_sSelectionInfo.Index]); glPopMatrix(); } + /* Switch anti-aliasing off */ if(m_bAntiAliasing) { glDisable(GL_MULTISAMPLE); } + /* Draw in world */ glPushMatrix(); m_cUserFunctions.DrawInWorld(); glPopMatrix(); @@ -585,76 +575,82 @@ namespace argos { /****************************************/ void CQTOpenGLWidget::InitializeArena() { - const Real fFloorSide = 1000.0f; - const Real fFloorElevation = -0.001f; + /* Set up the texture parameters for the floor plane + (here we refer to the standard floor, not the floor entity) */ + glEnable(GL_TEXTURE_2D); + QImage cGroundTexture(pcMainWindow->GetTextureDir() + "/ground.png"); + m_unGroundTexture = bindTexture(cGroundTexture, + GL_TEXTURE_2D, + GL_RGB, + QGLContext::MipmapBindOption | QGLContext::LinearFilteringBindOption); + /* Now take care of the floor entity */ + try { + /* Create an image to use as texture */ + m_cSpace.GetFloorEntity().SaveAsImage("/tmp/argos_floor.png"); + m_bUsingFloorTexture = true; + /* Use the image as texture */ + m_unFloorTexture = bindTexture(QImage("/tmp/argos_floor.png"), + GL_TEXTURE_2D, + GL_RGB, + QGLContext::MipmapBindOption | QGLContext::LinearFilteringBindOption); + m_cSpace.GetFloorEntity().ClearChanged(); + } + catch(CARGoSException& ex) {} + } - /* Create a display list for faster drawing */ - m_unArenaList = glGenLists(1); - glNewList(m_unArenaList, GL_COMPILE); + /****************************************/ + /****************************************/ + + void CQTOpenGLWidget::DrawArena() { /* Disable lighting - no funny color effects */ glDisable(GL_LIGHTING); - /* Set up the texture parameters for the floor - (here we refer to the standard floor, not the floor entity) */ - QImage cGroundTexture(pcMainWindow->GetTextureDir() + "/ground.png"); - m_unGroundTexture = bindTexture(cGroundTexture); + glEnable(GL_TEXTURE_2D); /* The texture covers the object like a decal */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - /* Bilinear filtering for zooming in and out */ - gluBuild2DMipmaps(GL_TEXTURE_2D, 3, cGroundTexture.width(), cGroundTexture.height(), - GL_LUMINANCE, GL_UNSIGNED_BYTE, cGroundTexture.bits()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); /* Wrap the texture at the edges, which in this case means that it is repeated */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glBindTexture(GL_TEXTURE_2D, m_unGroundTexture); /* Draw the floor along with its texture */ - glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glTexCoord2d( 0.5f, 0.5f); glVertex3f(-fFloorSide, -fFloorSide, fFloorElevation); - glTexCoord2d(2.0f*fFloorSide+0.5f, 0.5f); glVertex3f( fFloorSide, -fFloorSide, fFloorElevation); - glTexCoord2d(2.0f*fFloorSide+0.5f, 2.0f*fFloorSide+0.5f); glVertex3f( fFloorSide, fFloorSide, fFloorElevation); - glTexCoord2d( 0.5f, 2.0f*fFloorSide+0.5f); glVertex3f(-fFloorSide, fFloorSide, fFloorElevation); + glTexCoord2f(0.0f, FLOOR_SIDE); glVertex3f(-HALF_FLOOR_SIDE, -HALF_FLOOR_SIDE, FLOOR_ELEVATION); + glTexCoord2f(FLOOR_SIDE, FLOOR_SIDE); glVertex3f( HALF_FLOOR_SIDE, -HALF_FLOOR_SIDE, FLOOR_ELEVATION); + glTexCoord2f(FLOOR_SIDE, 0.0f); glVertex3f( HALF_FLOOR_SIDE, HALF_FLOOR_SIDE, FLOOR_ELEVATION); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-HALF_FLOOR_SIDE, HALF_FLOOR_SIDE, FLOOR_ELEVATION); glEnd(); - glDisable(GL_TEXTURE_2D); - /* Restore lighting */ - glEnable(GL_LIGHTING); - /* The list is done */ - glEndList(); - /* Now take care of the floor entity */ - try { - /* Create an image to use as texture */ - m_cSpace.GetFloorEntity().SaveAsImage("/tmp/argos_floor.png"); - m_bUsingFloorTexture = true; + if(m_bUsingFloorTexture) { /* Use the image as texture */ - m_unFloorTexture = bindTexture(QImage("/tmp/argos_floor.png")); + if(m_cSpace.GetFloorEntity().HasChanged()) { + deleteTexture(m_unFloorTexture); + /* Create an image to use as texture */ + m_cSpace.GetFloorEntity().SaveAsImage("/tmp/argos_floor.png"); + m_unFloorTexture = bindTexture(QImage("/tmp/argos_floor.png"), + GL_TEXTURE_2D, + GL_RGB, + QGLContext::MipmapBindOption | QGLContext::LinearFilteringBindOption); + /* Clear the 'changed' flag on the floor entity */ + m_cSpace.GetFloorEntity().ClearChanged(); + } + glBindTexture(GL_TEXTURE_2D, m_unFloorTexture); /* Draw the floor entity along with its texture */ CVector3 cHalfArenaSize = m_cSpace.GetArenaSize() * 0.5f; - /* Create a display list for faster drawing */ - m_unFloorList = glGenLists(1); - glNewList(m_unFloorList, GL_COMPILE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); /* Disabling the depth test solves an annoying glitch: since the floor and the floor entity are very close, the textures flicker */ glDisable(GL_DEPTH_TEST); - glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glTexCoord2d(0.0f, 0.0f); glVertex3f(-cHalfArenaSize.GetX(), -cHalfArenaSize.GetY(), 0.0f); - glTexCoord2d(1.0f, 0.0f); glVertex3f( cHalfArenaSize.GetX(), -cHalfArenaSize.GetY(), 0.0f); - glTexCoord2d(1.0f, 1.0f); glVertex3f( cHalfArenaSize.GetX(), cHalfArenaSize.GetY(), 0.0f); - glTexCoord2d(0.0f, 1.0f); glVertex3f(-cHalfArenaSize.GetX(), cHalfArenaSize.GetY(), 0.0f); + glTexCoord2d(0.0f, 1.0f); glVertex3f(-cHalfArenaSize.GetX(), -cHalfArenaSize.GetY(), 0.0f); + glTexCoord2d(1.0f, 1.0f); glVertex3f( cHalfArenaSize.GetX(), -cHalfArenaSize.GetY(), 0.0f); + glTexCoord2d(1.0f, 0.0f); glVertex3f( cHalfArenaSize.GetX(), cHalfArenaSize.GetY(), 0.0f); + glTexCoord2d(0.0f, 0.0f); glVertex3f(-cHalfArenaSize.GetX(), cHalfArenaSize.GetY(), 0.0f); glEnd(); - glDisable(GL_TEXTURE_2D); /* Restore depth test */ glEnable(GL_DEPTH_TEST); - /* Restore lighting */ - glEnable(GL_LIGHTING); - /* The list is done */ - glEndList(); } - catch(CARGoSException& ex) {} + glDisable(GL_TEXTURE_2D); + /* Restore lighting */ + glEnable(GL_LIGHTING); } /****************************************/ diff --git a/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h b/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h index a1d54127..9972f8ca 100644 --- a/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h +++ b/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h @@ -155,6 +155,7 @@ namespace argos { protected: void InitializeArena(); + void DrawArena(); virtual void timerEvent(QTimerEvent* pc_event); virtual void mouseMoveEvent(QMouseEvent* pc_event); diff --git a/src/plugins/simulator/visualizations/qt-opengl/textures/ground.png b/src/plugins/simulator/visualizations/qt-opengl/textures/ground.png index 44ab98fbff4cca753d5992ed96aa95fbf5ceb7a3..8922d03500b75c26fd62a2430541c0bd19ca912e 100644 GIT binary patch literal 2310 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&zE~)R&4Yzkn1=v6E*A2N2Y7q;vrJoCO|{ z#X$AfL734=V|E2lP_o1|q9iy!t)x7$D3zhSyj(9cFS|H7u^?41zbJk7I~yqm299P= z7srr_Id88S@*Z{&U^rMlt64zg8UGO(CDudY6AvBID`Pu2t@_NF^!I<`7#t3rsp;Q( z?ftHG%cB_@X3u%PGtS?gf#JI`1A{;c1B1c|1_p--j0_D5%nS^UK<75`0G%ocw8dyt z!Du*)riamdF{qP?KmHDy@fX-;VeoYI Kb6Mw<&;$U%pGqD8 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5890C>L#5>RT|kPnz$3C4NPB>>+sSM@kYHJX zV>(PV!>05*T|mx8PZ!6Kid%25IeIZW3b0-fI(w{j$LD|S7Y=l=sckei4pdjvaA8@$ z*t-9Nc;$bl{jVKGW1X!`w`FD}ud%bW2O2wgz=!btyy@%yZmf>qzwFm*r8&FS?b;i2 z( zO#u=NMh1okx(1fIM&==gW>y9!R)!|p21Zr}1|FJ+H^DUI=BH$)RT9u3K4WVeC}urf L{an^LB{Ts5<_vvR