# How to simply create 2D texture for 3D OpenGL rendering?

**URL:** <https://psychtoolbox.discourse.group/t/how-to-simply-create-2d-texture-for-3d-opengl-rendering/3754>\
**Category:** Programming Help\
**Tags:** experiment-design\
**Created:** [March 17, 2021, 3:03am UTC](https://psychtoolbox.discourse.group/t/how-to-simply-create-2d-texture-for-3d-opengl-rendering/3754 "2021-03-17T03:03:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yyh\_dahua](https://avatars.discourse-cdn.com/v4/letter/y/ec9cab/32.png) [@yyh\_dahua](https://psychtoolbox.discourse.group/u/yyh_dahua)\
**Post date:** [March 17, 2021, 3:03am UTC](https://psychtoolbox.discourse.group/t/how-to-simply-create-2d-texture-for-3d-opengl-rendering/3754/1 "2021-03-17T03:03:51Z")

</div>

Hi all,

I tried to draw a rectangle in the 3D cloud at some position(x,y,z). But I really don’t know which function can be used to draw, the demo(CylinderAnnulusOpenGLDemo.m) is difficult, and it is not suitable for me. It seems I should use functions like maketexture, getOpengltexture, drawtexture. But I don’t know how to combine them.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [March 17, 2021, 6:40pm UTC](https://psychtoolbox.discourse.group/t/how-to-simply-create-2d-texture-for-3d-opengl-rendering/3754/2 "2021-03-17T18:40:34Z")

</div>

Hi.

Look at `MinimalisticOpenGLDemo.m` for how the surface texture of the rotating earth is created via maketexture, getopengltexture etc. `ShepardZoomDemo.m` has a more complex variant of it, which automatically builds a image resolution pyramid for high quality mip-mapping. The standard by-the-OpenGL-textbook approach would also work, although less convienient, cfe. `SpinningCubeDemo.`.

For more detailed help from me you’d need to buy priority support.  
-mario

---

<div class="post-metadata">

**Author:** ![yyh\_dahua](https://avatars.discourse-cdn.com/v4/letter/y/ec9cab/32.png) [@yyh\_dahua](https://psychtoolbox.discourse.group/u/yyh_dahua)\
**Post date:** [March 20, 2021, 9:52am UTC](https://psychtoolbox.discourse.group/t/how-to-simply-create-2d-texture-for-3d-opengl-rendering/3754/3 "2021-03-20T09:52:31Z")

</div>

Thanks for your help. MinimalisticOpenGLDemo.m is really useful.
