java - LWJGL/OpenGL How do I resize my image in order to fit my sphere? -


i working on project , tried wrap image around shape, sphere. problem image cover of sphere, parts. how can resize image fits whole sphere perfectly?

import java.io.ioexception; import org.lwjgl.*; import org.lwjgl.input.keyboard; import org.lwjgl.opengl.*; import static org.lwjgl.opengl.extframebufferobject.glgeneratemipmapext; import static org.lwjgl.opengl.gl11.*; import static org.lwjgl.util.glu.glu.gluperspective; import org.lwjgl.util.glu.sphere; import org.newdawn.slick.opengl.*; import org.newdawn.slick.util.resourceloader;  private void render() {     glclear(gl_color_buffer_bit | gl_depth_buffer_bit);     glloadidentity();      gltranslatef(0, 0, -8);     glrotatef(rotateangle, 0, 1, 0);     sphere s = new sphere();     s.setnormals(gl_smooth);     s.settextureflag(true);     glenable(gl_texture_2d);     glgeneratemipmapext(gl_texture_2d);     gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear_mipmap_linear);     gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear);     glbindtexture(gl_texture_2d, t.gettextureid());     s.draw(3, 64, 64); } 

your texture should cover whole sphere, based on documentation found lwjgl sphere class. 1 problem in code set texture attributes before binding texture. you'll want move glbindtexture call before glgeneratemipmapext() , gltexparamteri calls.

to control scaling of texture fixed opengl pipeline, can apply transformations texture coordinates setting matrix mode gl_texture. example, make texture larger, try:

glmatrixmode(gl_texture); glloadidentity(); glscalef(0.5f, 0.5f, 0.5f); glmatrixmode(gl_modelview); 

by dividing texture coordinates factor 2, make texture image appear twice large.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -