Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

greenMuzz

Colour problem

This topic is 5368 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

On one computer I have access to, my game runs pretty much as I wanted it to. However, when I tried it on the university machine I work on, I found that the colours of my particles would bleed across the entire screen - almost as if there were a huge particle covering the whole screen (images at www.personal.rdg.ac.uk/~sir03me ). Any suggestions why this should be the case? My machine where it works is ATI & AMD, whereas the uni machine is nVidia and Pent4. All should be accessable from the bottom of my little web-page - sorry the images are so big - if you want a look.

Share this post


Link to post
Share on other sites
Advertisement
This renders my most basic particle:


void CSimpleParticle::Render()
{
if(this->life > 0)
{
glPushMatrix();
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
if(hasTexture_b ==false) glDisable(GL_TEXTURE_2D);
else
{
extern CTextureManager texMan;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texMan.textures[tex_i].id_ui);
}

glTranslatef(pos_v4f.X(), pos_v4f.Y(), pos_v4f.Z());
glRotatef(rot_v3f.X(), 1, 0, 0);
glRotatef(rot_v3f.Y(), 0, 1, 0);
glRotatef(rot_v3f.Z(), 0, 0, 1);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDepthMask(GL_FALSE);
glColor4f((GLfloat)r_f,(GLfloat) g_f,(GLfloat) b_f,(GLfloat) a_f);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glTexCoord2f(0,0); glVertex3f(-size_f,-size_f, 0);
glTexCoord2f(1,0); glVertex3f( size_f,-size_f, 0);
glTexCoord2f(1,1); glVertex3f( size_f, size_f, 0);
glTexCoord2f(0,1); glVertex3f(-size_f, size_f, 0);

glEnd();



if(hasTexture_b == true)
{
glDisable(GL_TEXTURE_2D);
}
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}



while this renders a modification of it

  
void CGunParticle::Render()
{
if(this->life > 0)
{
glPushMatrix();
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
extern CFreebooter FB;
CGalaxy *gal = (CGalaxy*)FB.scene;
if(gal->gunTypes[this->gunType_i]->hasTexturedParticle_b)
{
glEnable(GL_TEXTURE_2D);
extern CTextureManager texMan;
glBindTexture(GL_TEXTURE_2D, texMan.textures[gal->gunTypes[this->gunType_i]->tex_i].id_ui);
}
else glDisable(GL_TEXTURE_2D);

glTranslatef(pos_v4f.X(), pos_v4f.Y(), pos_v4f.Z());
glRotatef(rot_v3f.X(), 1, 0, 0);
glRotatef(rot_v3f.Y(), 0, 1, 0);
glRotatef(rot_v3f.Z(), 0, 0, 1);

glEnable(GL_BLEND);
//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDepthMask(GL_FALSE);
glColor4f((GLfloat)r_f,(GLfloat) g_f,(GLfloat) b_f,(GLfloat) a_f);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glTexCoord2i(0,0); glVertex3f(-size_f, -size_f, 0);
glTexCoord2i(1,0); glVertex3f( size_f,-size_f, 0);
glTexCoord2i(1,1); glVertex3f( size_f,size_f, 0);
glTexCoord2i(0,1); glVertex3f(-size_f,size_f, 0);
/*glNormal3f(0,1,0);
glTexCoord2i(0,0); glVertex3f(-size_f,0, -size_f);
glTexCoord2i(1,0); glVertex3f( size_f,0, -size_f);
glTexCoord2i(1,1); glVertex3f( size_f,0, size_f);
glTexCoord2i(0,1); glVertex3f(-size_f,0, size_f);*/

glEnd();
/*float cols[4];
glGetFloatv(GL_CURRENT_COLOR, cols);
fprintf(stdout, "%f %f %f %f \n", cols[0], cols[1], cols[2], cols[3]);*/


glDisable(GL_TEXTURE_2D);
glColor4f(1.0,1.0,1.0,1.0);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}



here's the classes for both:



class CSimpleParticle :
public CModelEntity
{
public:
CSimpleParticle(void);
~CSimpleParticle(void);

void Render(); // redefine inherited render

int life; // number of updates before drawing stops


float size_f; // radius (rememberingthat things are square)


// colours

float r_f;
float g_f;
float b_f;
float a_f;
void SetColour(float in_R, float in_G, float in_B, float in_A);
void Update();
};

class CGunParticle :
public CSimpleParticle
{
public:
CGunParticle(void);
~CGunParticle(void);

// what type of gun fired me?

int gunType_i;

// who fired me??

CShip *owner;

// redefine

void Update();
void Render();
};



then we have this class, which manages the particles:



class CSimpleParticleGenerator :
public CEntity
{
public:
CSimpleParticleGenerator(void);
~CSimpleParticleGenerator(void);

void Render();
void Update();

virtual void AddParticle(CSimpleParticle *in_Spart);
void CleanParticles();

protected:
vector<CSimpleParticle*> particles;
};



and is a fairly simple implementation:




CSimpleParticleGenerator::CSimpleParticleGenerator(void)
{
}

CSimpleParticleGenerator::~CSimpleParticleGenerator(void)
{
}

void CSimpleParticleGenerator::Render()
{
for(unsigned int pc_i = 0; pc_i < particles.size(); pc_i++)
{
particles[pc_i]->Render();
}
}

void CSimpleParticleGenerator::Update()
{
// clean up dead particles, update undead particles

int loopLimit = particles.size();
int pc_i = 0;
while(pc_i < loopLimit)
{
if(particles[pc_i]->life <= 0)
{
// remove dead particle

vector<CSimpleParticle*>::iterator iter;
if(pc_i > loopLimit)
{
cout << "It can go wrong!!" << endl;
exit(1);
}
delete(particles[pc_i]);
iter = particles.begin();
int c_i = 0;
while(c_i < pc_i) {iter++; c_i++;}
particles.erase(iter);
loopLimit--;
pc_i--;
}
else
{
particles[pc_i]->Update();
}
pc_i++;
}
}

void CSimpleParticleGenerator::AddParticle(CSimpleParticle *in_Spart)
{
particles.push_back(in_Spart);
}

void CSimpleParticleGenerator::CleanParticles()
{
particles.clear();
}





[edited by - greenmuzz on February 9, 2004 11:57:19 AM]

Share this post


Link to post
Share on other sites

  • 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!