qt - SDL OpenGL Texture display issue -


i'm following this tutorial in order load opengl texture sdl_surface, i've copy/paste code , adapted display wrong old part of buffer little bit annoying... cause can't figure what's wrong. work qt5 on mac os x. here's code

gluint texture;         // handle our texture object sdl_surface *surface;   // surface tell details of image glenum texture_format; glint  nofcolors; surface = img_load("/brique.png");  if ( surface ) {      // number of channels in sdl surface     nofcolors = surface->format->bytesperpixel;     if (nofcolors == 4)     // contains alpha channel     {         if (surface->format->rmask == 0x000000ff)             texture_format = gl_rgba;         else             texture_format = gl_bgra;     } else if (nofcolors == 3)     // no alpha channel     {         if (surface->format->rmask == 0x000000ff)             texture_format = gl_rgb;         else             texture_format = gl_bgr;     } else {         printf("warning: image not truecolor..  break\n");         // error should not go unhandled     }      glenable( gl_texture_2d );     // have opengl generate texture object handle     glgentextures( 1, &texture );      // bind texture object     glbindtexture( gl_texture_2d, texture );      // set texture's stretching properties     gltexparameteri( gl_texture_2d, gl_texture_min_filter, gl_linear );     gltexparameteri( gl_texture_2d, gl_texture_mag_filter, gl_linear );      // edit texture object's image data using information sdl_surface gives     glteximage2d( gl_texture_2d, 0, nofcolors, surface->w, surface->h, 0, texture_format, gl_unsigned_byte, surface->pixels ); } else {     printf("sdl not load image.bmp: %s\n", sdl_geterror());     sdl_quit();     exit (1); }  // free sdl_surface if created if ( surface ) {     sdl_freesurface( surface ); } 

and here's result : bad display

and here's debug function glteximage2d debug session

you or did not declare (this flips screen buffer)

sdl_gl_swapbuffers(); 

doing putting on last part of loop:

qglclearcolor(qtpurple.dark());  /**************************************** ... ogl initialization code here ... ****************************************/  while (!done) {    glclear(gl_color_buffer_bit | gl_depth_buffer_bit);     /***********************************    ... ogl rendering code here ...    ***********************************/     sdl_gl_swapbuffers(); } 

check tutorial on qt5 ogl:


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -