It is currently Sun Apr 23, 2017 8:53 am

All times are UTC - 5 hours




 Page 1 of 1 [ 10 posts ] 
Author Message
 Post subject: Engine Design and Architecture
PostPosted: Sun Dec 31, 2006 7:08 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
The NodeLight class is used with the NodeLightPoint, NodeLightDirectional and NodeLightSpot classes to create the three different types of lights in the game engine.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 18 - Node Lights
PostPosted: Sat Jan 27, 2007 7:48 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
I found a bug in VMK 18C while I was making VMK 21G. The bug lies in the Scene::LightsEnabled() function and in the Scene::LightsDisabled() function.

To fix Scene::LightsEnabled(), change:
<code>if (pLight->isOn()) {
  pLight->Render( m_iLightCounter++ );
}
</code>To:
<code>if (pLight->isOn()) {
  pLight->Render(m_iLightCounter);
}
iLightCounter++;
</code>
And to fix Scene::LightsDisabled(), change:
<code>
if (pLight->isOn()) {
  pLight->Disable( m_iLightCounter++ );
}
</code>
To:
<code>if (pLight->isOn()) {
  pLight->Disable(m_iLightCounter);
}
iLightCounter++;</code>  


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 5:27 pm 

Joined: Wed Nov 26, 2008 7:43 pm
Posts: 2
On VMK 18B, arround sec 27 of the first Render explanation, the audio is lost completly for the rest of that part. Once the render explanations is over and the next step starts, the audio is back again.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Sep 27, 2009 12:01 pm 

Joined: Sun Sep 27, 2009 11:55 am
Posts: 2
glLightfv(_lightId, GL_CONSTANT_ATTENUATION, _attenuation[0]);
      glLightfv(_lightId, GL_LINEAR_ATTENUATION, _attenuation[1]);
      glLightfv(_lightId, GL_QUADRATIC_ATTENUATION, _attenuation[2]);


glLightfv asks for a GLfloat* in the 3rd parameter, and instead this it gets a float. float* can be converted to GLfloat, such as in glLightfv(_lightId, GL_AMBIENT, _ambientColor); wich doesn't give any kind of error, but not to normal float.
It is new on OpenGL? In the tutorial the code compiles, but in my pc not... and the error is what I told above (in spanish):
1>c:\users\migi\documents\visual studio 2008\gameengine\gameengine\scenelib\nodelightpoint.cpp(61) : error C2664: 'glLightfv' : no se puede convertir el parámetro 3 de 'float' a 'const GLfloat *'
1>c:\users\migi\documents\visual studio 2008\gameengine\gameengine\scenelib\nodelightpoint.cpp(62) : error C2664: 'glLightfv' : no se puede convertir el parámetro 3 de 'float' a 'const GLfloat *'
1>c:\users\migi\documents\visual studio 2008\gameengine\gameengine\scenelib\nodelightpoint.cpp(63) : error C2664: 'glLightfv' : no se puede convertir el parámetro 3 de 'float' a 'const GLfloat *'


With a & before the parameters it works, but I want your approvation :)

Thank you very much!


Offline
 Profile  
 
 Post subject: Distinct array and scalar forms of OpenGL functions
PostPosted: Tue Sep 29, 2009 3:42 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Hi Migi.

It seems you add extra ‘-v’ letter to the name of the function glLightf(...). Be careful please, there are two kinds of OpenGL suffixes for function names: with final ‘v’ and without. The functions with ‘v’ at the end of their names accept the ARRAY of values, instead of a single value.
Compare:
[code]
void glLightf( // <--- no -v at the end of the name
GLenum light,
GLenum pname,
GLfloat param // <--- one “floatâ€


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Sep 30, 2009 6:37 am 

Joined: Sun Sep 27, 2009 11:55 am
Posts: 2
Thank you very much! Almost always the problems are due to a typo :P
Thx again.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Oct 09, 2009 4:29 pm 

Joined: Fri Sep 04, 2009 3:24 am
Posts: 30
I'm getting the following error when I close the app. after doing vmk18C

HEAP CORRUPTION DETECTED: after Normal block (#140) at
0x00C580A0.

CRT detected that the application wrote to memory after end of heap
buffer.
int Scene::AddLight(NodeLight *pLight)
{
   m_Lights.push_back(pLight);
   return((int)m_Lights.size() - 1);
}

AddLight returns 0, however checking m_Lights.size() shows 1. I'm assuming 0 is the light ID.
void Scene::DeleteAllLights()
{
   for (int i = 0; i < (int)m_Lights.size(); i++)
   {
      delete m_Lights[i];
   }
   m_Lights.clear();
}

The delete is where things are going foul for me. m_Lights[i] is 1, the size of m_Lights is 1 and the above error occurs when I'm closing the app.

If I change the for loop to:
for (int i = 0; i < ((int)m_Lights.size() - 1); i++)

it works just fine. m_Lights[i] is 0, the size of m_Lights is 1 before the delete and 0 after.

I've used VC++ Express 2008 and Visual Studio standard(both 32 & 64 bit builds) with the same error,(0x changes).

I'd like to know if this is a compiler issue or have I messed up in one of the other vmk's.

Thanks for any help.


Offline
 Profile  
 
 Post subject: Wait a minute, I'm puffed out.
PostPosted: Sat Oct 10, 2009 1:37 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
To Groggy

Oh no, the compiler is guilty least of all. After all, standard library stuff is thoroughly tested. Try to find out the bug in YOUR code.

I wish I could help you, but at the time I was working on these series I had already injected in my code objects managers for almost all scene objects, such as LightsManager, TexturesManger etc. Because of this, my code base diverged from the original one.

AFAIR, sell [0] in aforementioned vector was reserved for Head Light. Additionally, Light ID is 1-based.

Good luck


Offline
 Profile  
 
 Post subject:
PostPosted: Mon Oct 12, 2009 4:21 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Groggy wrote:
int Scene::AddLight(NodeLight *pLight)
{
m_Lights.push_back(pLight);
return((int)m_Lights.size() - 1);
}


Inside of AddLight, make sure you do check to make sure pLight is valid before you add it to the m_Lights container

if (pLight == NULL) {
   //bad light
   return -1;
}


otherwise when you go to destroy all the memory you will try to delete memory that doesn't belong to you.

Step through your debugger and also watch to make sure that only valid pLights are being pushed back. If you have invalid pointers that is another problem.

Lastly, in your message you had said "The delete is where things are going foul for me. m_Lights[i] is 1"

m_Lights[i] should not be an integer value. It is supposed to be a pointer to a memory location that contains a valid Light class object. Make sure that you are storing the right thing inside m_Lights.


Offline
 Profile  
 
 Post subject:
PostPosted: Mon Oct 12, 2009 6:05 am 

Joined: Fri Sep 04, 2009 3:24 am
Posts: 30
The error came back with LightNodeDirectional, so I scrapped it and started over.

I know it works, I made it to texturing the triangle before I deleted it the first time. I've went too fast and spent to much time in one sitting trying to get back to where I was and missed something.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 10 posts ] 

All times are UTC - 5 hours


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

Jump to:  

cron