2 Problems...
Hello,
currently my engine faces two major problems.
1) Window management
2) Texture loading (well.. images)
Should I use a ready window manager (like glut or wxWindow i dont know the name) or make my own (like Im using now)?
Secondly, I am using DevIL to load my images and manually convert them to textures. The problem is that it doesnt load the textures correctly and it supports (as far BMP is concerned) only 24bit BMPs.. Does anyone have a DevIL tutorial or sample application, maybe Im not doing somehting correct. Any other libraries for image loading available?
Thanks
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Re: Window management - it depends what you''re trying to do. For games, or apps that require only a GL display, you could try GLUT. If you want a more complex display, eg, splitter panes w/ controls, alongside GL views, something like VC++ is probably more appropriate.
For image loading, try the gle32 library, at www.mathviewer.com/gle32v2home.asp.
For image loading, try the gle32 library, at www.mathviewer.com/gle32v2home.asp.
Thank you for your responce!
I am making an engine that is aimed for 3d games, not tools. So I guess that one window per application is cool. Do you think it would be a good idea not to make a window class, but create the window manually from the client app? (my engine is a win32 dll) So that everyone is happy.. Its a dillema cause I will need to change lots of code in my engine
Thanks for the lib though!
I am making an engine that is aimed for 3d games, not tools. So I guess that one window per application is cool. Do you think it would be a good idea not to make a window class, but create the window manually from the client app? (my engine is a win32 dll) So that everyone is happy.. Its a dillema cause I will need to change lots of code in my engine
Thanks for the lib though!
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
I created a function that loads BMPs (8 bpp, uncompressed), and it works quite well.
You might want to try it:
You might want to try it:
//load a bmp texture, with the specified global alphaGLuint load_bmp8_fixed_alpha(char * FileName, Uint8 a){ int i,x,y,x_padding,x_size,y_size,colors_no,r,g,b,current_pallete_entry; Uint8 * file_mem; Uint8 * file_mem_start; Uint8 * texture_mem; Uint8 * read_buffer; Uint8 * color_pallete; FILE *f = NULL; int file_lenght; GLuint texture; f = fopen (FileName, "rb"); if (!f) return; file_mem = (Uint8 *) calloc ( 20000, sizeof(Uint8)); file_mem_start=file_mem; fread (file_mem, 1, 50, f);//header only //now, check to see if our bmp file is indeed a bmp file, and if it is 8 bits, uncompressed if(*((short *) file_mem)!=19778)//BM (the identifier) { free(file_mem_start); fclose (f); return -1; } file_mem+=18; x_size=*((int *) file_mem); file_mem+=4; y_size=*((int *) file_mem); file_mem+=6; if(*((short *)file_mem)!=8)//8 bit/pixel? { free(file_mem_start); fclose (f); return -1; } file_mem+=2; if(*((int *)file_mem)!=0)//any compression? { free(file_mem_start); fclose (f); return -1; } file_mem+=16; colors_no=*((int *)file_mem); if(!colors_no)colors_no=256; file_mem+=8;//here comes the pallete color_pallete=file_mem+4; fread (file_mem, 1, colors_no*4+4, f);//header only file_mem+=colors_no*4; x_padding=x_size%4; if(x_padding)x_padding=4-x_padding; //now, allocate the memory for the file texture_mem = (Uint8 *) calloc ( x_size*y_size*4, sizeof(Uint8)); read_buffer = (Uint8 *) calloc ( 2000, sizeof(Uint8)); for(y=0;y { //fread (texture_mem+y*x_size, 1, x_size-x_padding, f); fread (read_buffer, 1, x_size-x_padding, f); for(x=0;x { current_pallete_entry=*(read_buffer+x); b=*(color_pallete+current_pallete_entry*4); g=*(color_pallete+current_pallete_entry*4+1); r=*(color_pallete+current_pallete_entry*4+2); *(texture_mem+(y*x_size+x)*4)=r; *(texture_mem+(y*x_size+x)*4+1)=g; *(texture_mem+(y*x_size+x)*4+2)=b; *(texture_mem+(y*x_size+x)*4+3)=a; } } free(file_mem_start); free(read_buffer); fclose (f);//ok, now, hopefully, the file is loaded and converted...//so, assign the texture, and such glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); 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_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x_size, y_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_mem); free(texture_mem); return texture;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement