gpt4 book ai didi

c++ - 如何在3D OpenGL场景上绘制SDL 2D矩形?

转载 作者:行者123 更新时间:2023-12-02 10:01:26 39 4
gpt4 key购买 nike

我正在尝试将用SDL 2D绘制的小的交互式信息矩形覆盖在用OpenGL绘制的3D场景上。每个人都能工作,但不能一起工作。然后隐藏3D模型。

SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

SDL_CreateWindowAndRenderer(m_width, m_height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE, &m_window, &m_renderer);
SDL_GLContext context = SDL_GL_CreateContext(m_window);
SDL_RenderClear(m_renderer);
SDL_RenderPresent(m_renderer);

// load vertex, fragmend shader...

glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, BUFFER_OFFSET(0));

SDL_Rect rect;
rect.w = 50;
rect.h = 50;
rect.x = 100;
rect.y = 100;

SDL_SetRenderDrawColor(m_renderer, 255, 0, 0, 255);
SDL_RenderFillRect(m_renderer, &rect);
SDL_RenderPresent(m_renderer);

我怎么解决这个问题?谢谢

最佳答案

您至少现在不会。

Here's the (open) bug about adding backend API state getters/setters to SDL_Renderer.

或者,创建一个使用软件渲染器的SDL_Renderer实例,然后将生成的位图上载到OpenGL纹理中,然后将其合成到场景中。

关于c++ - 如何在3D OpenGL场景上绘制SDL 2D矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62410834/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com