simple program for creating a large square and concentric smaller squares in it...

hi, i can’t get this simple program to work. im using linux, i dont know whether its a glx problem or not so ill post it here first. im trying to make squares each with a different color that fit inside eachother and leave an L shape where the bigger first square is not covered by the smaller one

im doing this by starting with a simple identity matrix and lowering x and y 1 values by 0.2 to create smaller squares. im giving the matrix and color values through uniform variables in my shaders.
what happens is that the last drawn square is the only square drawn and all the space around it where the other squares should be is the color i set the window to clear to
[ATTACH=CONFIG]745[/ATTACH]

here is my attributes for my fbattribute config:

int doublebufferattributes[] = {
    GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
    GLX_RENDER_TYPE,   GLX_RGBA_BIT,
    GLX_DOUBLEBUFFER,  True,  /* Request a double-buffered color buffer with */
    GLX_RED_SIZE,      1,     /* the maximum number of bits per component    */
    GLX_GREEN_SIZE,    1, 
    GLX_BLUE_SIZE,     1,
    None
};

here is my init function:

void init()
{
	if (glewInit() != GLEW_OK)
	{
		printf("glew could not load");
		exit(1);
	}
	
	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);
	glClearColor(0, 0, 0, 1);
	const char *fshader =
	    	    "#version 430 core
"
	    		"out vec4 fColor;
"
	    		"uniform vec4 Color;
"
	    		"void main()
"
	    	    "{
"
	    		"fColor = Color;
"
	    	    "}
";

	const char *vshader =
	    	    "#version 430 core
"
	    	    "layout (location = 0) in vec3 vPosition;
"
	    	    "uniform mat3  Basicmat;
"
	    		"void main()
"
	    	    "{
"
	    	    "gl_Position = vec4(Basicmat * vPosition, 1);
"
	    		"}
";

	GLuint prog = glCreateProgram();

	GLuint vert = glCreateShader(GL_VERTEX_SHADER);
	GLuint frag = glCreateShader(GL_FRAGMENT_SHADER);

	GLint vlen = (GLint)strlen(vshader);
	GLint flen = (GLint)strlen(fshader);

	glShaderSource(vert, 1, &vshader, &vlen);
	glShaderSource(frag, 1, &fshader, &flen);
	glCompileShader(vert);
	glCompileShader(frag);


	glAttachShader(prog, vert);
	glAttachShader(prog, frag);
	glLinkProgram(prog);
	glUseProgram(prog);
			
	GLint statusvert;
	GLint statusfrag;
	
	glGetShaderiv(vert, GL_COMPILE_STATUS, &statusvert);
	glGetShaderiv(frag, GL_COMPILE_STATUS, &statusfrag);
	
	printf("vert: %d
frag: %d
", statusvert, statusfrag);
	printf("GL_TRUE: %d
GL_FALSE: %d
", GL_TRUE, GL_FALSE);
	
	colorloc = glGetUniformLocation(prog, "Color");
	matloc = glGetUniformLocation(prog, "Basicmat");
	
	GLfloat vertices[] = {
		0, 0, 0,
	    0, 1, 0,
	    1, 1, 0,
	    0, 0, 0,
	    1, 1, 0,
	    1, 0, 0
	};

	glGenBuffers(1, &buf);
	glBindBuffer(GL_ARRAY_BUFFER, buf);
	glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_STATIC_DRAW);

	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void *)0);
	glEnableVertexAttribArray(0);
	
	
}

here is my display function:

void displayfunc()
{
	glClear(GL_COLOR_BUFFER_BIT);
	
	glUniform4f(colorloc, 1, 0, 0, 1);
	glUniformMatrix3fv(matloc, 1, GL_FALSE, Basicmat);
	
	glDrawArrays(GL_TRIANGLES, 0 , 6);
		
		glUniform4f(colorloc, 0, 1, 0, 1);
		
		Basicmat[0] = 0.8;
		Basicmat[4] = 0.8;
		
		glUniformMatrix4fv(matloc, 1, GL_FALSE, Basicmat);
		
		glDrawArrays(GL_TRIANGLES, 0 , 6);
	
	glUniform4f(colorloc, 0, 0, 1, 1);
		
		Basicmat[0] = 0.6;
		Basicmat[4] = 0.6;
		
		glUniformMatrix4fv(matloc, 1, GL_FALSE, Basicmat);
		
		glDrawArrays(GL_TRIANGLES, 0 , 6);
}

it seems as though the gldrawarrays clears the screen.

thanks for the help

nevermind :slight_smile: