main.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. I am doing off-screen processing using opengl es2.0 on Android.
  3. I created a renderbuffer, and attached it to a framebuffer FBO, after rendering to the FBO, I try to get the pixels from that FBO by getReadPixels() method. But I got nothing.
  4. The code is shown below:
  5. */
  6. // compile with LDFLAGS=-lGLEW -lglut
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <math.h>
  11. #include <time.h>
  12. #include "ogles_gpgpu/ogles_gpgpu.h"
  13. int main(void)
  14. {
  15. /*
  16. OGJNIWrapper ogWrapper = new OGJNIWrapper();
  17. ogWrapper.init(true, false, true);
  18. ogWrapper.setRenderDispShowMode(OGJNIWrapper.RENDER_DISP_MODE_INPUT);
  19. ogWrapper.setRenderDispShowMode(OGJNIWrapper.RENDER_DISP_MODE_OUTPUT);
  20. ogWrapper.setRenderDisp(width, height, OGJNIWrapper.ORIENTATION_FLIPPED);
  21. ogWrapper.prepare(camPreviewFrameSize.width, camPreviewFrameSize.height, false);
  22. int camTextureId = createGLTexture();
  23. SurfaceTexture camTexture = new SurfaceTexture(camTextureId);
  24. ogWrapper.setInputTexture(camTextureId);
  25. ogWrapper.process();
  26. ogWrapper.renderOutput();
  27. imgData = ogWrapper.getOutputPixels();
  28. if (ogWrapper != null) {
  29. ogWrapper.cleanup();
  30. ogWrapper = null;
  31. */
  32. GLuint resultFBO; // frame buffer object id
  33. GLuint rboId; // render buffer object id
  34. GLuint image_width, image_height = 100;
  35. Core core = new Core::getInstance();
  36. core::init(GL context);
  37. core::checkGLExtensions();
  38. //core::setInputData(data);
  39. // GL_RGBA || GL_NONE
  40. //uint16_t w, h = 100;
  41. //core::prepare(w, h, GL_NONE);
  42. //core::getOutputData(data);
  43. core::cleanup();
  44. core::destroy();
  45. return 0;
  46. }