Hi All,
I am relatively new to OPENGL and need to accomplish task of resize (say 2 times from original size) cube(3D) once mouse over it. And after mouse is not on the cube it has to back normal size.
Do yu know how to do that ?
Maybe there is some good material to read? like tutorials…
Thanks for your help!
PS
Just moved topic from beginners to here, in advanced group as task does not look like for beginners
That is a beginner opengl question and it should be in beginner topics, but i’ll try to answer regardless:
Modern OpenGL (I cut out a few steps but you get the picture)
- Set up an OpenGL context and window (E.g. GLFW + Glew)
- Generate and bind a VAO
- Generate however many VBOs you want for the cube, bind each, fill with data, set the vertex attribute pointer and enable the vertexattribarray
- Write a shader that takes in the VBO info and a uniform mat4 to transform into the camera viewspace from modelspace. I recommend doing the math with GLM but you can write it yourself… Not recommended. You’ll need to compile the shader and link it.
- draw your cube with glDrawArrays or glDrawElements
- it should appear on screen
- swap buffers
That’s the basics of it
if you use the old opengl FF pipeline, it’s a bit simper but less flexible
- Setup OpenGL context and window
- Setup the glViewport etc. and push() the the model->view matrix
- glBegin(GL_TRIANGLES);
- all the vertices
- glEnd();
6)pop();
- flush(); (You can do without this but if you’re using the FFP you’re not going for speed, are you?)
- swap buffers
the FF pipeline is REALLY SLOW so I recommend you DO NOT USE IT because once you get used to it, it will be a tough transition… but if you’re doing a school project that is due tomorrow this works in a pinch