# gl::drawBillboard has no texture

**URL:** https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359
**Category:** Using Cinder
**Created:** [November 17, 2018, 11:37pm UTC](https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359 "2018-11-17T23:37:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gruffler](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gruffler/32/685_2.png) [@gruffler](https://discourse.libcinder.org/u/gruffler)
#### Post date: [November 17, 2018, 11:37pm UTC](https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359/1 "2018-11-17T23:37:29Z")

</div>

Hi,

Recently discovered the gl::drawBillboard feature and I have been trying to get it to work and have no idea why I can not get the texture to show on a billboard.  
I can see the geometry, its just untextured.  
I have made a simplest example below and if someone could give me heads up where I am going wrong I would appreciate it.

> #include “cinder/app/App.h”  
> #include “cinder/app/RendererGl.h”  
> #include “cinder/gl/gl.h”
> 
> using namespace ci;  
> using namespace ci::app;  
> using namespace std;
> 
> class CinderProject1App : public App {  
> public:  
> void setup() override;  
> void update() override;  
> void draw() override;  
> private:  
> CameraPersp mCam;  
> gl::TextureRef bbTex;  
> };
> 
> void CinderProject1App::setup()  
> {  
> mCam.lookAt(vec3(3, 2, 4), vec3(0));
> 
> auto img2 = loadImage(loadAsset(“CARROT2.png”));  
> bbTex = gl::Texture::create(img2);  
> bbTex-\>bind();
> 
> gl::enableDepthWrite();  
> gl::enableDepthRead();  
> }
> 
> void CinderProject1App::update()  
> {  
> }
> 
> void CinderProject1App::draw()  
> {  
> gl::setMatrices(mCam);
> 
> gl::clear(Color(0.2f, 0.2f, 0.2f));
> 
> glm::vec3 bbup, bbright;  
> mCam.getBillboardVectors(&bbright, &bbup);
> 
> bbTex-\>bind();  
> gl::drawBillboard(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec2(1.0f, 1.0f), 0.0, bbright, bbup,cinder::Rectf(0.25f, 0.25f, 0.75f, 0.75f));  
> bbTex-\>unbind();
> 
> }
> 
> CINDER\_APP( CinderProject1App, RendererGl )

---

<div class="post-metadata">

### Author: ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)
#### Post date: [November 17, 2018, 11:58pm UTC](https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359/2 "2018-11-17T23:58:30Z")

</div>

Hi,

you haven’t created a proper shader for it. With no shader bound, Cinder will bind a default shader which does not sample a texture. One exception is the `gl::draw( texture )` call, which actually does [create and bind a shader](https://github.com/cinder/Cinder/blob/f2d862d0a26456f6372ef217d15a53b8b14bea9c/src/cinder/gl/draw.cpp#L300) that samples the texture.

I haven’t tried your code, nor my solution, but my guess is that the following code change will fix your issue:

```auto
void CinderProject1App::draw()
{
    gl::setMatrices(mCam);
    gl::clear(Color(0.2f, 0.2f, 0.2f));

    glm::vec3 bbup, bbright;
    mCam.getBillboardVectors(&bbright, &bbup);

    auto shader = gl::getStockShader( gl::ShaderDef().texture() );
    shader->bind();

    bbTex->bind();
    gl::drawBillboard(vec3(0.0f), vec2(1.0f), 0.0, bbright, bbup, Rectf(0.25f, 0.25f, 0.75f, 0.75f));
    bbTex->unbind();
}

```

---

<div class="post-metadata">

### Author: ![gruffler](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gruffler/32/685_2.png) [@gruffler](https://discourse.libcinder.org/u/gruffler)
#### Post date: [November 18, 2018, 12:17am UTC](https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359/3 "2018-11-18T00:17:46Z")

</div>

Ahh your right of course. 😫 Knew it would be something obvious!  
I did come to this from messing about with gl::draw(texture) as you mentioned too, but I should have known.  
Thanks for the fast and helpful reply!

 ![2018-11-18%20(1)](https://canada1.discourse-cdn.com/flex030/uploads/libcinder/original/1X/b6ea80d57ba1512354199e156f1985781cf77a24.jpeg)

Got billboards! Next is figure out why they are upsidedown… 🕶

---

<div class="post-metadata">

### Author: ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)
#### Post date: [November 18, 2018, 12:56am UTC](https://discourse.libcinder.org/t/gl-drawbillboard-has-no-texture/1359/4 "2018-11-18T00:56:23Z")

</div>

Hey, that’s great!

Try this:

```auto
auto fmt = gl::Texture2d::Format().loadTopDown();
auto image = loadImage( loadAsset( "carrot2.png" ) );
auto texture = gl::Texture2d::create( image, fmt );

```
