You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to display the same texture in different scale modes. The screenshot shows the effect of test_fn below. Can I achieve the same effect without creating multiple textures?
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
staticvoidtest_fn(SDL_Renderer* renderer) {
static SDL_Texture *nearest = nullptr, *linear = nullptr;
constint w = 33, h = 25;
constint zoom = 4;
if (!nearest) {
nearest = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, w, h);
SDL_SetTextureScaleMode(nearest, SDL_ScaleModeNearest);
linear = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, w, h);
SDL_SetTextureScaleMode(linear, SDL_ScaleModeLinear);
Uint32 pixels[h][w];
bool b = false;
for (auto& line : pixels) {
for (Uint32& p : line) {
p = b ? 0 : -1;
b = !b;
}
}
SDL_UpdateTexture(nearest, nullptr, pixels, w * sizeof(Uint32));
SDL_UpdateTexture(linear, nullptr, pixels, w * sizeof(Uint32));
}
if (ImGui::Begin("Test", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse)) {
ImGui::Image(nearest, ImVec2(w * zoom, h * zoom));
ImGui::SameLine();
ImGui::Image(linear, ImVec2(w * zoom, h * zoom));
}
ImGui::End();
}
The text was updated successfully, but these errors were encountered:
Here is the background of this issue: I wanted to display a zoom window in nearest scale mode for a texture shown in linear mode. The problem was worked around by making a new texture with different scale mode, but I think the solution is wasteful.
Version/Branch of Dear ImGui:
Version 1.90.6
Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp
Compiler, OS:
Windows 10 + MSVC 2022
Full config/build information:
No response
Details:
I want to display the same texture in different scale modes. The screenshot shows the effect of
test_fn
below. Can I achieve the same effect without creating multiple textures?Screenshots/Video:
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: