Jump to content
  • Advertisement
Sign in to follow this  
suez

what's the problem in this code

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

gldisable(gl_blend); for (RenderOperation::VertexBuffers::const_iterator v = op.getVertexBuffers().begin(); v != op.getVertexBuffers().end();v ++) { VertexBuffer *vbuf = *v; if (vbuf->m_texCoords) glEnableClientState(GL_TEXTURE_COORD_ARRAY); if (vbuf->m_colors) glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, vbuf->m_texCoords); glColorPointer(4,GL_FLOAT,0,vbuf->m_colors); glVertexPointer(3,GL_FLOAT,0,vbuf->m_vertexes); glEnable(GL_TEXTURE_2D); preloadTexture(vbuf->m_texture); renderTexture(vbuf->m_texture); Real ang; Vector3 axis; // orient the camera const Vector3 ndpos = (*r)->getWorldPosition(); const Vector3 campos = c->getPosition(); Vector3 ax = ndpos-campos; ax.normalise(); Quaternion qt = Vector3::UNIT_Z.getRotationTo(ax); qt.ToAngleAxis(ang,axis); glRotatef(Math::RadiansToDegrees(ang),axis.x,axis.y,axis.z); glDrawElements(getGLDrawType(vbuf->m_drawType),vbuf->nIndex,GL_UNSIGNED_INT,vbuf->m_indices); } glenable(gl_blend); This is one period of code to draw the particles in a vertex array in my rendersystem(there are also some other objects to render before or after this period of code), however when i run this code with the color_array enabled,the whole screen turn black, and when i comment disable the color array, the particles seem to blend with the background color, what is the problem? thx

Share this post


Link to post
Share on other sites
Advertisement
Post your code that fills in the arrays. And put [ source][ /source] tags around it, without the spaces.

Share this post


Link to post
Share on other sites
This sounds strangely familiar. You wouldn't be using Vertex Buffer Objects in your program as well, by chance?

If the answer is yes then take a look at my thread and see what I done to resolve the problem. This one really drove me nuts!

If you are not using VBOs however, please post more code- in particular the code where you set up your data structures and fill your arrays etc.. We need to be able to fully see what is happening if we are to help you.

One problem I can spot however from the code is your use of blending. You are disabling blending before rendering your particles when you should be enabling it, and doing the opposite at the end- enabling blending after your particles are rendered. Reverse these two statements around. You will also need to supply an appropriate blending function with 'glBlendFunc(...)'. See the red book for more details on this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!