Jump to content

  • Log In with Google      Sign In   
  • Create Account


glScissor - Coordinate confusion


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Plerion   Members   -  Reputation: 354

Like
0Likes
Like

Posted 23 February 2013 - 09:50 AM

Hello everyone

 

Currently im facing some difficulties getting glScissor to work. Im trying to clip the elements that are outside my treeview (technically its only the last one before its completely "out of range" that can be cut off). Now this is done the following way:

void TreeView::draw() {
	glEnable(GL_SCISSOR_TEST);

	Vector2 screenPos = getScreenPosition();

	glScissor(/* something */);

	Vector2 startPos(mPosition.X + 2, mPosition.Y + 2);

	for(auto& elem : mRootItems) {
		renderItem(startPos, elem);

		if(startPos.Y >= mPosition.Y + mSize.Y)
			break;
	}

	glDisable(GL_SCISSOR_TEST);
}

 

FYI: screenPos is checked and is the correct window coordinate (relative to the top left point of the client area).

 

Now the something i have tested with various versions:

glScissor((int32)screenPos.X, sWindow->getClientHeight() - (int32)screenPos.Y, (int32)mSize.X, -(int32)mSize.Y);

 

Thats ok unless the window is resized then the items are all hidden unless i move the frame containing the treeview to the bottom left corner, there it gets visible until as long it stays inside a rectangle with the old size of the window (Imagine like that: You take the old size of the window and move it down to the bottom left corner. As long as the frame is inside this area its correctly displayed).

 

glScissor((int32)screenPos.X, sWindow->getClientHeight() - (int32)screenPos.Y, (int32)mSize.X, (int32)mSize.Y);

NOTE: difference is the missing - at (int32)mSize.Y

 

Cant see anything anywhere

 

glScissor((int32)screenPos.X, (int32)screenPos.Y, (int32)mSize.X, (int32)mSize.Y);

 

Its drawn correctly if the element is inside a horizontal band around the middle of the window with mSize.Y beeing the height of the band.

 

I guess i did not find the correct system for the coordinates yet. How do the coordinates of glScissor correspond to what i set at glViewport?

 

Greetings

Plerion



Sponsor:

#2 BornToCode   Members   -  Reputation: 902

Like
2Likes
Like

Posted 23 February 2013 - 08:50 PM

glScissor  cordinate 0,0 is the bottom left hand corner not the top left.



#3 Plerion   Members   -  Reputation: 354

Like
0Likes
Like

Posted 24 February 2013 - 03:15 AM

Hey BornToCode

 

Thanks, i was aware of that but i made a little error in reasoning. Anyway, im using the stencil buffer now so it dont need glScissor anymore but maybe another time :)

 

Greetings

Plerion






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS