PDA

View Full Version : Help needed(Texture Mapping)



qasim1981
01-05-2005, 04:13 AM
I want to map a bmp file i-e "myimage.bmp" on a rectangular object.kindly gimme any tutorial or code sample. I ll be greatful to you for the favour. :confused:

bentlegen
01-05-2005, 01:59 PM
Gautam converted a bunch of NeHe OpenGL tutorials to OpenGL|ES a few months ago.

Take a look at this thread (http://khronos.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=4&t=000135).

- ben

bentlegen
01-05-2005, 02:03 PM
I should add that those ports use UG and therefore likely only work with the Khronos Linux and Vincent implementations.

You might want to look at regular OpenGL [texture mapping] tutorials. The syntax might be slightly different, but the concepts are the same. Try here (http://nehe.gamedev.net) or here (http://www.gametutorials.com).

- ben

qasim1981
01-05-2005, 09:14 PM
i tried to manipulate one of the tutorials from the redbook "texbind", i did some thing like this ... but still not working. plz solve this segment


:confused:

gautam
01-05-2005, 10:56 PM
It would help if you also say what happens with that piece of code. Except for this it seems ok to me :-




The width and height need to be image width and height, not 2x2 which IMHO is very small.

Also call the following in Display not reshape.




Also sometimes biSizeImage returns 0, that time you have to use width * height * 3 for memory allocation.

But it would help if we have an idea of what exactly is not working and what exactly is happening with this code.

gautam
01-05-2005, 10:58 PM
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>Originally posted by bentlegen:
I should add that those ports use UG and therefore likely only work with the Khronos Linux and Vincent implementations.

You might want to look at regular OpenGL [texture mapping] tutorials. The syntax might be slightly different, but the concepts are the same. Try here (http://nehe.gamedev.net) or here (http://www.gametutorials.com).


- ben<HR></BLOCKQUOTE>

Although they have only been tested on linux using UG implementation the rendering part can be easily copied from that to any other implementation

[ January 06, 2005: Message edited by: gautam ]

qasim1981
01-05-2005, 11:18 PM
this code is trying to map "mybmp" on a triangle. Now its working a little bit. but the problem is that when i give it a plain bmp i-e of one color only, like red, or grey or yellow, it works, but when i give it any multicolored bmp, only its first color is displayed on whole triangle, for e.g if a bmp is divided into yellow and green color of equal size, only 1st color is displayed. how to solve this???

bentlegen
01-06-2005, 04:55 AM
Just a guess, but it's likely that you're not specifying the proper height/width of the texture to glTexImage2D, and that the few colors that are getting through are being clamped throughout the rest of your textured poly.

- ben

qasim1981
01-06-2005, 07:12 AM
I agree with this, but how can i specify the width and height of the image in glTexImage2D() ???i tried by following way but by doing so nothing appears on screen


glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,bitmapInfoHeader.biWidth,
bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,bitmapData);

[ January 06, 2005: Message edited by: qasim1981 ]

flame
01-07-2005, 03:09 AM
Hi. Are the dimensions of the bitmap power-of-two ? OpenGL ES only supports power-of-two textures (256x256, 128x64, ...).

--jani;

[ January 07, 2005: Message edited by: Jani Vaarala ]

qasim1981
01-07-2005, 07:20 AM
Yes, i also tried with power of 2 ,, 2,4,8,16,32,64,128,256, but no use

flame
01-11-2005, 04:14 AM
Hi.

Do you have texture filter modes enabled that require mipmapping? If you do and not all mipmap levels are specified with decreasing power-of-two sizes (see gl spec for "texture completeness"), rendering is done as if texturing was disabled.

--jani;

qasim1981
01-15-2005, 10:50 AM
thankyou guys for all ur support. This code worked 100% as it as, the only problem was with the resolution of bitmap, now its working fine. Thankyou once again . :) :cool: