シェイプの面にマップしたいUIViewがあります。それはすべて機能しますが、iPhone 5の網膜グラフィックスで機能させたいと思います。openGLレイヤーのcontentScaleプロパティを2.0に設定しましたが、それでも結果は少しぼやけています。サイズは適切です。網膜ディスプレイの画像に網膜以外のグラフィックを使用しているように見えます。したがって、私がしなければならない「唯一の」ことは、これが2倍のピクセルでなければならないことをiPhoneに伝えることです。私はDarthMikeが提案した解決策を試しましたが、残念ながら役に立ちませんでした。
ここで、初期化してビューに追加します。
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];
ここでは、ビューをコンテキストにレンダリングし、テクスチャとして追加します
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);