Hello guys,
I have a Question. Is it possible to add CEF into a ImGUI Window?
I get on the CEF onPaint Function a buffer and can I at this buffer into a ImGUI Window?
void CEFView::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType paintType, const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height)
I have no idea what CEF is. Please clarify the question and the context.
You can use AddImage() to render anything that your imgui renderer wants to handle, and you can use render callbacks as well.
On 13 May 2017, at 12:09, Centurius123 notifications@github.com wrote:
Hello guys,
I have a Question. Is it possible to add CEF into a ImGUI Window?
I get on the CEF onPaint Function a buffer and can I at this buffer into a ImGUI Window?
void CEFView::OnPaint(CefRefPtrbrowser, CefRenderHandler::PaintElementType paintType, const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height) ―
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Ohh sorry!
CEF -> Chromium Embedded Framework
https://bitbucket.org/chromiumembedded/cef
I try to open a Website and draw this Website into a ImGUI Window
So the most typical approach would be to render CEF into a texture, which may already be the case.
Then depending on how your imgui renderer loop handle ImTextureId you can pass the information of this texture to eg AddImage().
ImTextureId is basically a void* type can you use to pass texture/material information from your app code to your renderer code.
I try to use ImGUI::Image, but my game crashs.
I can write the buffer into a bmp file, but I dont know how I create a Image with the buffer into a ImGUI Window
If something crash please specify exactly why and in which condition.
Uploading a texture to your renderer/engine is up to you, it's generally a simple/common task. If you are using one of the stock imgui_impl_xxx.cpp examples so you can see how they upload textures. For example OpenGL uses glGenTextures+glBindTexture+glTexImage2D
I use dx11
How I draw a Bitmap?
You upload it into a texture and pass this texture pointer to AddImage().
Do you have an example for addimage?
Use
ImGui::Image(ID3D11ShaderResourceView* id, ImVec2 size);
ImTextureID = ID3D11ShaderResourceView* if you are using imgui_impl_dx11.cpp renderer.
I was looking for it!
Is it possible to use ImGui to render the buffer using DX9?
I tried using ImGui :: Image and drawlist-> addimage, but crash
Please provide your code snippet.
Please provide info about the crash.
On 17 May 2017, at 01:33, rafadsm20 notifications@github.com wrote:
I was looking for it!
Is it possible to use ImGui to render the buffer using DX9?
I tried using ImGui :: Image and drawlist-> addimage, but crash―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
My code:
static class CefDelegate
{
public:
void OnPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const void* buffer, int width, int height)
{
ImGui_ImplDX9_NewFrame();
ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiSetCond_FirstUseEver);
ImGui::SetNextWindowPos(ImVec2(0, 0));
if (!ImGui::Begin("Cef Frame", 0, ImVec2(0, 0), 0.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings))
{
ImGui::End();
return;
}
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddImage(&buffer, ImVec2(0, 0), ImVec2(width, height));
/*
or
ImGui::Image(&buffer, ImVec2(width, height));
*/
ImGui::End();
RGetDevice()->SetRenderState(D3DRS_ZENABLE, false);
RGetDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
RGetDevice()->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
ImGui::Render();
}
};
Visual Studio ScreenShot
https://prnt.sc/f8wrod
DX9 version
I also tried to store a buffer in a texture using:
In Definitions
IDirect3DTexture9* tx;
In Init
RGetDevice()->CreateTexture(RGetScreenWidth(), RGetScreenHeight(), 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, &tx, NULL);
In OnPaint:
D3DLOCKED_RECT d3dLockedRect;
tx->LockRect(0, &d3dLockedRect, 0, 0);
memcpy(d3dLockedRect.pBits, buffer, width *height* 4);
tx->UnlockRect(0);
In Draw Function:
draw_list->AddImage(tx, ImVec2(0, 0), ImVec2(width, height));
or
ImGui::Image(tx, ImVec2(width, height));
OnPaint API Docs: http://magpcss.org/ceforum/apidocs/projects/(default)/CefRenderHandler.html#OnPaint(CefRefPtr
Is &buffer a LPDIRECT3DTEXTURE9, aka buffer of DIRECT3DTEXTURE9 type?
Read the rendering code ImGui_ImplDX9_RenderDrawLists to understand what is happening. Whatever you are passing to ImGui::Image or ImDrawList::AddImage() is passed to that render loop,
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
Also this (bool*)true passed on Begin makes no sense. Pass a NULL pointer if you don't have a bool to store the state of whether the window is open or not. You are passing an invalid pointer (pointer to 0x00000001) which is going to crash whenever imgui tries to write there.
PS: When posting attachment, please use the github attachment system.
Is &buffer a LPDIRECT3DTEXTURE9, aka buffer of DIRECT3DTEXTURE9 type?
No, the documentation says it contains pixel data for the entire image
"|buffer| contains the pixel data for the whole image"
PS: When posting attachment, please use the github attachment system.
I apologize, I did, but the attached image did not open, so I sent
Could you help me convert the buffer to an IDirect3DTexture9 texture?
I tried using:
My application freezes and crashes using this
D3DLOCKED_RECT d3dLockedRect;
tx->LockRect(0, &d3dLockedRect, 0, 0);
memcpy(d3dLockedRect.pBits, buffer, width *height* 4);
tx->UnlockRect(0);
Could you help me convert the buffer to an IDirect3DTexture9 texture?
Sorry this question has nothing to do with imgui. Try to look up the answer elsewhere.
Try to use CreateDDSTextureFromMemory()
Most helpful comment
Sorry this question has nothing to do with imgui. Try to look up the answer elsewhere.