Jump to content
  • Advertisement
Cacks

OpenGL OpenGL ViewPort Matrix

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

@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

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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?

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!