Skip to content
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

Fix OpenGL initialization on Windows #6

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions drivers/opengl/rasterizer_storage_opengl.cpp
Original file line number Diff line number Diff line change
@@ -356,10 +356,7 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
need_decompress = true;
}
} break;
#if 0
// these have changed in the enum, no idea about PVR formats so left out for now
// FTODO
case Image::FORMAT_PVRTC2: {
case Image::FORMAT_PVRTC1_2: {
if (config.pvrtc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
@@ -370,7 +367,7 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC2A: {
case Image::FORMAT_PVRTC1_2A: {
if (config.pvrtc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
@@ -382,7 +379,7 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
}

} break;
case Image::FORMAT_PVRTC4: {
case Image::FORMAT_PVRTC1_4: {
if (config.pvrtc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
@@ -394,7 +391,7 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
}

} break;
case Image::FORMAT_PVRTC4A: {
case Image::FORMAT_PVRTC1_4A: {
if (config.pvrtc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
@@ -406,7 +403,6 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
}

} break;
#endif
case Image::FORMAT_ETC: {
if (config.etc1_supported) {
r_gl_internal_format = _EXT_ETC1_RGB8_OES;
@@ -439,7 +435,7 @@ Ref<Image> RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref<Image> &p
need_decompress = true;
} break;
default: {
ERR_FAIL_V(Ref<Image>());
ERR_FAIL_V(p_image);
}
}

@@ -497,8 +493,8 @@ RID RasterizerStorageOpenGL::texture_allocate() {
}

void RasterizerStorageOpenGL::texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) {
// Texture *tex = texture_owner.getornull(p_texture);
// ERR_FAIL_COND(!tex);
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);

int w = p_image->get_width();
int h = p_image->get_height();
11 changes: 7 additions & 4 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
@@ -1731,17 +1731,18 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
void DisplayServerWindows::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
_THREAD_SAFE_METHOD_
#if defined(VULKAN_ENABLED)
context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
// TODO disabling for now
//context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
#endif
}

DisplayServer::VSyncMode DisplayServerWindows::window_get_vsync_mode(WindowID p_window) const {
_THREAD_SAFE_METHOD_
#if defined(VULKAN_ENABLED)
return context_vulkan->get_vsync_mode(p_window);
#else
return DisplayServer::VSYNC_ENABLED;
//TODO disabling for now
//return context_vulkan->get_vsync_mode(p_window);
#endif
return DisplayServer::VSYNC_ENABLED;
}

void DisplayServerWindows::set_context(Context p_context) {
@@ -3213,6 +3214,8 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win

outside = true;

rendering_driver = p_rendering_driver;

// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
if (wintab_lib) {
2 changes: 1 addition & 1 deletion platform/windows/gl_manager_windows.cpp
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ int GLManager_Windows::_find_or_create_display(GLWindow &win) {
// }

// create
GLDisplay d_temp;
GLDisplay d_temp = {};
_displays.push_back(d_temp);
int new_display_id = _displays.size() - 1;

6 changes: 4 additions & 2 deletions servers/rendering/renderer_viewport.cpp
Original file line number Diff line number Diff line change
@@ -145,8 +145,10 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
timestamp_vp_map[rt_id] = p_viewport->self;
}

// This is currently needed for GLES to keep the current window being rendered to up to date
DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen);
if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl") {
// This is currently needed for GLES to keep the current window being rendered to up to date
DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen);
}

/* Camera should always be BEFORE any other 3D */