View unanswered posts | View active topics It is currently Fri Aug 17, 2018 11:28 am



Reply to topic  [ 5 posts ] 
 about the GL_World render 
Author Message

Joined: Sat Dec 31, 2011 11:57 pm
Posts: 13
Post about the GL_World render
When the QT program begins to load 3DS file as GLC_Word instance, create a new QT widget, rendering GLC_World, it is normal, but i close this widget to re-open a new widget, once again rendering GLC_World, at this point GLC_World instance is still in memory, but the program was error,who can help me?
my source code:

#include "glwidget.h"
#include <QDir>
#include <QHashIterator>
#include <GLC_Factory>

GLWidget::GLWidget(GLC_World word, QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers),parent)
, m_Light()
, m_GlView(this)
, m_MoverController()
, m_World(word)
{
m_Light.setPosition(1.0, 1.0, 1.0);
m_Light.setTwoSided(true);

m_GlView.loadBackGroundImage(":/myProgram/Icon/default_background.png");

QColor repColor;
repColor.setRgbF(1.0, 0.11372, 0.11372, 1.0);
m_MoverController= GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);
}

GLWidget::~GLWidget()
{
}

void GLWidget::initializeGL()
{
m_GlView.initGl();
m_GlView.reframe(m_World.boundingBox());
}
void GLWidget::paintGL()
{
// Clear screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Load identity matrix
glLoadIdentity();

//////////////////////////// GLC specific///////////////////////////////////////
// Calculate camera depth of view
m_GlView.setDistMinAndMax(m_World.collection()->boundingBox());

// define the light
m_Light.enable();
m_Light.glExecute();

// define view matrix
m_GlView.glExecuteCam();

// Display the collection of GLC_Object

m_World.render(0, glc::ShadingFlag);
m_World.render(0, glc::TransparentRenderFlag);


// Display UI Info (orbit circle)
m_MoverController.drawActiveMoverRep();

//////////////////////////End GLC specific/////////////////////////////////////
}


Sun Jan 01, 2012 12:13 am
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: about the GL_World render
Hi,
bingcaihuang wrote:
When the QT program begins to load 3DS file as GLC_Word instance, create a new QT widget, rendering GLC_World, it is normal, but i close this widget to re-open a new widget, once again rendering GLC_World, at this point GLC_World instance is still in memory, but the program was error,who can help me?
my source code:

The GLC_World class use Shallow copy. A GLC_World object is deleted when the last instance of a world is deleted. So it's normal that the world instance is still in memory.
The error is certainly du to the fact that the rendering context of your QGLWidget used by 3D objects of the world is deleted before deletion of the last instance of the used world.
To avoid this, add this modification into your destructor.
Code:
GLWidget::~GLWidget()
{
       m_World.clear();
}


@+


Mon Jan 09, 2012 3:00 pm
Profile

Joined: Sat Dec 31, 2011 11:57 pm
Posts: 13
Post Re: about the GL_World render
laumaya wrote:
Hi,
bingcaihuang wrote:
When the QT program begins to load 3DS file as GLC_Word instance, create a new QT widget, rendering GLC_World, it is normal, but i close this widget to re-open a new widget, once again rendering GLC_World, at this point GLC_World instance is still in memory, but the program was error,who can help me?
my source code:

The GLC_World class use Shallow copy. A GLC_World object is deleted when the last instance of a world is deleted. So it's normal that the world instance is still in memory.
The error is certainly du to the fact that the rendering context of your QGLWidget used by 3D objects of the world is deleted before deletion of the last instance of the used world.
To avoid this, add this modification into your destructor.
Code:
GLWidget::~GLWidget()
{
       m_World.clear();
}


@+


If i delete a GLC_World object when the widget close,i must reload the object next time when i create a new widget,is there any way to keep the object in memory,i can use
the object next time instead of reload it?


Fri Jan 13, 2012 2:08 am
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: about the GL_World render
bingcaihuang wrote:
If i delete a GLC_World object when the widget close,i must reload the object next time when i create a new widget,is there any way to keep the object in memory,i can use
the object next time instead of reload it?

At the first rendering of a GLC_World , GLC_lib objects like (VBO & textures) are linked to the OpenGL rendering context associated to the view. So it's impossible to :
    1. Load object
    2. Create QGLWidget
    3. Display objects into the created QGLWidget
    4. Delete the QGLWidget
    5. Create a new QGLWidget
Because Objects are linked with the rendering context of the first QGLWidget.
But, it's possible to use shared rendering context if there is at least one QGLWidget which render the GLC_World.

For the next version of GLC_lib I will track rendering context. So I'm thinking to remove this limitation.

@+


Fri Jan 13, 2012 8:39 pm
Profile

Joined: Sat Dec 31, 2011 11:57 pm
Posts: 13
Post Re: about the GL_World render
laumaya wrote:
bingcaihuang wrote:
If i delete a GLC_World object when the widget close,i must reload the object next time when i create a new widget,is there any way to keep the object in memory,i can use
the object next time instead of reload it?

At the first rendering of a GLC_World , GLC_lib objects like (VBO & textures) are linked to the OpenGL rendering context associated to the view. So it's impossible to :
    1. Load object
    2. Create QGLWidget
    3. Display objects into the created QGLWidget
    4. Delete the QGLWidget
    5. Create a new QGLWidget
Because Objects are linked with the rendering context of the first QGLWidget.
But, it's possible to use shared rendering context if there is at least one QGLWidget which render the GLC_World.

For the next version of GLC_lib I will track rendering context. So I'm thinking to remove this limitation.

@+



i see……thank you for your help, it is of great use to me.


Sat Jan 21, 2012 3:38 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.