An error when call glfwIconifyWindow

part of code:

	glfwSetErrorCallback(error_callback);

	if (!glfwInit())
	{
		wprintf(L"Failed to initialize GLFW\n");
		return false;
	}

	glfwWindowHint(GLFW_SAMPLES, 4);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
	glfwWindowHint(GLFW_DECORATED, GL_FALSE);

	GLFWmonitor* primary = glfwGetPrimaryMonitor();
	const GLFWvidmode* mode = glfwGetVideoMode(primary);


	g_mainWnd = glfwCreateWindow(getMainWndW(), getMainWndH(), "Simple example", NULL, NULL);

	if (!g_mainWnd)
	{
		glfwTerminate();
		return false;
	}

	glfwMakeContextCurrent(g_mainWnd);
	glewExperimental = true; // Needed for core profile
	// before glew init, need make context current;
	if (glewInit() != GLEW_OK)
	{
		wprintf(L"Failed to initialize GLEW\n");
		deinit();
		return false;
	}

	glfwSwapInterval(1);
	glfwSetKeyCallback(g_mainWnd, key_callback);
	glfwSetCharModsCallback(g_mainWnd, charmods_callback);
	glfwSetFramebufferSizeCallback(g_mainWnd, resize_callback);
	glfwSetMouseButtonCallback(g_mainWnd, mouse_button_callback);
	glfwSetCursorPosCallback(g_mainWnd, cursor_position_callback);
	glfwSetScrollCallback(g_mainWnd, scroll_callback);
	glfwSetWindowRefreshCallback(g_mainWnd, refresh_callback);
	glfwSetInputMode(g_mainWnd, GLFW_STICKY_KEYS, GL_TRUE);
	glfwSetInputMode(g_mainWnd, GLFW_STICKY_MOUSE_BUTTONS, GL_TRUE);

	glfwIconifyWindow(g_mainWnd);

What error are you getting from glfwIconifyWindow and if you remove the call does your application work fine?

I’ve tried this on Windows with the latest version of GLFW and this works as expected.

1 Like

R6010

  • abort() has been called

OK - an abort call could be due to an assert. If you ran this under a debugger you should have been given the option to debug, and see the source of the issue.

GLFW asserts on a window handle being NULL, but it looks like you are checking this in your code. Are you able to find out where the program is aborting with a debugger?

Note that for it’s useful to know more details about your OS, system, compiler & debugger used, version of GLFW used etc. when trying to track down problems, if you can add details this may help.

What are getMainWndW and getMainWndH functions doing? Are you accessing g_mainWnd variable in them (which is not yet assigned)?

A1: getMainWndW and getMainWndH to get the window width and height
A2: g_mainWnd = glfwCreateWindow(getMainWndW(), getMainWndH(), “Simple example”, NULL, NULL);

Yes, I understand the place where are you calling them. I’m asking about how those functions are defined. What do they actually execute? How do they get window width and height? Are you sure they don’t use g_mainWnd variable in them?