# Is there an simple example code of a program using c / c++ and OpenGL ES?

**URL:** <https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211>\
**Category:** Developers\
**Tags:** retroarch, opengl, c, cpp\
**Created:** [August 4, 2018, 9:07am UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211 "2018-08-04T09:07:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AC\_YOUCH](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ac_youch/32/801_2.png) [@AC\_YOUCH](https://forum.clockworkpi.com/u/AC_YOUCH)\
**Post date:** [August 4, 2018, 9:07am UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/1 "2018-08-04T09:07:52Z")

</div>

Is there an simple example code of a program using c / c++ and OpenGL ES?

I compiled the program code using glfw. However, it did not work well in gameshell’s environment.

---

<div class="post-metadata">

**Author:** ![Godzil](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/godzil/32/60_2.png) [@Godzil](https://forum.clockworkpi.com/u/Godzil)\
**Post date:** [August 4, 2018, 11:43am UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/2 "2018-08-04T11:43:39Z")

</div>

well it is highly possible that there is no opengl library as there is no GPU acceleration.

I’m not sure if mesa work on ARM platform.

How does it fail?

---

<div class="post-metadata">

**Author:** ![AC\_YOUCH](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ac_youch/32/801_2.png) [@AC\_YOUCH](https://forum.clockworkpi.com/u/AC_YOUCH)\
**Post date:** [August 4, 2018, 3:01pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/3 "2018-08-04T15:01:50Z")

</div>

hi Godzil

I am a beginner of “arm linux”.

[Compare clockwork Pi and Raspberry Pi](https://ksr-ugc.imgix.net/assets/019/358/103/eefc4e413448f4f4094a2ec96818e6d0_original.jpg?w=680&fit=max&v=1511449938&auto=format&q=92&s=7901c671af323d2829947414c4840766)

## “GPU Mail 400 MP 2 Supports OpneGL ES 2.0” was written. There was “libglfw.so” and so on in “/ usr / lib / arm-linux-gnueabihf”. From two conditions, maybe I can make a polygon display program? I thought.

```
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
window = glfwCreateWindow(WIDTH, HEIGHT, __FILE__ , NULL, NULL);
glfwMakeContextCurrent(window);

```

–  
However, the return value of glfwCreateWindow () was null.  
Probably, I think that this program method was incorrect.

I hope that a simple triangle display program will be provided from “Clockwork”.

- I used google translation

---

<div class="post-metadata">

**Author:** ![fr500](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/fr500/32/389_2.png) [@fr500](https://forum.clockworkpi.com/u/fr500)\
**Post date:** [August 4, 2018, 4:16pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/4 "2018-08-04T16:16:37Z")

</div>

There is GL support via llvmpipe (ie, it’s software rendered)  
GL works (RA video driver is GL based) it’s just slow.

It’s GL, not GLES btw (since llvmpipe is GL)

---

<div class="post-metadata">

**Author:** ![AC\_YOUCH](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ac_youch/32/801_2.png) [@AC\_YOUCH](https://forum.clockworkpi.com/u/AC_YOUCH)\
**Post date:** [August 4, 2018, 5:17pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/5 "2018-08-04T17:17:58Z")

</div>

hi fr500

(Is “RA video driver” a “RetroArch video driver”…?)

There are currently no libraries or methods to use hardware rendering (OpenGL ES etc.) from c / c ++ programs of GameShell.  
Is this my understanding correct?

- I used google translation

---

<div class="post-metadata">

**Author:** ![AC\_YOUCH](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ac_youch/32/801_2.png) [@AC\_YOUCH](https://forum.clockworkpi.com/u/AC_YOUCH)\
**Post date:** [August 5, 2018, 7:35am UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/6 "2018-08-05T07:35:11Z")

</div>

MEMO:  
[OpenGL on Mali GPU (BananaPi, OrangePi PC, etc)](https://forum.armbian.com/topic/1420-opengl-on-mali-gpu-bananapi-orangepi-pc-etc/)

---

<div class="post-metadata">

**Author:** ![Godzil](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/godzil/32/60_2.png) [@Godzil](https://forum.clockworkpi.com/u/Godzil)\
**Post date:** [August 5, 2018, 12:29pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/7 "2018-08-05T12:29:18Z")

</div>

If glfw can’t create the window and an OpenGL context it mean that something is missing.

@AC_YOUCH what is the exact error you get?

---

<div class="post-metadata">

**Author:** ![fr500](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/fr500/32/389_2.png) [@fr500](https://forum.clockworkpi.com/u/fr500)\
**Post date:** [August 5, 2018, 1:38pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/8 "2018-08-05T13:38:54Z")

</div>

Yes, RetroArch video driver.  
I tried installing the sunxi drivers before and I failed. Let me know if it works for you.

@Godzil well GLX gears works. Regarding GLFW, I wouldn’t know, but I see he’s starting it with GLFW\_OPENGL\_ES\_API, afaik llvmpipe supports GL not GLES, so maybe that has to be changed.

As I said, GL on the CPI is software rendered (so far), so the GPU supported APIs are irrelevant.

---

<div class="post-metadata">

**Author:** ![Godzil](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/godzil/32/60_2.png) [@Godzil](https://forum.clockworkpi.com/u/Godzil)\
**Post date:** [August 5, 2018, 1:45pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/9 "2018-08-05T13:45:11Z")

</div>

Well the thing is without proper output showing how it fail, it is hard to know why it fail 🙂

I.E. if it is not a build error, I would highly recommend to use that : [http://www.glfw.org/docs/3.0/group\_\_error.html](http://www.glfw.org/docs/3.0/group__error.html) to get the exact reason why it fail

---

<div class="post-metadata">

**Author:** ![AC\_YOUCH](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ac_youch/32/801_2.png) [@AC\_YOUCH](https://forum.clockworkpi.com/u/AC_YOUCH)\
**Post date:** [August 5, 2018, 8:25pm UTC](https://forum.clockworkpi.com/t/is-there-an-simple-example-code-of-a-program-using-c-c-and-opengl-es/1211/10 "2018-08-05T20:25:20Z")

</div>

@fr500  
Thank you for your advice and trying.  
I would like to try it, but that is difficult for me.  
I used linux for gameshell for the first time.

I hope the clockwork formula will provide an OS image supporting hardware rendering.

@Godzil  
Thank you for the advice.

The reason I tried glfw is because I had the programming experience with windows + glfw in the past.  
I wanted to confirm hardware rendering of gameshell.  
I think that whatever means of confirmation was good.
