HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 OpenGL all particles are black

View previous topic View next topic Go down 
AuthorMessage
mmortall



Messages : 6
Date d'inscription : 2011-04-11

PostSubject: OpenGL all particles are black   Fri Aug 19, 2011 1:41 pm

I use Spark with pure OpenGL + glu + glut (no SDL)
I copy code from Fountain Demo.
I load textures using Irrlicht and then got its OpenGL id-s. Id-s is valid.

All particles rendered as black quads. If I turn on blending its become invisible.
All another 3D models are drowed perfect using OpenGL.



My init:
Code:

   unsigned int randomSeed = static_cast<unsigned int>(time(NULL));

   // Inits Particle Engine
   SPK::randomSeed = Game::GetInstance()->getIrrDevice()->getTimer()->getRealTime();
   // Sets the update step
   SPK::System::setClampStep(true,0.1f);         // clamp the step to 100 ms
   SPK::System::useAdaptiveStep(0.001f,0.01f);      // use an adaptive step from 1ms to 10ms (1000fps to 100fps)

   //Vector3D gravity(0.0f,-0.8f,0.0f);

   loadData(); //load images

   Vector3D gravity(0.0f,-2.2f,0.0f);

   GLPointRenderer* basicRenderer = GLPointRenderer::create();

   GLQuadRenderer* particleRenderer = GLQuadRenderer::create();
   particleRenderer->setScale(0.06f,0.06f);
   particleRenderer->setTexturingMode(TEXTURE_2D);
   GLuint tx = m_textureFlash->getTextureID();
   particleRenderer->setTexture(tx);
   particleRenderer->setBlending(BLENDING_NONE);
   particleRenderer->enableRenderingHint(DEPTH_WRITE,false);

   // Model
   Model* particleModel = Model::create(FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE,
      FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE,
      FLAG_SIZE | FLAG_ANGLE);

   particleModel->setLifeTime(1.6f,2.2f);
   //particleModel->setParam(PARAM_ALPHA,0.2f,0.0f);
   //particleModel->setParam(PARAM_SIZE,1.0f,1.0f,2.0f,8.0f);
   //particleModel->setParam(PARAM_ANGLE,0.0f,4.0f * 3.141592,0.0f,4.0f * 3.141592);

   // Emitters
   const int NB_EMITTERS = 13;

   Point* emitterZone[NB_EMITTERS];
   emitterZone[0] = Point::create(Vector3D(0.0f,0.1f,0.0f));

   emitterZone[1] = Point::create(Vector3D(0.0f,0.1f,0.0f));
   emitterZone[2] = Point::create(Vector3D(0.0f,0.1f,0.0f));
   emitterZone[3] = Point::create(Vector3D(0.0f,0.1f,0.0f));
   emitterZone[4] = Point::create(Vector3D(0.0f,0.1f,0.0f));

   emitterZone[5] = Point::create(Vector3D(-1.6f,0.1f,-1.6f));
   emitterZone[6] = Point::create(Vector3D(1.6f,0.1f,1.6f));
   emitterZone[7] = Point::create(Vector3D(1.6f,0.1f,-1.6f));
   emitterZone[8] = Point::create(Vector3D(-1.6f,0.1f,1.6f));
   emitterZone[9] = Point::create(Vector3D(-2.26f,0.1f,0.0f));
   emitterZone[10] = Point::create(Vector3D(2.26f,0.1f,0.0f));
   emitterZone[11] = Point::create(Vector3D(0.0f,0.1f,-2.26f));
   emitterZone[12] = Point::create(Vector3D(0.0f,0.1f,2.26f));

   StraightEmitter* particleEmitter[NB_EMITTERS];
   particleEmitter[0] = StraightEmitter::create(Vector3D(0.0f,1.0f,0.0f));

   particleEmitter[1] = StraightEmitter::create(Vector3D(1.0f,3.0f,1.0f));
   particleEmitter[2] = StraightEmitter::create(Vector3D(-1.0f,3.0f,-1.0f));
   particleEmitter[3] = StraightEmitter::create(Vector3D(-1.0f,3.0f,1.0f));
   particleEmitter[4] = StraightEmitter::create(Vector3D(1.0f,3.0f,-1.0f));

   particleEmitter[5] = StraightEmitter::create(Vector3D(1.0f,2.0f,1.0f));
   particleEmitter[6] = StraightEmitter::create(Vector3D(-1.0f,2.0f,-1.0f));
   particleEmitter[7] = StraightEmitter::create(Vector3D(-1.0f,2.0f,1.0f));
   particleEmitter[8] = StraightEmitter::create(Vector3D(1.0f,2.0f,-1.0f));
   particleEmitter[9] = StraightEmitter::create(Vector3D(1.41f,2.0f,0.0f));
   particleEmitter[10] = StraightEmitter::create(Vector3D(-1.41f,2.0f,0.0f));
   particleEmitter[11] = StraightEmitter::create(Vector3D(0.0f,2.0f,1.41f));
   particleEmitter[12] = StraightEmitter::create(Vector3D(0.0f,2.0f,-1.41f));

   float flow[NB_EMITTERS] =
   {
      500.0f,

      600.0f,
      600.0f,
      600.0f,
      600.0f,

      900.0f,
      900.0f,
      900.0f,
      900.0f,
      900.0f,
      900.0f,
      900.0f,
      900.0f,
   };

   float flowLow[NB_EMITTERS] =
   {
      150.0f,

      200.0f,
      200.0f,
      200.0f,
      200.0f,

      250.0f,
      250.0f,
      250.0f,
      250.0f,
      250.0f,
      250.0f,
      250.0f,
      250.0f,
   };
   
   for (int i = 0; i < NB_EMITTERS; ++i)
   {
      particleEmitter[i]->setZone(emitterZone[i]);
      particleEmitter[i]->setFlow(flow[i]);
      particleEmitter[i]->setForce(2.5f,4.0f);
   }
   particleEmitter[0]->setForce(3.0f,3.5f);

   // Group
   particleGroup = Group::create(particleModel,20000);
   particleGroup->setRenderer(particleRenderer);
   for (int i = 0; i < NB_EMITTERS; ++i)
      particleGroup->addEmitter(particleEmitter[i]);
   particleGroup->setCustomUpdate(&splash);
   particleGroup->setGravity(gravity);
   particleGroup->setFriction(0.7f);
   particleGroup->enableAABBComputing(true);

   // System
   particleSystem = System::create();
   particleSystem->addGroup(particleGroup);
   particleSystem->enableAABBComputing(true);
   particleSystem->computeAABB();

My render:
Code:

   glDepthFunc(GL_LEQUAL);
   glDisable(GL_BLEND);
   glDisable(GL_ALPHA_TEST);

   glDisable(GL_CULL_FACE);
   glDisable(GL_LIGHTING);
   glEnable(GL_TEXTURE_2D);

   glClearColor(0.0f,0.68f,0.85f,1.0f);
   glViewport(0,0,1024, 768);

   //glDepthMask(GL_TRUE);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(45,(float)1024/(float)768,0.01f,80.0f);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();                     

   glTranslatef(0.0f,0.0f,-10);
   //glRotatef(0,1.0f,0.0f,0.0f);
   //glRotatef(0,0.0f,1.0f,0.0f);

   particleSystem->render();
   //particleGroup->render();

   particleSystem->update(0.001f);
   //particleGroup->update(0.001f);

   Vector3D AABBMin = particleGroup->getAABBMin();
   Vector3D AABBMax = particleGroup->getAABBMax();

   glDisable(GL_TEXTURE_2D);
   glBegin(GL_LINES);
   glColor3f(1.0f,0.0f,0.0f);

   glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z);
   glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z);
   
   glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z);
   glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z);

   glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z);
   glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z);

   glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z);
   glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);

   glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z);
   glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z);

   glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z);
   glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);

   glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z);
   glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z);

   glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z);
   glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);

   glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z);
   glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);

   glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z);
   glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);

   glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z);
   glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);

   glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z);
   glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z);
   glEnd();
Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: OpenGL all particles are black   Fri Aug 19, 2011 2:06 pm

Hi, are you sure the OpenGL texture parameters are well set for this texture id ?

You can also try to wrap your SPARK render code with :
Code:

GLRenderer::saveGLStates ();
// render spark systems
// ...
GLRenderer::restoreGLStates();
Back to top Go down
View user profile http://spark.developpez.com
mmortall



Messages : 6
Date d'inscription : 2011-04-11

PostSubject: Re: OpenGL all particles are black   Sat Aug 20, 2011 4:25 am

I isolate all states in my project so now render use default parameters and renders only particles. Nothing affect it.
I add identical custom procedural texture generator for your samples and my project. In your samples all works, in my project all particle black. So this is no texture problem.
I use 2010 studio and rebuild engine for 2010. When I rebuild your OpenGL's samples for 2010 they crash on render in release and debug.

Note that with Irrlicht and 2010 studio all works fine. Irrlicht I rebuild for 2010 too.
I check your render code in GLQuadRenderer. All was written fine and mast work. Looks like the problem is in invalid texcoord pointer.

Looks like problem is in MSW 2010 and some additional libs witch using SPARK. Now I use SPARK 1.05.04.
I try to use SPARK 1.5.5.


I succes build your demos for 2010. All work fine. But in my program all the same. Very strange((

I will write simple demo and try to localize bug.
Back to top Go down
View user profile
mmortall



Messages : 6
Date d'inscription : 2011-04-11

PostSubject: Re: OpenGL all particles are black   Sat Aug 20, 2011 1:21 pm

I think I found the issue. I render OpenGL using Irrlicht OpenGL device. When I turn it off and set up SDL or GLUT device all rendered fine.

So when I use GLQuadRenderer with Irrlicth device this bug occurs. Why?
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: OpenGL all particles are black   Sun Aug 21, 2011 12:29 pm

My 2 cents: why using Irrlicht just for file management ? Do not forget that Irrlicht might alter the gl device without informing you Wink I think you should use only OpenGL and SDL, or just Irrlicht (I advise you the second choice, because it allows you to use DirectX without changing the code)

_________________
Back to top Go down
View user profile
mmortall



Messages : 6
Date d'inscription : 2011-04-11

PostSubject: Re: OpenGL all particles are black   Sun Aug 21, 2011 2:45 pm

Irrlicht is very slow engine. For pure OpenGL I use NULL driver.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: OpenGL all particles are black   Today at 9:27 am

Back to top Go down
 
OpenGL all particles are black
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» How to take the screen shot? when i set a kwargs, it is showing error... when i not set kwargs it is coming black color as background
» My Pokémon Black game won't load on my 3DS!?
» Pokémon Discussion Beyond Pokémon Black and White 2!
» Pokémon Black and White 2 Discussion
» [ANSWERED] Black screen after Windows Update

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: