I have just begun to start working on the texture related part of opengl and C++, and now I am having some issues getting it to work correctly. My goal here is a simple way of importing a bmp file, storing it in the program itself, then use that texture on 3d objects. I was able to put the following together, the problem is that it does work. When I try to run the following I get a invalid conversion from void to gluint, or something like that. I tried a few tricks to fix this but no luck so far. Any ideas how I can finish off this function?
bool ImportBMP(char *filename, int num_list)
if (filename == NULL)
texture_obj[num_list] = LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if (texture_obj[num_list] == NULL)
Now please read the documentation on Win32 LoadImage and OpenGL glTexImage2D functions and tell us what you are doing wrong… if you can’t find the mistake, I suggest you go back to your basic programming classes
Ok I think I have a better understanding of what I need to do here but I don’t have the answer I needed yet. I know that their is a handle for imported images, but I am having issues finding out how to use this handle to correctly a bitmap. Now I know that the last argument in glTexImage2d is incorrect but I don’t know how to fix it.
I did a bit of twicking but still not right. This function crashes the program when run. I believe thats due to the incorrect last argument in glTexImage2d.
bool ImportBMP(char *filename, int num_list, int width, int height)
texture_obj = LoadImage(NULL,filename,IMAGE_BITMAP,width,height,LR_LOADFROMFILE);
Yes it is. LoadImage returns a bitmap handle, while TexImage wants a pointer to texel data. So you have to get the pointer to the bitmap data first. Now, it is at least 8 years I last used GDI, so my memory is a bit rusty, but I guess you have to use GetDIBits function to do this. There should be also an alternative way, by getting memory pointer to the resource directly and loading it yourself, but you’ll have to ask some win32 specialists. At this point, your question is completely OpenGL unrelated, it is a question about how to access bitmap data under win32. Hope I could give you some pointers…