Java – How to create bitmap from integer array in C / OpenGL

android, c++, java, opengl-es

I am trying to move my code from Java to C, and I have encountered a problem while trying to find a function in C that can take an array of ints and create a bitmap from it for OpenGL. In Java, I used

bitmap = Bitmap.createBitmap( {int array name} , w, h, Config.RGB_565);

Is there a similar function that I can use in C, or a workaround that I could use?

Also, if it matters, I am programming for Android.


Best Solution

I am not specifically familiar with android but if I remember by OpenGL C bindings properly there is no Bitmap structure. Instead the various bitmap function (i.e. glBindTexture()) just take GLuint pointers (the C equivalent of an array).

In Java everything is a class so the bitmap has a class associated with it, but the bitmap class is mostly just a wrapper (and some functions) for the int array which actually contains your image.

In OpenGL specifically, we often times bind an array with the glBindTexture function, and then other texture functions take the name it's bound to to reference the correct 'state' for OpenGL.

On the other hand if you are trying to short circuit this process you can always use glTexImage2D