Below is example Shader Java OpenGL coding: Shader Coding: fragShader.glsl #version 430 in vec4 varyingColor; out vec4 color; uniform mat4 mv_matrix; uniform mat4 p_matrix; void main(void) { color = varyingColor; } vertShader.glsl #version 430 layout (location=0) in vec3 position; uniform mat4 mv_matrix; uniform mat4 p_matrix; out vec4 varyingColor; void main(void) { gl_Position = p_matrix * mv_matrix * vec4(position,1.0); varyingColor = vec4(position,1.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5); } Questions : 1. How to make Java OpenGL coding to add sphere 3D shape. Be sure to properly specify the number of vertices in the glDrawArrays() command ? answer with coding (plug & play) 2. How to make Java OpenGL coding from answer No.1, so that the additional 3D shape rotates on its axis (just like the earth’s rotation, but we may choose which axis to rotate on, x, y, or z-axis) ? answer with coding (plug & play)
Below is example Shader Java OpenGL coding:
Shader Coding:
fragShader.glsl
#version 430
in vec4 varyingColor;
out vec4 color;
uniform mat4 mv_matrix;
uniform mat4 p_matrix;
void main(void)
{
color = varyingColor;
}
vertShader.glsl
#version 430
layout (location=0) in vec3 position;
uniform mat4 mv_matrix;
uniform mat4 p_matrix;
out vec4 varyingColor;
void main(void)
{
gl_Position = p_matrix * mv_matrix * vec4(position,1.0);
varyingColor = vec4(position,1.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
}
Questions :
1. How to make Java OpenGL coding to add sphere 3D shape. Be sure to properly specify the number of vertices in the glDrawArrays() command ? answer with coding (plug & play)
2. How to make Java OpenGL coding from answer No.1, so that the additional 3D shape rotates on its axis (just like the earth’s rotation, but we may choose which axis to rotate on, x, y, or z-axis) ? answer with coding (plug & play)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









