Hi,
I have a problem with a texture when I execute my program.
I’m running VRJuggler 2.0.1 and OpenSG 1.6.0 on an SGI Irix system in a CAVE environment. Here is what I want to do and what is happening (the source code sample will follow):

I want to create a Plane geometry and apply a texture on it. The texture will be an animated movie (each frame is an RGB image), so I will change the texture each frame displayed (like doing a flip book animation).

The problem I have is when I play all the animation once, it’s OK, but the second time, the program crash with this warning “WARNING: Window::frameExit: Caught stray OpenGL error invalid operation (0x502)”. I did some test and it’s really seems to be related to a texture problem. The problem seems to come from the image data either being deleted or something like that.

Here is an extract of the code:

#include "scene.h"
CScene * scene;

void MAINAPP::draw()
{
vrj::OpenSGApp::draw();
}

void MAINAPP::initScene()
{
// ALL OpenSG Node and Corre creation are made…

scene = new CScene();

}

void MAINAPP::preFrame()
{
float fElapsedTime = GetTime();
scene->ChangeAnimation(felapsedTime);
}

SCENE CLASS:
-------------------------
class CSnene
{
public:
CScene();
~CScene();

void ChangeAnimation(float fElapsedTime);

private:
ImagePtr aImgAnimation[10]; //For an animation of 10 images
SimpleTexturedMaterialPtr tex_01;
};

CScene::CScene()
{
GeometryPtr AnimGeo = makePlaneGeo(10,8,1,1);
tex_01 = SimpleTexturedMaterial::create();
for(int i=0; i < 10; i++) aImgAnimation[i] = Image::create();
aImgAnimation[0]->read("frame_01.sgi");
aImgAnimation[1]->read("frame_02.sgi");
aImgAnimation[2]->read("frame_03.sgi");
…
aImgAnimation[9]->read("frame_10.sgi");

beginEditCP(tex_01);
tex_01->setImage(aImgAnimation[0]);
endEditCP(tex_01);

beginEditCP(AnimGeo, Geometry::MaterialFieldMask);
AnimGeo ->setMaterial(tex_01);
endEditCP(AnimGeo, Geometry::MaterialFieldMask);

NodePtr Anim_core = Node::create();
beginEditCP(Anim_core, Node::CoreFieldMask);
Anim_core->setCore(AnimGeo);
endEditCP(Anim_core, Node::CoreFieldMask);

// Master node of all scene already exist…
beginEditCP(MasterNode);
MasterNode->addChild(Anim_core);
endEditCP(MasterNode);

}

void CScene::ChangeAnimation(float fElapsedTime)
{
int iFrame = fElapsedTime % 10; // Frame between 0 and 10
beginEditCP(tex_01);
tex_01->setImage(aImgAnim[iFrame]);
tex_01->imageChanged();
endEditCP(tex_01);
}


I did an other test too, I changed the way that ChangeAnimation(float fElapsedTime) was running, meaning that I was passing the exact frame number I wanted to be displayed… So, what I did is asked the first frame, then the third frame and then the second one… every frame worked as intended… But if I ask the first one, then the third one and finally the first one again… BOOM, the program crash ! I added finally one quick checkup, like checking the width of the image before displaying it: when asking frame 1, size is ok, the asking frame 3, size ok, asking back frame 1, size is now 0…Like if the info of the image have disappeared…

Any help would be appreciated ;)

Patrick

begin:vcard
fn:Patrick Perron
n:Perron;Patrick
org;quoted-printable:Laboratoire Faubert - Universit=C3=A9 de Montr=C3=A9al;1(514)343-6111 Option#1 Poste#8937
adr:Room 260-7;;3744 Jean-Brillant;Montreal;Quebec;H3T 1P1;Canada
email;internet:[EMAIL PROTECTED]
title:Programmer / System Administrator
tel;work:1(514)343-6111 Option#1 Poste#8937
tel;fax:1(514)343-2382
url:http://vision.opto.umontreal.ca
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to