OpenGL and Threads
in
Android Processing
•
2 years ago
Hello,
I am making an application for android and thanks to DDMS and MAT I can keep tabs on how much memory which part of the program uses especially images since I use quite a lot in my application.
I have noticed that when you load your images with loadImage() at first there is only a relatively small amount of memory allocated and when you draw them with image() the full memory for the int array is allocated which can get pretty big using OpenGL pretty fast.
For example one image 800x480 is 800x480x4 = 1.536.000 bytes or roughly 1.47 MB.
So what I do for my application is that I load everything (loadImage()) in setup, but everything I do not need any more I throw out of the memory and use image() only when I load/display the images I need on the spot
So obviously you will see some hiccups when playing because of the loading of the images if you go to a new space..
So then I though let's try to create a separate Thread and show the images I need only once with the image() function in the separate thread so that I do not get hiccups and the user has a fluent experience..
But I am using OpenGL and apparently openGL does not like me when displaying images in separate threads and say to me:
OpenGL error 3780760 at render_triangles in: null
OpenGL error 3780760 at render_triangles out: null
And I end up with funky textures or just with squares... Can anybody give me some advice on this? or shed a light how processing or Java handles image in OpenGL with multiple threads ?
Since I am starting a new topic let me use this opportunity to thank everybody on this forum especially: ak_eric since I learned so much from everybody and I can only do what I am doing because of the knowledge shared on this forum..
I am making an application for android and thanks to DDMS and MAT I can keep tabs on how much memory which part of the program uses especially images since I use quite a lot in my application.
I have noticed that when you load your images with loadImage() at first there is only a relatively small amount of memory allocated and when you draw them with image() the full memory for the int array is allocated which can get pretty big using OpenGL pretty fast.
For example one image 800x480 is 800x480x4 = 1.536.000 bytes or roughly 1.47 MB.
So what I do for my application is that I load everything (loadImage()) in setup, but everything I do not need any more I throw out of the memory and use image() only when I load/display the images I need on the spot
So obviously you will see some hiccups when playing because of the loading of the images if you go to a new space..
So then I though let's try to create a separate Thread and show the images I need only once with the image() function in the separate thread so that I do not get hiccups and the user has a fluent experience..
But I am using OpenGL and apparently openGL does not like me when displaying images in separate threads and say to me:
OpenGL error 3780760 at render_triangles in: null
OpenGL error 3780760 at render_triangles out: null
And I end up with funky textures or just with squares... Can anybody give me some advice on this? or shed a light how processing or Java handles image in OpenGL with multiple threads ?
Since I am starting a new topic let me use this opportunity to thank everybody on this forum especially: ak_eric since I learned so much from everybody and I can only do what I am doing because of the knowledge shared on this forum..
1