#define GLEW_STATIC
#include <stdio.h>
#include <GL\glew.h>
#include <GL\GLU.h>
#include <GL\glut.h>
#include <glm.hpp>
#include <GL\gl.h>
#include <GLFW\glfw3.h>
using namespace glm;
using namespace std;
int main()
{
glfwWindowHint(GLFW_SAMPLES, 4); // anti aliasing
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // openGL major version to be 3
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); // minor set to 3, which makes the version 3.3
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // for MAC OS only
glfwWindowHint(GLFW_OPENGL_COMPAT_PROFILE, GLFW_OPENGL_CORE_PROFILE); //avoid using old openGL
GLFWwindow* window;
window = glfwCreateWindow(1024, 768, "First Window in OpenGL", NULL, NULL);
if (window == NULL)
{
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0,
0.0f, 1.0f, 0.0f
};
// identifying our vertex buffer
GLuint vertexbuffer;
glGenBuffers(1, &vertexbuffer);
// The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
glewExperimental = true; // Needed in core profile
if (glewInit() != GLEW_OK)
{
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do{
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle
glDisableVertexAttribArray(0);
glfwSwapBuffers(window);
glfwPollEvents();
}
while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0);
return 0;
}
窗口立即关闭的原因是因为您有分段错误。这很可能是由于未能以适当的顺序初始化事物。
在运行任何glfw函数调用之前初始化glfw
,如下所示:
// Initialise GLFW
if( !glfwInit() ) {
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4); // anti aliasing
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // openGL major version to be 3
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); // minor set to 3, which makes the version 3.3
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // for MAC OS only
glfwWindowHint(GLFW_OPENGL_COMPAT_PROFILE, GLFW_OPENGL_CORE_PROFILE); //avoid using old openGL
GLFWwindow* window;
window = gl
然后,在创建和设置GL上下文之后,将glew
的初始化移到右侧:
if (window == NULL) {
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE; // Needed in core profile
const GLenum err = glewInit();
if (err != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
return -1;
}
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
// ... rest of code follows
新窗口打开链接 该方法可以新起webview打开页面,由于客户端窗口过多会占用较多内存,请谨慎使用 Tida.pushWindow("http://www.tmall.com/go/chn/common/u-award.php?disableptf=1"); 关闭窗口 关闭当前webview窗口 Tida.popWindow();
查看这段代码,它们展示了一种在登录后显示新窗口的方法。当用户名和密码是正确的,它打开新的对话框。我想要一个按钮点击打开新的对话框,而不检查用户名和密码。
任务:Main.Main()失败无法创建窗口 执行任务“:main.main()”失败。 进程“命令”c:/program files/java/jdk-16/bin/java.exe“以非零退出值-1结束 null null
问题内容: 我在JPopupMenu中有一个JComboBox(以及其他组件)。事实证明,每当我打开组合框的弹出窗口(以选择一个项目)时,父级JPopupMenu都会关闭。我一直在尝试找到一种方法来覆盖此功能,但无济于事。 有没有人建议防止关闭父级JPopupMenu?谢谢! 问题答案: 这不可能直接实现,很难覆盖已知的错误,另一方面,Swing不允许同时使用两个lightwieght弹出组件 但
我试图创建一个程序,它有一个tkinter窗口打开,然后当你按下一个按钮,它关闭tkinter窗口,打开一个pyplay窗口。然而,当我点击按钮打开pyplay窗口时,它会打开pyplay窗口,而tkinter窗口保持打开状态。 代码: 我还尝试使用: 我怎样才能解决这个问题?(我正在MacOS 11.1上运行Python 3.7.7)
本文向大家介绍C# Winform中实现主窗口打开登录窗口关闭的方法,包括了C# Winform中实现主窗口打开登录窗口关闭的方法的使用技巧和注意事项,需要的朋友参考一下 在使用C#进行Winform编程时,我们经常需要使用一个登录框来进行登录,一旦输入的用户名密码登录成功,这时登录窗口应该关闭,而且同时打开主程序窗口。该如何来实现呢? 乍一想,很简单啊,打开主窗口就用主窗口的Show()方法,而