Skip to main content
gamedev.net
🔒 Locked

drawing order

Started by me_here_me 1 reply 950+ views
Original Post
me_here_me
me_here_me
Hi, I am drawing two textures and a cylinder on my screen. First texture needs to be drawn over all the display screen. The second texture only occupies the lower right quadrant of the the screen, while the cylinder should also be over the entire screen. Problem: I am not able to arrange all of these. I want to cylinder to be the top most object, followed by second texture (occupying part of screen), and in the end to be the first texture. But in practice I get the following ordering. On top is second texture, followed by cylinder, and in the last is the first texture. My display code is as below:

	glUseProgram(0);
	GLUquadricObj* quadraticObject = gluNewQuadric( );	

	glColor4f(1.0,0.0,0.0,1.0);
	glTranslatef(0.0,0.0,-250.0);
	gluCylinder(quadraticObject, 50.0, 50.0, 500.0, 100, 100);

	glColor4f(1.0,1.0,1.0,1.0);

	// render image to screen
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
	glViewport(0, 0, width(), height());

	glUseProgram(0);
	glClearColor(1, 1, 1, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();

	if (generateBoxPlot3D){
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, txSecond);
		glEnable(GL_TEXTURE_2D);

		glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex2f(0, -1);
		glTexCoord2f(0, 1); glVertex2f(0,  0);
		glTexCoord2f(1, 1); glVertex2f( 1,  0);
		glTexCoord2f(1, 0); glVertex2f( 1, -1);
		glEnd();
	}

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, txFirst);
	glEnable(GL_TEXTURE_2D);

	glBegin(GL_QUADS);
	glTexCoord2f(0, 0); glVertex2f(-1, -1);
	glTexCoord2f(0, 1); glVertex2f(-1,  1);
	glTexCoord2f(1, 1); glVertex2f( 1,  1);
	glTexCoord2f(1, 0); glVertex2f( 1, -1);
	glEnd();


best wishes
speciesUnknown
speciesUnknown
Quote:
Original post by me_here_me
Hi,
I am drawing two textures and a cylinder on my screen.

First texture needs to be drawn over all the display screen. The second texture only occupies the lower right quadrant of the the screen, while the cylinder should also be over the entire screen.

Problem: I am not able to arrange all of these.

I want to cylinder to be the top most object, followed by second texture (occupying part of screen), and in the end to be the first texture.

But in practice I get the following ordering.
On top is second texture, followed by cylinder, and in the last is the first texture.

My display code is as below:
*** Source Snippet Removed ***

best wishes


Try this:

glDisable(GL_DEPTH_TEST);
drawYourStuffInOrder();
glEnable(GL_DEPTH_TEST);


Bear in mind that the facets of the cylinder will be drawn in the order you do them, so you will need to draw them in the order of their distance from the screen.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
me_here_me
me_here_me
thanks for the hint.

I managed to do the trick using

glDepthMask(true) and glDepthMask(false)

best wishes

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.