DerelictGL program draw nothing

Ivan Agafonov armadil at yandex.ru
Mon Sep 3 11:47:48 PDT 2012


On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote:
> Why this simple program don't show white square?
>
> import std.stdio;
>
> import derelict.opengl3.gl;
> import derelict.glfw3.glfw3;
>
> const uint width = 200;
> const uint height = 200;
>
> void init()
> {
> 	glViewport(0,0,width,height);
> 	glMatrixMode(GL_PROJECTION);
> 	glLoadIdentity();
> 	glOrtho(-width,width,-height,height,-1,1);
> 	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
> }
>
> void display()
> {
> 	glClear(GL_COLOR_BUFFER_BIT);
> 	glBegin(GL_POLYGON);
> 		glVertex2d(0,0);
> 		glVertex2d(0,height);
> 		glVertex2d(width,height);
> 		glVertex2d(height,0);
> 	glEnd();
> }
>
> void main()
> {
> 	DerelictGL.load();
> 	DerelictGLFW3.load();
> 	glfwInit();
> 	GLFWwindow window;
> 	window = glfwCreateWindow(width,height,GLFW_WINDOWED,"Hello 
> DerelictGLFW3",null);
> 	init();
> 	bool opened = true;
> 	while(opened)
> 	{
> 		opened = !glfwGetWindowParam(window,GLFW_CLOSE_REQUESTED) && 
> !glfwGetKey(window,GLFW_KEY_ESC);
> 		display();
> 		glfwSwapBuffers(window);
> 		glfwWaitEvents();
> 	}
> 	glfwTerminate();
> }

width and height must be int, not uint.
After window = glfwCreateWindow();
put glfwMakeContextCurrent(window);
And it will work!


More information about the Digitalmars-d-learn mailing list