I can't get opengl 2.1 vbo to draw

i have geforce 6200 , gnu/linux distro with real nvidia driver

all i get is blank screen and haven't found a solution to fix it without going back to glBegin()
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
// g++ -Wall -o glfwOpenGLplay glfwOpenGLplay.cpp -lGLEW -lglfw -lGLU -lGL

#include <GL/glew.h>
#include <GL/glfw.h>
#include <iostream>

int onExit(int);
void myprojection();
void mymodelview();


int main(void)
{
	if (!glfwInit())		return onExit(1);
	
	if (!glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_WINDOW)) 		return onExit(1);
	
	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		std::cout << "Error: " << glewGetErrorString(res) << std::endl;
		return 1;
	}
	
	glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
	myprojection();
	mymodelview();
	
	float tdata[] = { 1.0f, 0.0f, 5.0f,   0.0f, 0.0f, -5.0f,   -1.0f, 0.0f, -5.0f };
	GLuint tVBO;
	glGenBuffers(1, &tVBO);
	glBindBuffer(GL_ARRAY_BUFFER, tVBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(tdata), tdata, GL_STATIC_DRAW);
						
	while(glfwGetWindowParam(GLFW_OPENED))
	{
		
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glLoadIdentity();
		
		//glTranslatef(0.0f, 0.0f, -1.0f);
		//glColor3f(0.0f, 1.0f, 0.0f);
		
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, 0, 0);
		glDrawArrays(GL_TRIANGLES, 0, sizeof(tdata) / sizeof(float) / 3);
		glDisableClientState(GL_VERTEX_ARRAY);
		glfwSwapBuffers();
		
		if(glfwGetKey( GLFW_KEY_ESC ) == GL_TRUE)
			glfwCloseWindow();
			
		glfwSleep( 0.015 );
	}
	return onExit(0);
}

int onExit(int code)
{
	glfwTerminate();
	return code;
}

void myprojection()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	//gluPerspective(90.f, 1.f, 1.f, 300.f);
}

void mymodelview()
{
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
Last edited on
I was trying to draw a flat triangle . oops! fixed now.
Last edited on
Topic archived. No new replies allowed.