seuqram Posted April 13, 2015 at 03:12 PM Report Share #581140 Posted April 13, 2015 at 03:12 PM (edited) Bom dia, já a algum tempo que ando por volta deste assunto e esta semana resolvi pesquisar um pouco acerca de bibliotecas que façam load de texturas compativel com c++/opengl glut. Algumas despertaram-me a atenção, a biblioteca SOIL e a freeimage. Pelo que vi, a segunda é mais recente mas têm menos conteúdo na internet. Já que não tenho nenhuma experiência com esse tipo de bibliotecas resolvi fazer este tópico. Qual a que me aconselham a usar? Será uma mais simples e mais bem estruturada do que outra? Obrigado. Edited April 13, 2015 at 05:31 PM by seuqram Link to comment Share on other sites More sharing options...
seuqram Posted April 13, 2015 at 03:13 PM Author Report Share #581141 Posted April 13, 2015 at 03:13 PM (edited) Bom dia, já a algum tempo que ando por volta deste assunto e esta semana resolvi pesquisar um pouco acerca de bibliotecas que façam load de texturas compativel com c++/opengl glut. Algumas despertaram-me a atenção, a biblioteca SOIL e a freeimage. Pelo que vi, a segunda é mais recente mas têm menos conteúdo na internet. Já que não tenho nenhuma experiência com esse tipo de bibliotecas resolvi fazer este tópico. Qual a que me aconselham a usar? Será uma mais simples e mais bem estruturada do que outra? Obrigado. Edited April 13, 2015 at 03:13 PM by seuqram Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted April 13, 2015 at 03:20 PM Report Share #581144 Posted April 13, 2015 at 03:20 PM nenhuma ... aprende a fazer "à mão" por duas razões - ficas a saber o que se passa/como se faz - é super simples enviar uma imagem para a memória de vídeo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
seuqram Posted April 13, 2015 at 05:58 PM Author Report Share #581154 Posted April 13, 2015 at 05:58 PM (edited) Eu já tentei a alguns dias e não deu certo... GLuint LoadTexture(const char*filename,int width,int height) { GLuint texture; unsigned char * data; FILE * file; file = fopen( filename, "rb" ); if ( file == NULL ) return 0; data = (unsigned char *)malloc( width * height * 3 ); //int size = fseek(file,); fread( data, width * height * 3, 1, file ); fclose( file ); for(int i = 0; i < width * height ; ++i) { int index = i*3; unsigned char B,R; B = data[index]; R = data[index+2]; data[index] = R; data[index+2] = B; } glGenTextures( 1, &texture ); glBindTexture( GL_TEXTURE_2D, texture ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT ); gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height,GL_RGB, GL_UNSIGNED_BYTE, data ); free( data ); return texture; } Apliquei o GLuint texture= LoadTexture( "your.bmp",910,683); glEnable(GL_TEXTURE_2D); e depois antes da respetiva face: glColor3f( 1.0, 1.0, 1.0 ); glBindTexture (GL_TEXTURE_2D, texture); glBegin(GL_QUADS); glVertex2f(0,0); glTexCoord2f (0, 0); glVertex2f(0,1); glTexCoord2f (0, 1); glVertex2f(1,1); glTexCoord2f (1, 1); glVertex2f(1,0); glTexCoord2f (1, 0); será que está a faltar algo ou tenho alguma coisa errada na função de fazer load? http://postimg.org/image/acrqfv1rr/ Edited April 14, 2015 at 12:54 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted April 13, 2015 at 06:33 PM Report Share #581159 Posted April 13, 2015 at 06:33 PM não podes ler um ficheiro e assumir que os dados que estão lá estão direitihnos como pensas ... mesmo os ficheiros bmp possuem um cabeçalho que não interessa a não ser para determinar como ler os dados contidos no ficheiro. deverias, ai sim, usar alguma biblioteca de funções para leitura das imagens dos ficheiros e só depois enviar a imagem para a placa gráfica IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
seuqram Posted April 13, 2015 at 06:41 PM Author Report Share #581160 Posted April 13, 2015 at 06:41 PM Então devo ultilizar uma das bibliotecas que mencionei anteriormente? Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted April 13, 2015 at 07:14 PM Report Share #581165 Posted April 13, 2015 at 07:14 PM não o que disse era para usares coisas como : https://code.google.com/p/libbmp/ para ler um ficheiro BMP para outro tipo de ficheiro terás de usar uma biblioteca adequada para interpretar o ficheiro 1 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
seuqram Posted April 13, 2015 at 08:23 PM Author Report Share #581168 Posted April 13, 2015 at 08:23 PM Muito obrigado. Depois disso pode se meter diretamente a variável de tipo bmpfile_t no bindtexture ou têm de se fazer "fread" para a de tipo GLuint? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now