Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vorel512

Member Since 02 Jan 2012
Offline Last Active Aug 30 2012 06:42 AM

Posts I've Made

In Topic: Create textures from text OpenGL ES 2.0 / GLKit

14 August 2012 - 01:54 AM

Resolved! The problem was, that the frame size should be power of two.
Please mark this topic "Resolved"!

In Topic: Rendering text iPhone

14 August 2012 - 01:53 AM

The problem was, that the frame size has to be power of two.
Please mark this topic "Resolved".

In Topic: GLSL normals problem?

27 July 2012 - 02:34 AM

Hi you have to rotate the normal like:
[source lang="cpp"]mat4 rotate_x(float theta){ return mat4( 1.0, 0.0, 0.0, 0.0, 0.0, cos(theta), sin(theta), 0.0, 0.0, -sin(theta), cos(theta), 0.0, 0.0, 0.0, 0.0, 1.0 );}void main(){........mat4 tRotation = rotate_x(originalRotation.x);vec4 newTranslation = vec4(tRotation * PositionFromAttributes);vec3 eyeNormal = NormalMatrix3x3 * vec3(newTranslation) * NormalFromAttributes;........}[/source]

In Topic: Create textures from text OpenGL ES 2.0 / GLKit

27 July 2012 - 12:25 AM

I've made a new function just for text rendering, but the picture is black anyway. I've tried to change the color values in the label, but still black output.

[source lang="cpp"]- (GLuint)setupTextTexture:(NSString *)text { //0 CGPoint position = CGPointMake(0,0); // Make a UILabel with the string UIFont *font = [UIFont fontWithName:@"Georgia" size:12]; CGSize size = [text sizeWithFont:font forWidth:12 lineBreakMode:UILineBreakModeClip]; CGRect frame; frame.origin = position; frame.size = size; UILabel *label = [[UILabel alloc]initWithFrame:frame]; label.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; label.text = text; label.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; label.font = font; // Make a UIImage with the UILabel UIGraphicsBeginImageContext(label.frame.size); [[label layer] renderInContext:UIGraphicsGetCurrentContext()]; UIImage *layerImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // 1 CGImageRef spriteImage = layerImage.CGImage; if (!spriteImage) { NSLog(@"Failed to setup text image %@", text); exit(1); } // 2 size_t width = CGImageGetWidth(spriteImage); size_t height = CGImageGetHeight(spriteImage); GLubyte * spriteData = (GLubyte *) calloc(width*height*4, sizeof(GLubyte)); CGContextRef spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width*4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast); // 3 CGContextDrawImage(spriteContext, CGRectMake(0, 0, width, height), spriteImage); CGContextRelease(spriteContext); // 4 GLuint texName; glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData); free(spriteData); return texName; }[/source]

In Topic: GLSL multitexturing

24 July 2012 - 07:08 AM

Okay, I missed '1' at the second glUniform1i(_textureUniform1, 0);
I've set the mix to the second pictures alpha channel, and now it looks much more proper. But some pixels has alpha 1... I do not know why, because the background image has alpha 255 everywhere.

PARTNERS