OpenGL black window

Hello, I am trying to use openGL to show a .obj model, with textures on a .tga file, let's assume for simplicity (and because i think that's not where the problem lies) that the vertexes, stored in out_vertices, the colors stored in out_uvs and the normals stored in out_normals are correct and in apropriate order;
My problem is that all this program does so far is draw a black screen... or rather draw nothing and the screen clears to black;
I'm only allowed to use openGL, glew, glm and glfw, because this is a university project, so no extra libraries plz. Here go my draw methods as well stuff in main() I feel have something to do with this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
int main()
{
	//start glfw
	if (!glfwInit()) return -1;

	//create window
	window = glfwCreateWindow(WIDTH, HEIGHT, "A window", NULL, NULL);
	if (window == NULL)
	{
		glfwTerminate();
		return -1;
	}
	//use window
	glfwMakeContextCurrent(window);

	//ativa sincronizaĆ§Ć£o vertical
	glfwSwapInterval(1);

	FILE *file = fopen("Iron_Man.obj", "r");
	if (file == NULL)
	{
		printf("Impossible to open the file !\n");
		return false;
	}

	if (glewInit() != GLEW_OK) {
		fprintf(stderr, "FALECEU!!!\n");
		getchar();
		glfwTerminate();
		return -1;
	}

	//load .obj assume its correct
	LoadModelVertex(file);
	//load image assume its correct
	Load_texture(image);

	glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * out_vertices.size(), &out_vertices[0], GL_TRIANGLES); //not sure what this does, i thought this sent the data of the arrays provided to the buffer, but my teacher made me think otherwise...

	//set color to clear window with
	glClearColor(0, 0, 0, 0);
	//set clear depth default
	glClearDepth(1);
	//set clear stencil default
	glClearStencil(0);

	//position, facing,UP (test to see if it drew behind camera, black screen too)
	//lookAt(*new vec3(0, 0, 0), *new vec3(0, 0, 1), *new vec3(0, 1, 0));

	//screen management
	display();

	//release glfw stuff
	glfwTerminate();
}

void display()
{
	do
	{
		//clear stuff
		glClear(GL_COLOR_BUFFER_BIT || GL_DEPTH_BUFFER_BIT);

		//glBindVertexArray(VAO); I had a Vao but did nothing with it so?

		draw();

		//swap buffers bcs we using back/front buffer
		glfwSwapBuffers(window);

		//process events and return
		glfwPollEvents();

	} while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&glfwWindowShouldClose(window) == 0);
}

void draw()
{
	//activate array for writing, and drawarrays() uses this
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);

	//location and format of data with coordinates of given array
	glVertexPointer(out_vertices.size(), GL_FLOAT, 0, &out_vertices);
	glVertexPointer(out_uvs.size(), GL_FLOAT, 0, &out_uvs);
	glVertexPointer(out_normals.size(), GL_FLOAT, 0, &out_normals);

	glDrawArrays(GL_TRIANGLES, 0, out_vertices.size());
	//glDrawElements(GL_TRIANGLES, out_vertices.size(), GL_UNSIGNED_INT, (void *)0); both these two don't work(black screen)

	//deactivate
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

	printf("drew a frame\n");
}
Last edited on
Duplicate of http://www.cplusplus.com/forum/beginner/238412/

Please DON'T spam multiple threads for the same problem. It wastes everyone's time, including your own.
I wanted to delete the last one... thought it was possible, I'm really sorry will surely never happen again from me.
Topic archived. No new replies allowed.