who can give me an example of OpenGL_ES with Texture ??? | developer.brewmp.com who can give me an example of OpenGL_ES with Texture ??? | developer.brewmp.com

Developer

who can give me an example of OpenGL_ES with Texture ???

Forums:

an example of OpenGL_ES with Texture please,thanks

and who can tell me which phone support opengl_es ???

and who can tell me which phone support opengl_es ???

Ok everything you need to know about creating a texture in opengl es. One go read a basic opengl tutorial on texture mapping. Two read my stupid code here to figure out all the brew stuff.
Things to note.
1. Image->getDataStream is just the raw file loaded into ram.
2. Red and blue are swapped for some dumb reason. Thus SwapRedBlue();
3. GL_PALETTE8_RGBA8_OES seems to work for me for 8 bit textures.
4. Note how I calculate iSize.
5. Note the ptr math on the data ptr.
//code//
m_pTexture = new Image( l, pTexName );
SwapRedBlue( ); // stupid opengl
glGenTextures( 1, &m_iTexID );
glBindTexture(GL_TEXTURE_2D, m_iTexID );
glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
int iSize = m_pTexture->getWidth() * m_pTexture->getHeight() + 1024;
glCompressedTexImage2D( GL_TEXTURE_2D, 0, GL_PALETTE8_RGBA8_OES, m_pTexture->getWidth(), m_pTexture->getHeight(), 0, iSize, m_pTexture->getDataStream() + BMP_HEADER_SIZE - 1024 );
int iError = eglGetError();
//end code//
Hope this helps.

Ok everything you need to know about creating a texture in opengl es. One go read a basic opengl tutorial on texture mapping. Two read my stupid code here to figure out all the brew stuff.
Things to note.
1. Image->getDataStream is just the raw file loaded into ram.
2. Red and blue are swapped for some dumb reason. Thus SwapRedBlue();
3. GL_PALETTE8_RGBA8_OES seems to work for me for 8 bit textures.
4. Note how I calculate iSize.
5. Note the ptr math on the data ptr.
//code//
m_pTexture = new Image( l, pTexName );
SwapRedBlue( ); // stupid opengl
glGenTextures( 1, &m_iTexID );
glBindTexture(GL_TEXTURE_2D, m_iTexID );
glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
int iSize = m_pTexture->getWidth() * m_pTexture->getHeight() + 1024;
glCompressedTexImage2D( GL_TEXTURE_2D, 0, GL_PALETTE8_RGBA8_OES, m_pTexture->getWidth(), m_pTexture->getHeight(), 0, iSize, m_pTexture->getDataStream() + BMP_HEADER_SIZE - 1024 );
int iError = eglGetError();
//end code//
Hope this helps.

No BREW handset currently supports OpenGL ES

No BREW handset currently supports OpenGL ES

Hi Gareth,
What type of data is m_pTexture?
I cant find any thing like getDataStream() on BREW API.
Is there a way to load an image and get the image raw bytes using BREW API?
I know that I can use ISHELL_LoadImage to load an image and use the IImage interface to handle it, but IImage does not give me the raw bytes that I need to create the GL Texture. Or it does but I don’t see how?
Or, it’s necessary to create a function to load the image from a file using pure C++?
Thanks

Hi Gareth,
What type of data is m_pTexture?
I cant find any thing like getDataStream() on BREW API.
Is there a way to load an image and get the image raw bytes using BREW API?
I know that I can use ISHELL_LoadImage to load an image and use the IImage interface to handle it, but IImage does not give me the raw bytes that I need to create the GL Texture. Or it does but I don’t see how?
Or, it’s necessary to create a function to load the image from a file using pure C++?
Thanks

m_pTexture is of type Image.
Image is not part of brew but a class used to provide additional functionality.
For this case all I use it for is loading the image and pulling the width and height out of the bmp header.
Just for testing you could be less abstract and do the following.
#define FILESIZE 500 // the actual size of file
#define WIDTH 15 // image widht
#define HEIGHT 15 // image height
byte *pData = new byte[FILESIZE ];
IFILE_Read( filemnr, pData, FILESIZE );
so now you have raw data pnter and know the width and height of image. Just replace all the m_pTexture stuff with something like that. Hope this makes more sense.

m_pTexture is of type Image.
Image is not part of brew but a class used to provide additional functionality.
For this case all I use it for is loading the image and pulling the width and height out of the bmp header.
Just for testing you could be less abstract and do the following.
#define FILESIZE 500 // the actual size of file
#define WIDTH 15 // image widht
#define HEIGHT 15 // image height
byte *pData = new byte[FILESIZE ];
IFILE_Read( filemnr, pData, FILESIZE );
so now you have raw data pnter and know the width and height of image. Just replace all the m_pTexture stuff with something like that. Hope this makes more sense.

Anyone has the sample code on how to swap blue and red?
Thanks!

Anyone has the sample code on how to swap blue and red?
Thanks!