Billboards texture

Hello,

I’d like to use point sprites in my program. I see the quads when I use
the drawBillboard() method but they are not textured. Here is my code:

vec4 psPos[NBR_POINT_SPRITES];
TextureRef psTex;
(…)
for (int i = 0; i < NBR_POINT_SPRITES; ++i)
{
double x = -2. + (rand() % 40) * .1f;
double y = (rand() % 120) * .1f;
double z = -2. + (rand() % 40) * .1f;
double speed = (rand() % 20) * .1f;
psPos[i] = vec4(x, y, z, speed);
}

psTex = Texture2d::create(loadImage("data/ps.png"));

(…)
vec3 mRight, mUp;
viewCam.getBillboardVectors(&mRight, &mUp);

gl::enableAlphaBlending();
gl::color(ColorA(1.f, 1.f, 1.f, .75f));
psTex->bind();    // bind the point sprites texture

for (int i = 0; i < NBR_POINT_SPRITES; ++i)
{
	gl::drawBillboard(vec3(psPos[i].x, psPos[i].y, psPos[i].z), vec2(.25f, .25f), 0.f, mRight, mUp);
}

psTex->unbind();
gl::disableAlphaBlending();

Any help will be appreciated,
azerty69

Do you have a shader bound? Try adding this where you bind you texture.

gl::ScopedGlslProg shader { gl::getStockShader ( gl::ShaderDef().color().texture() ) };

Hello lithium,

Your suggestion has solved the problem. I was thinking that the method ‘drawBillboard’ was doing
the job for me, like gl::draw(Texture2dRef tex).

Thank youi very much,
azerty69