[2.1] Rendering some lines with openGL

Problems building or running the engine, queries about how to use features etc.
Post Reply
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

[2.1] Rendering some lines with openGL

Post by Slicky »

I have some visual debugging code that uses glBegin(GL_LINES);

Rather, than reinventing the wheel I have tried to get it to render at the same times as Ogre. I haven't been successful in getting anything to show on the screen.

Is a particular point in the Ogre rendering process where I should use this?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Rendering some lines with openGL

Post by dark_sylinc »

Ogre 2.1 creates a GL Core context (in contrast to a Compatibility Profile context, which is optional though provided by most drivers except Mesa).

glBegin has been deprecated thus it is likely that it will fail to work as expected in core contexts.
Changing all instances of WGL_CONTEXT_CORE_PROFILE_BIT_ARB for WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB in Ogre's codebase might make it work. (GLX_CONTEXT_CORE_PROFILE_BIT_ARB for GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB in Linux)
Also I suggest you call RenderSystem->_startLegacyV1Rendering(); before your immediate mode calls, as that will bind a global VAO, though you may have to call: glBindVertexArray( 0 ); instead.
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

Re: [2.1] Rendering some lines with openGL

Post by Slicky »

Ok thanks for the info I will see if I can pull that off. I was aware of the deprecated GLines but I tried newer code too and it also didn't work.

One of my attempts was:

Code: Select all

		GLfloat vertices[] =
		{
			20.0f, 150.0f, 0.0f, 1.0f,
			220.0f, 150.0f, 0.0f, 1.0f,
			200.0f, 160.0f, 0.0f, 1.0f
		};
		glUseProgram(gProgramID);
		// This binds our vbo
		glBindBuffer(GL_ARRAY_BUFFER, gVBO);
		// This hands the vertices into the vbo and to the rendering pipeline    
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
		// "Enable a port" to the shader pipeline
		glEnableVertexAttribArray(0);
		glBindBuffer(GL_ARRAY_BUFFER, gVBO);
		// pass information about how vertex array is composed
		glVertexAttribPointer(0, // same as in glEnableVertexAttribArray(0)
			4, // # of coordinates that build a vertex
			GL_FLOAT, // data type
			GL_FALSE, // normalized?
			0,        // stride
			(void*)0);// vbo offset

		glDrawArrays(GL_LINES, 0, 2);
		glDisableVertexAttribArray(0);
		//Unbind program
		glUseProgram(NULL);
Post Reply