So, I was using gworlds before in Carbon to import textures to opengl. Unfortunately, when I build a universal application the compiler says the calls I’m using are going to be deprecated. So, I saw the mac pdf reference from another post on the mac opengl board and it had an example of reading in a file with quartz. Anyhow, the example code works fine with one little issue – the textures are all upside down! I had the same problem with my previous code which led to a transform solution:
//this works in the old code…
MatrixRecord matrix;
SetIdentityMatrix (&matrix);
TranslateMatrix ( &matrix, -X2Fix(0.5f * imageWidth), -X2Fix(0.5f * imageHeight));
ScaleMatrix (&matrix, X2Fix(1.0), X2Fix(-1.0), X2Fix (0.0), X2Fix (0.0));
TranslateMatrix ( &matrix, X2Fix(0.5f * imageWidth), X2Fix(0.5f * imageHeight));
err = GraphicsImportSetMatrix(giComp, &matrix);
Quartz has a similiar mechanism but I cant get it to work. I suspect its related to these calls…
CGContextRef myBitmapContext = CGBitmapContextCreate (myData,
width, height, 8,
width4, space,
kCGImageAlphaPremultipliedFirst);
/
CGContextTranslateCTM(myBitmapContext, -width *0.5, -height *0.5 );
CGContextScaleCTM(myBitmapContext, 0, -1);
CGContextRotateCTM(myBitmapContext,M_PI);
CGContextTranslateCTM(myBitmapContext, width 0.5, height0.5 );
*/
CGContextRotateCTM(myBitmapContext,M_PI);
CGContextDrawImage(myBitmapContext, rect, myImageRef);
CGContextRelease(myBitmapContext);
return myImageRef;
Some apple examples just have the 180 degree rotation…does not seem to work for me. Most of the examples are textures and I’m not sure if they realize they are upside down.(?)
Anyhow, the quartz stuff just produces a black texture… Any ideas??