DerelictGL program draw nothing

Zhenya zheny at list.ru
Mon Sep 3 11:58:19 PDT 2012


On Monday, 3 September 2012 at 18:47:25 UTC, Ivan Agafonov wrote:
> 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!
Thank you very much)




More information about the Digitalmars-d-learn mailing list