c++ - Mapping a texture with OpenGL using SOIL -


trying complete basic texture map surface using opengl , soil not generating anything.

gluint textureid[5];  glutinitwindowposition(0, 50); windowid[0] = glutcreatewindow("orthogonal projection, cubes");  glmatrixmode(gl_projection); glloadidentity(); glortho(-400, 400, -400, 400, -500, 500);  glmatrixmode(gl_modelview); glloadidentity();  glutkeyboardfunc(keyboard); glutdisplayfunc(drawwindowone);  textureid[0] = soil_load_ogl_texture("assets/facea.png",                soil_load_auto, soil_create_new_id, soil_flag_invert_y);  void drawwindowone() {     glclearcolor(0.0, 0.0, 0.0, 0.0);        glclear(gl_color_buffer_bit);         glviewport(0, 0, 250, 250);       glmatrixmode(gl_modelview);       gltexenvf(gl_texture_env, gl_texture_env_mode, gl_replace);       gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_repeat);     gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_repeat);     gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest);     gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest);      glenable(gl_texture_2d);      glbindtexture(gl_texture_2d, textureid[0]);      glbegin(gl_quads);     glnormal3f(0.0, 0.0, 1.0); // front face     gltexcoord2f(0.0, 0.0);     glvertex3f(-a,-a, a);     gltexcoord2f(0.0, 1.0);     glvertex3f(-a, a, a);     gltexcoord2f(1.0, 1.0);     glvertex3f( a, a, a);     gltexcoord2f(1.0, 0.0);     glvertex3f( a,-a, a);     glend();      gldisable(gl_texture_2d); } 

the face draws in blue, however, , no texture. have second window, apart position differance using frustrum opposed orthogonal

windowid[1] = glutcreatewindow("perspective projection using glfrustum");  glmatrixmode(gl_projection); glloadidentity(); glfrustum(-60, 60, -60, 60, 60, 200); glulookat(0, 0, 120, 0, 0, 0, 0, 1, 0); 

and texture draws fine.

the problem was loading textures @ once, appears need loaded after each window initialized available windows draw code.

#pragma region initialise window 1 glutinitwindowposition(0, 50); windowid[1] = glutcreatewindow("orthogonal projection, cubes"); glmatrixmode(gl_projection); glloadidentity(); glortho(-400, 400, -400, 400, -500, 500);  glmatrixmode(gl_modelview); glloadidentity();  glutkeyboardfunc(keyboard); glutdisplayfunc(drawwindowone); loadtextures(); #pragma endregion  #pragma region initialise window 2 glutinitwindowposition(0, 450); windowid[1] = glutcreatewindow("perspective projection using glfrustum, ellipsoids");  glmatrixmode(gl_projection); glloadidentity(); glfrustum(-60, 60, -60, 60, 60, 200); glulookat(0, 0, 120, 0, 0, 0, 0, 1, 0);  glmatrixmode(gl_modelview); glloadidentity();  glutkeyboardfunc(keyboard); glutdisplayfunc(drawwindowtwo); loadtextures(); #pragma endregion 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -