-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visualisation options for actors #316
Comments
Simple test using stdimage and pass the loaded image pointer through a sphactor_report. It;s ugly but it works. We can't free in the imgui render code but anyway. In the actor, load image and pass the pointer through a report: int image_width = 0;
int image_height = 0;
unsigned char* image_data = stbi_load("/tmp/img.jpg", &image_width, &image_height, NULL, 4);
if (image_data == NULL)
return NULL;
int64_t paddr = (int64_t)image_data;
zsys_info("%i %i", paddr, image_data);
zosc_t *reportm = zosc_create("/triggerreport", "shsisi", "image", paddr, "width", image_width, "height", image_height);;
sphactor_actor_set_custom_report_data((sphactor_actor_t *)ev->actor, reportm); In gazebosc we enhance RenderCustomReport to render an image if first name is image: ImGui::BeginGroup();
if (streq(nameStr, "image"))
{
data = zosc_next(customData, &type); // next is the pointer
int64_t pointeraddr;
rc = zosc_pop_int64(customData, &pointeraddr);
assert(rc == 0);
unsigned char *image_data = (unsigned char *)pointeraddr;
zsys_info("retr %i %i", pointeraddr, image_data);
char *name;
int image_width = 0;
int image_height = 0;
data = zosc_next(customData, &type);
rc = zosc_pop_string(customData, &name);
assert(rc == 0);
assert(streq(name, "width"));
zstr_free(&name);
data = zosc_next(customData, &type);
rc = zosc_pop_int32(customData, &image_width);
assert(rc == 0);
data = zosc_next(customData, &type);
zosc_pop_string(customData, &name);
assert(streq(name, "height"));
zstr_free(&name);
data = zosc_next(customData, &type);
rc = zosc_pop_int32(customData, &image_height);
assert(rc == 0);
zsys_info("pointer %i, width %i, height %i", image_data, image_width, image_height);
// Create a OpenGL texture identifier
GLuint image_texture;
glGenTextures(1, &image_texture);
glBindTexture(GL_TEXTURE_2D, image_texture);
// Setup filtering parameters for display
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // This is required on WebGL for non power-of-two textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Same
// Upload pixels into texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
//stbi_image_free(image_data);
ImGui::SetNextItemWidth(LABEL_WIDTH);
ImGui::Text("size = %d x %d", image_width, image_height);
//ImGui::SameLine();
ImGui::SetNextItemWidth(VALUE_WIDTH);
//ImGui::SetNextItemWidth(LABEL_WIDTH+VALUE_WIDTH);
ImGui::Image((void*)(intptr_t)image_texture, ImVec2(image_width, image_height));
ImGui::EndGroup();
//ImGui::End();
}
else if (!streq(nameStr, "lastActive")) {
ImGui::SetNextItemWidth(LABEL_WIDTH);
ImGui::Text("%s:", nameStr);
ImGui::SameLine();
ImGui::SetNextItemWidth(VALUE_WIDTH);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a multithreading issue so it might be best to look how we can do this through Imgui.
See for custom drawlist options:
The text was updated successfully, but these errors were encountered: