I've been reading up on this push/pop matrix stuff. I kinda don't understand it but do I need to? If I'm making a 2D game, does pushing or popping any matrices have any sort of benefit, like speed or simplicity or something? If it's not, then I'll stop reading about it (for now) :p

Er, unless I'm wrong (Correct me people if I am!) Pushing/Popping matrix is to control it's state when you're doing operations. When you push, it saves the current state, allowing you to mess around with it. When you pop, it returns it to the state it was in when you last popped.

For a 2D game? It depends on how you're doing it. I mean, it might be easier to use a library/framework that would obscure all of that from you (LibGDX and Slick2D come to mind). If you're dead set on doing it on your own by setting up your own orthographic camera, writing out little square meshes and then texturing them, then yes it can be useful. All depends on what you're doing. :3

Er, unless I'm wrong (Correct me people if I am!) Pushing/Popping matrix is to control it's state when you're doing operations. When you push, it saves the current state, allowing you to mess around with it. When you pop, it returns it to the state it was in when you last popped.

For a 2D game? It depends on how you're doing it. I mean, it might be easier to use a library/framework that would obscure all of that from you (LibGDX and Slick2D come to mind). If you're dead set on doing it on your own by setting up your own orthographic camera, writing out little square meshes and then texturing them, then yes it can be useful. All depends on what you're doing. :3

Almost all of what I'm doing is just drawing quads. (OpenGL/LWJGL)Sometimes I change draw color of sprites for certain effects, but I always have to set the draw color back to white at the end. If I used push/pop matrix, would I need this constant resetting?

Think about like 'tiling' where you'd iterate through a large list of things and need to change the position and other things each time. You can push at the start of the operation, translate, push, paint the tile, pop, translate, push paint the tile, pop... And on and on. Then finally pop when you're done with the operation.

Then you can do whatever else you need to (Like paint the UI, etc) without having to worry about whether you'd remembered to reset the position back to the origin.

Er, unless I'm wrong (Correct me people if I am!) Pushing/Popping matrix is to control it's state when you're doing operations. When you push, it saves the current state, allowing you to mess around with it. When you pop, it returns it to the state it was in when you last popped.

For a 2D game? It depends on how you're doing it. I mean, it might be easier to use a library/framework that would obscure all of that from you (LibGDX and Slick2D come to mind). If you're dead set on doing it on your own by setting up your own orthographic camera, writing out little square meshes and then texturing them, then yes it can be useful. All depends on what you're doing. :3

Almost all of what I'm doing is just drawing quads. (OpenGL/LWJGL)Sometimes I change draw color of sprites for certain effects, but I always have to set the draw color back to white at the end. If I used push/pop matrix, would I need this constant resetting?

Think about like 'tiling' where you'd iterate through a large list of things and need to change the position and other things each time. You can push at the start of the operation, translate, push, paint the tile, pop, translate, push paint the tile, pop... And on and on. Then finally pop when you're done with the operation.

Then you can do whatever else you need to (Like paint the UI, etc) without having to worry about whether you'd remembered to reset the position back to the origin.

Though, for what you describe about the Color things. For color stacking you need other calls than "glPushMatrix()" and "glPopMatrix()". For that you need "glPushAttrib(GL_COLOR_BUFFER_BIT)" and "glPopAttrib()".

Eclipse isn't recognizing the methods, and it's not suggesting any imports

Whenever I see someone refer to their IDE this way, it sort of raises a red flag to me that you're letting your IDE think for you rather than learning the actual language.

I'll give a hint: These methods are static methods on the GL11 class, and you need to statically import them if you want to refer to them without the prefix. If you did import them, then you've likely passed them the wrong argument types (and you should normally be getting a different error in that case)

when using OpenGL, use floats, not ints. By using ints you are forcing an int -> float conversion every time you call a gl function like glColor3i. If you just stick with floats, this conversion doesn't have to happen.

Eclipse isn't recognizing the methods, and it's not suggesting any imports

Whenever I see someone refer to their IDE this way, it sort of raises a red flag to me that you're letting your IDE think for you rather than learning the actual language.

I'll give a hint: These methods are static methods on the GL11 class, and you need to statically import them if you want to refer to them without the prefix. If you did import them, then you've likely passed them the wrong argument types (and you should normally be getting a different error in that case)

Haha yeah, I basically am learning by hopping from tutorial to tutorial and I accrue a lot of shameful gaps in my knowledge that way, and I was having a hard time figuring out how to search for the answers here.

Having said that, I was able to find out what to do with your hint. Once I statically imported GL11 all the squiggly red lines disappeared and my program ran.

However, I've just gotten stuck again because no rectangle is being drawn. There's something I'm still doing wrong

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org