Advertisement

OpenGL ViewPort Matrix

Started by October 16, 2019 02:30 PM
21 comments, last by _Silence_ 5 years, 3 months ago

Hi,

I'd like to get & set the OpenGL View Port Matrix but it doesn't work

I'm using the "GL_VIEWPORT" parameter

any ideas?

Reject the basic asumption of civialisation especially the importance of material possessions

If you can post a code sample and a description of what exactly isn't working, someone might be able to help.

Advertisement

@Zakwayda

if I say glGetIntegerv(GL_VIEWPORT, &matrix)

this gives the viewport position & size not the 4x4 viewport Matrix

 

If I use glLoadIntegerv(GL_VIEWPORT, &matrix)

this doesn't load a 4x4 Matrix in

 

Reject the basic asumption of civialisation especially the importance of material possessions

The behavior you describe for glGetIntegerv() seems consistent with the documentation. As for glLoadIntegerv(), I think for that it would help to see an actual compilable code sample.

@Zakwayda,

I deleted the code because it didn't work but it was something like this:

 

float matrix[16];

// Entered viewport matrix from book

glLoadFloatv( GL_VIEWPORT, matrix)

 

when I resized the window the viewport didn't change size.

Any way to get the 4x4 viewport matrix?

 

Reject the basic asumption of civialisation especially the importance of material possessions

Not to belabor the point, but I think we need to see actual code. When I search for the functions you mention, I can't even find them documented anywhere, so I think there may be a bit of a disconnect here.

I haven't kept up on recent versions of OpenGL, but I don't remember the viewport matrix being queryable. Also, it's not obvious how this:

Quote

when I resized the window the viewport didn't change size.

Relates to acquiring the viewport matrix. What do you need the viewport matrix for exactly?

Again, I think more information is needed. If you deleted the relevant code, then I suggest recreating it and then posting it here with an explanation of how it's not working.

Advertisement

@Zakwayda

if the matrix had loaded using glLoadFloatv the viewport would have resized when I changed the window size but didn't

I need the viewport matrix because I want to project objects positions onto screen positions & screen positions into object positions

Reject the basic asumption of civialisation especially the importance of material possessions
5 minutes ago, Cacks said:

if the matrix had loaded using glLoadFloatv the viewport would have resized when I changed the window size but didn't

Hm, well, I don't even know what glLoadFloatv() is (my Google search for that term returned a grand total of zero results). So either I'm making a mistake, or there's a disconnect here.

The reason I suggest posting an actual compilable code example is that if you are in fact referencing a non-existent function, posting a compilable code example will force you to correct that error, and then we'll know what it is you're actually trying to do. Again, it's possible I'm the one making the mistake here, but otherwise, I think without a code example we may be at an impasse.

Sorry glLoadMatrixf

Reject the basic asumption of civialisation especially the importance of material possessions
10 minutes ago, Cacks said:

Sorry glLoadMatrixf

Ok, that's closer, but we still may need to see what you're doing exactly.

As I mentioned earlier, I'm not up to date on recent OpenGL versions, so I should probably bow out at this point. But I'll leave you with a couple thoughts.

First, I think you should post a code example. Even a couple of compilable statements would show what it is you're actually trying to do. As it is, we're left to guess. If there's some reason you can't or don't want to post actual code, maybe you could share that with us.

Your mention of glLoadMatrixf() suggests to me that you might be using the fixed-function pipeline (although I'm not positive about that). If you're using the functionality I think you're using, then I think that functionality doesn't even apply to the viewport, and GL_VIEWPORT isn't even a valid parameter in that context.

That leads me to my last two suggestions, which are: 1) be sure to consult the documentation, and 2) use glGetError() or some other means to check for OpenGL errors (OpenGL will let you know if you do something obviously wrong like use an invalid parameter).

This topic is closed to new replies.

Advertisement