|
2010-07-06
, 22:17
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#2
|
The Following User Says Thank You to Joorin For This Useful Post: | ||
|
2010-07-07
, 07:59
|
Posts: 317 |
Thanked: 787 times |
Joined on Oct 2009
@ Krakow, Poland
|
#3
|
|
2010-07-07
, 08:18
|
Posts: 3,617 |
Thanked: 2,412 times |
Joined on Nov 2009
@ Cambridge, UK
|
#4
|
|
2010-07-07
, 08:20
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#5
|
|
2010-07-07
, 11:33
|
Posts: 8 |
Thanked: 2 times |
Joined on Jun 2009
|
#7
|
|
2010-07-07
, 11:40
|
|
Posts: 186 |
Thanked: 192 times |
Joined on Jan 2010
@ Finland
|
#8
|
The Following User Says Thank You to juise- For This Useful Post: | ||
|
2010-07-07
, 12:07
|
Posts: 3 |
Thanked: 1 time |
Joined on Feb 2010
|
#9
|
int i, j; GLubyte* pixels8888 = surfaceRGBA->pixels; GLushort * pixels4444 = malloc(sizeof(GLushort) * surfaceRGBA -> w * surfaceRGBA -> h); for (i = 0; i < surfaceRGBA -> w * surfaceRGBA -> h; i++) { j = i << 2; pixels4444[i] = (pixels8888[j+3] >> 4) + ((pixels8888[j+2] >> 4) << 4) + ((pixels8888[j+1] >> 4) << 8) + ((pixels8888[j] >> 4) << 12); } // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surfaceRGBA->w, surfaceRGBA->h, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels4444); free(pixels4444);
The Following User Says Thank You to manu_dibango For This Useful Post: | ||
|
2010-07-07
, 14:48
|
Posts: 317 |
Thanked: 787 times |
Joined on Oct 2009
@ Krakow, Poland
|
#10
|
It seems that the buffer is given as parameter to glTexImage2D(). Check the documentation to see exactly what that function does to the buffer.
Does the free() work if you comment out the call to glTexImage2D()?
Does it work if you place it immediately after malloc()?
Thanks in advance.
Resolution:
The error in the code snippet above is that pixels4444 should not be freed right after calling glTexImage2D because pixels4444 can be used by OpenGL later. According to this:
Last edited by dwaradzyn; 2010-07-11 at 13:16. Reason: Resolution