# Quest for setTexture

**URL:** <https://discourse.processing.org/t/quest-for-settexture/21564>\
**Category:** Coding Questions\
**Created:** [June 4, 2020, 3:52pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564 "2020-06-04T15:52:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinGo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/martingo/32/9546_2.png) [@MartinGo](https://discourse.processing.org/u/MartinGo)\
**Post date:** [June 4, 2020, 3:52pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/1 "2020-06-04T15:52:31Z")

</div>

Hi. I want to make an hexagonal tile using the setTexture method of PShape, the problem is I want to run the following example

```auto
PImage img;
PShape globe;
	
void setup() {
  // Load an image
  img = loadImage("earth.jpg");
  globe = createShape(SPHERE, 50);
  // Automatically texture the shape with the image
  globe.setTexture(img);
}

```

And I get the message “IllegalArgumentException: createShape(SPHERE) is not supported in 2D” . I tried to set up to P3D using “size(640, 480, P3D)” but nothing is drawn. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [June 4, 2020, 8:47pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/2 "2020-06-04T20:47:34Z")

</div>

You’re almost there …

[https://processing.org/reference/shape\_.html](https://processing.org/reference/shape_.html)

---

<div class="post-metadata">

**Author:** ![uheinema](https://avatars.discourse-cdn.com/v4/letter/u/e99b99/32.png) [@uheinema](https://discourse.processing.org/u/uheinema)\
**Post date:** [June 5, 2020, 12:26am UTC](https://discourse.processing.org/t/quest-for-settexture/21564/3 "2020-06-05T00:26:27Z")

</div>

Nothing is drawn.  
That’s wrong.

You created the shape, fine. (A 2D sphere? What’s that?)  
Textured it, fine.  
Now draw() it.

---

<div class="post-metadata">

**Author:** ![MartinGo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/martingo/32/9546_2.png) [@MartinGo](https://discourse.processing.org/u/MartinGo)\
**Post date:** [June 5, 2020, 9:53pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/4 "2020-06-05T21:53:05Z")

</div>

> [@MartinGo](#):
>
> ```auto
> PImage img;
> PShape globe;
> 	
> void setup() {
> // Load an image
> img = loadImage("earth.jpg");
> globe = createShape(SPHERE, 50);
> // Automatically texture the shape with the image
> globe.setTexture(img);
> }
> 
> ```

I’m sorry. You were right, nothing is being drawn. I forgot the draw method I used the shape method. Thanks both of you!

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [June 5, 2020, 10:29pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/5 "2020-06-05T22:29:28Z")

</div>

```auto
void setup() {
  size(400, 400, P3D);
  background(3,7,11);

  PImage img = loadImage("img.jpg");
  PShape globe = createShape(SPHERE, 100);
  globe.setTexture(img);
  globe.setStroke(color(0, 0));  

  shape(globe, width*0.5, height*0.5);
}

```

---

<div class="post-metadata">

**Author:** ![MartinGo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/martingo/32/9546_2.png) [@MartinGo](https://discourse.processing.org/u/MartinGo)\
**Post date:** [June 6, 2020, 5:39pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/6 "2020-06-06T17:39:48Z")

</div>

I use it to learn the difference of putting “shape” in setup and “shape” in draw, if I write shape in setup, it blinks a lot (at least in my graphic card) if I use it in draw it is just drawn.

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [June 6, 2020, 7:07pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564/7 "2020-06-06T19:07:07Z")

</div>

In my example I had no reason to call it in `draw()`, but yes if you plan to animate/interact/ect, then move it into `draw()`. I was just looking to explicitly show you that you need to call the `shape()` function in order to draw the shape.
