I have a UIView that I would like to map onto a face of my shape. All that works but I would like it to work with retina graphics on iPhone 5. I set my openGL layer's contentScale property to 2.0 but nevertheless, the result is slightly blurry. So the size is right, it just seems as if I were using non-retina graphics for an image on the retina display. So the 'only' thing I have to do is to tell the iPhone that this has to be double the pixels. I tried the solution DarthMike suggested, unfortunately to no avail.
Here I initialize and add it to my view:
MyOpenGLView *view = [[MyOpenGLView alloc] initWithFrame:CGRectMake(0, dY, 230,230) context:context];
view.contentScaleFactor = 2.0;
view.layer.contentsScale = 2.0;
view.delegate = view;
view.drawableDepthFormat = GLKViewDrawableDepthFormat16;
[view setupGL];
[self.view addSubview:view];
Here I render the view into a context and add it as a texture
MyViewToBeTheTexture *textureView = [[MyViewToBeTheTexture alloc]initWithFrame:CGRectMake(0, 0, 230, 230)];
self.effect.texture2d0.enabled = true;
// make space for an RGBA image of the view
GLubyte *pixelBuffer = (GLubyte *)malloc(
4 *
textureView.bounds.size.width *
textureView.bounds.size.height);
// create a suitable CoreGraphics context
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context =
CGBitmapContextCreate(pixelBuffer,
textureView.bounds.size.width, textureView.bounds.size.height,
8, 4*textureView.bounds.size.width,
colourSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colourSpace);
// draw the view to the buffer
[textureView.layer renderInContext:context];
// upload to OpenGL
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA,
textureView.bounds.size.width, textureView.bounds.size.height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, pixelBuffer);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glGenBuffers(1, &texArray);
glBindBuffer(GL_ARRAY_BUFFER, texArray);
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0,0);
glBufferData(GL_ARRAY_BUFFER, sizeof(TexCoords), TexCoords, GL_STATIC_DRAW);
SOLUTION FOUND !
Please take a look at this question: