Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- allow them to work simultaneously (moving glMatrixMode(GL.GL_MODEL_VIEW) higher does this) - allow whole screen mirror-image via viewScale parameter, by using abs(scale) Limitations: - not tested what happens with orientation - does not fix psychopy#89
- Loading branch information
ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peircej: does this look about right? It works in the test scenarios I threw at it. tests pass, but that's not surprising since if there had been tests they would have been failing before.
If so, adding a scale field to the Exp settings -> screen would allow people to enter -1 to flip the entire display horizontally or vertically. So you could develop an experiment offline in normal view, and then flip for viewing in fMRI by changing a single parameter in the exp settings dialog. TextStim still are unaffected (i.e., psychopy#89 remains).
ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this looks wrong to me in two ways:
For the flipping we can also now do this by a different method that will be immune to the fact that text and pixel-by-pixel drawing (SimpleImageStim?) render with a different coordinates system. When the user has FBO turned on we can use the _renderFBO() method to control flipping and rescaling there instead. A few users have found slower performance with FBO turned on (I think for a very fast graphics card it won't be noticeable though) so we might turn it off by default (currently on by default i think). But with FBO on and a quick change to that _renderFBO function I'm certain that proper frame mirroring and rescaling can be achieved.
ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, ok: 1) The abs() part is essential to make the mirror image part actually work. Otherwise you get a double negative for scale values < 0. The first negative is from the
GL.glScalef(self.viewScale[0], self.viewScale[1], 1)
, then followed by thenorm_rf_pos[x,y]
. So negatives were canceling out, but no longer do with abs() in one of the places. And it actually flips now in practice and did not before :-)and then again a second time here:
With the code in this commit, you always get one or the other but not both. It was the both case that was problematic.
The sample script that Alexander posted could be the basis of a test. The 'both' case would fail, and the code here would make that pass.
BUT: I'm unsure about the differences between
GL.GL_MODELVIEW
andGL.GL_PROJECTION
, and possible carry over effects of using one versus the other.ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. But the second scale use is only applied to the positioning. I guess the question is whether the mirror should be applied to the shift or not. I think if you used a photograph you would see that the mirror is occurring (the abs func is only affecting a translate function, right?). Choosing whether or not to apply the sign of the scale during translate should decide whether the shift follows the mirror or not.
For GL_MODELVIEW and GL_PROJECTION I've also forgotten the important aspects of these (haven't touched them in a while). Hopefully it won't affect anything because each draw() function sets its matrix mode, but if I've missed that for anything then that object might get affected by a change here. Or we set the matrix mode back to some default at the end of the command (or push/pop matrix mode?)
Maybe @toddrjen can comment on the change, since he wrote the original code here
ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From googling around, it looks like CL_PROJECTION is probably not the thing to use here, based on https://www.opengl.org/discussion_boards/showthread.php/133880-Diference-between-GL_MODELVIEW-and-GL_PROJECTION and also http://sjbaker.org/steve/omniv/projection_abuse.html "in most cases you would want to define the projection matrix just once and use the modelview matrix all other times."
Using only GL_MODELVIEW fixed another issue I was having. So I now think lines ~611+ should be like this
ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've convinced myself that the proper mirror-reversals are happening when viewScale values are either positive or negative, and these are properly interacting with viewPos values (a non-zero position is the critical test). viewOri is not interacting correctly yet.
Here's a test script that could become a test (ignoring viewOri):
with the attached file
![s](https://cloud.githubusercontent.com/assets/382342/11231573/fd2e15f0-8d77-11e5-97a9-149585c084ea.png)
s.png
(image containing text) that looks like "fill fill", here:ff76914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great. Pending any comment from toddrjen I think we should include the change