Hello everybody,
I wrote an application with the chromium embedded framework and it just simply renders a Webbrowser window to a texture in openGL.Now I want to use this texture in another application which also uses the openGL engine to render stuff.My question is now how can I share the texture with the other application ? The First application uses the following code to render the browser to a texture and bind it.I hope someone can help me with this problem
render_handler.h:
#include <GL/glew.h>
#include <include/cef_render_handler.h>
class RenderHandler : public CefRenderHandler
{
public:
RenderHandler();
public:
void init();
void resize(int w, int h);
// CefRenderHandler interface
public:
bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect);
void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height);
// CefBase interface
public:
IMPLEMENT_REFCOUNTING(RenderHandler);
public:
GLuint tex() const { return tex_; }
private:
int width_;
int height_;
GLuint tex_;
};
render_handler.cpp:
#include "render_handler.h"
RenderHandler::RenderHandler()
: width_(2), height_(2), tex_(0)
{
}
void RenderHandler::init()
{
glGenTextures(1, &tex_);
glBindTexture(GL_TEXTURE_2D, tex_);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// dummy texture data - for debugging
const unsigned char data[] = {
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
255, 255, 255, 255,
};
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glBindTexture(GL_TEXTURE_2D, 0);
}
void RenderHandler::resize(int w, int h)
{
width_ = w;
height_ = h;
}
bool RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
{
rect = CefRect(0, 0, width_, height_);
return true;
}
void RenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height)
{
glBindTexture(GL_TEXTURE_2D, tex_);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*)buffer);
glBindTexture(GL_TEXTURE_2D, 0);
}