Beauty Salon α-BET (alphabet)

space001
Blender3d Collada dae modeling Use Papervision3d on Progression3 and 4 http://a-bet.secret.jp/#/access
more whaison works.
whaison space
space002
http://whaison.jugem.jp/ https://jp.pinterest.com/whaison/ https://www.instagram.com/whaison/ https://whaison.amebaownd.com/
https://suzuri.jp/whaison
http://whaison.blogspot.com/
http://whaison.tumblr.com/ http://qiita.com/users/whaison http://www.behance.net/whaison https://github.com/whaison/ https://bitbucket.org/whaison http://serato.com/user/whaison http://whaison.hatenablog.jp/

typo memo
http://d.hatena.ne.jp/whaison/


dayNote
http://www.myspace.com/whaison http://ameblo.jp/whaison/ http://blog.crooz.jp/whaison/ http://blog.crooz.jp/whaisoncafe/ http://nenpyo.org/whaison

fulldisk
http://full.shin-gen.jp/
http://whaison.client.jp/
http://www.dclog.jp/whaison/
featured forums.
space004
forum.unity3d.com/

forums.unrealengine.com.

Progression Forum.

FlashDevelop Forum.

Papervision3D Forum.

FlexUserGroup Forum.

SparkProjectForum.





Twitter







Mobile
qrcode
Calendar
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031    
<< December 2019 >>
New Entries
Archives
Categories
Recent comment
  • FlashDevelopでフォント埋め込み
    感謝!! (12/24)
  • cocos2d-x-3.0rc0 ,c++ ,cpp でTexturePacker で 吐き出した、plist と png でパラパラアニメーションのコード例
    whaison (04/17)
  • Blender2.67にbvh(web上に2500個以上ころがってる)入れてそのBoneオブジェクトをUnity4.0のmecanimで使う
    whaison (08/19)
  • Apple Dev Center 「Certificates, Identifiers & Profiles」で Adhoc をつくってXCode4.6.1でArchiveしてipaを書き出し
    whaison (04/30)
  • Flash CS6でプロパティーパネルで物理演算のジャンプの高さを設定できるCitrus Engine
    whaison (03/01)
  • 「Flash以外、例えばKinectとか」ON TOKYO (会場:高田馬場4-11-8 Floor 6階 ) 短縮URL http://bit.ly/dI0Bfx
    uka (03/02)
  • App Store Review Guidelines アップル社のアプリ審査基準ガイドライン和訳 Apple が 開発者を悩ませ ユーザーをハッピーにしたいガイドライン。w
    whaison (01/25)
  • Unity3d では ADOBE JAPAN OSAKIで行われたFITC 2010 TOKYOでは、 「iOS用にパブリッシュするためには、フリー版ではなくて、有料版を買ってください。さらに追加のパッケージである、"iOS Package (for Development)"を買ってください」とのことだった。
    whaison (01/25)
  • enjoy Adidas-Futsal-Park
    whaison (01/16)
  • MacBookAir にFlashPlayer入れたらなった。Mac Flash Player 10.1/10.2でUstream などでカメラが認識されないバグそんなときはUstreamProducer!でもなくiPhoneだと直ぐにライブ配信できた
    whaison (01/14)
simple sintax high lighter2.0
space003
SyntaxHighlighter2.0用 の貼り付けコード作成する!
ブログパーツ-BLOG PARTS.
Profile
Links
Recommend
Admin
無料ブログ作成サービス JUGEM
Seach this site
            
2015.07.18 Saturday
OpenGL でとりあえず。なんかつくってみる。001-iOS 8.1 @ OpenGL ES 3.0ハローワールド
OpenGL でとりあえず。なんかつくってみる。001-iOS 8.1 @ OpenGL ES 3.0ハローワールド




なんかこんなん よく出るよねー


実機でそりゃー


Objective-C  h プロパティ
------------------------------------

//

//  RMViewController.h

//  test

//

//  Created by ramemiso on 2013/09/23.

//  Copyright (c) 2013 ramemiso. All rights reserved.

//

#import <UIKit/UIKit.h>

#import <GLKit/GLKit.h>

@interface RMViewController : GLKViewController

@end

------------------------------------
Objective-C  m  メインコード
-------------------------------------

//

//  RMViewController.m

//  test

//

//  Created by ramemiso on 2013/09/23.

//  Copyright (c) 2013 ramemiso. All rights reserved.

//

#import "RMViewController.h"

#import <OpenGLES/ES3/gl.h>

#import <OpenGLES/ES3/glext.h>

#define BUFFER_OFFSET(i) ((char *)NULL + (i))

// Uniform index.

enum

{

    UNIFORM_MODELVIEWPROJECTION_MATRIX,

    UNIFORM_NORMAL_MATRIX,

    NUM_UNIFORMS

};

GLint uniforms[NUM_UNIFORMS];

enum

{

    ATTRIB_POSITION,

    ATTRIB_NORMAL,

};

GLfloat gCubeVertexData[216] =

{

    // Data layout for each line below is:

    // positionX, positionY, positionZ,     normalX, normalY, normalZ,

    0.5f, -0.5f, -0.5f,        1.0f, 0.0f, 0.0f,

    0.5f, 0.5f, -0.5f,         1.0f, 0.0f, 0.0f,

    0.5f, -0.5f, 0.5f,         1.0f, 0.0f, 0.0f,

    0.5f, -0.5f, 0.5f,         1.0f, 0.0f, 0.0f,

    0.5f, 0.5f, -0.5f,          1.0f, 0.0f, 0.0f,

    0.5f, 0.5f, 0.5f,         1.0f, 0.0f, 0.0f,

    

    0.5f, 0.5f, -0.5f,         0.0f, 1.0f, 0.0f,

    -0.5f, 0.5f, -0.5f,        0.0f, 1.0f, 0.0f,

    0.5f, 0.5f, 0.5f,          0.0f, 1.0f, 0.0f,

    0.5f, 0.5f, 0.5f,          0.0f, 1.0f, 0.0f,

    -0.5f, 0.5f, -0.5f,        0.0f, 1.0f, 0.0f,

    -0.5f, 0.5f, 0.5f,         0.0f, 1.0f, 0.0f,

    

    -0.5f, 0.5f, -0.5f,        -1.0f, 0.0f, 0.0f,

    -0.5f, -0.5f, -0.5f,       -1.0f, 0.0f, 0.0f,

    -0.5f, 0.5f, 0.5f,         -1.0f, 0.0f, 0.0f,

    -0.5f, 0.5f, 0.5f,         -1.0f, 0.0f, 0.0f,

    -0.5f, -0.5f, -0.5f,       -1.0f, 0.0f, 0.0f,

    -0.5f, -0.5f, 0.5f,        -1.0f, 0.0f, 0.0f,

    

    -0.5f, -0.5f, -0.5f,       0.0f, -1.0f, 0.0f,

    0.5f, -0.5f, -0.5f,        0.0f, -1.0f, 0.0f,

    -0.5f, -0.5f, 0.5f,        0.0f, -1.0f, 0.0f,

    -0.5f, -0.5f, 0.5f,        0.0f, -1.0f, 0.0f,

    0.5f, -0.5f, -0.5f,        0.0f, -1.0f, 0.0f,

    0.5f, -0.5f, 0.5f,         0.0f, -1.0f, 0.0f,

    

    0.5f, 0.5f, 0.5f,          0.0f, 0.0f, 1.0f,

    -0.5f, 0.5f, 0.5f,         0.0f, 0.0f, 1.0f,

    0.5f, -0.5f, 0.5f,         0.0f, 0.0f, 1.0f,

    0.5f, -0.5f, 0.5f,         0.0f, 0.0f, 1.0f,

    -0.5f, 0.5f, 0.5f,         0.0f, 0.0f, 1.0f,

    -0.5f, -0.5f, 0.5f,        0.0f, 0.0f, 1.0f,

    

    0.5f, -0.5f, -0.5f,        0.0f, 0.0f, -1.0f,

    -0.5f, -0.5f, -0.5f,       0.0f, 0.0f, -1.0f,

    0.5f, 0.5f, -0.5f,         0.0f, 0.0f, -1.0f,

    0.5f, 0.5f, -0.5f,         0.0f, 0.0f, -1.0f,

    -0.5f, -0.5f, -0.5f,       0.0f, 0.0f, -1.0f,

    -0.5f, 0.5f, -0.5f,        0.0f, 0.0f, -1.0f

};

@interface RMViewController () {

    GLuint _program;

    

    GLKMatrix4 _modelViewProjectionMatrix;

    GLKMatrix3 _normalMatrix;

    float _rotation;

    

    GLuint _vertexArray;

    GLuint _vertexBuffer;

}

@property (strong, nonatomic) EAGLContext *context;

- (void)setupGL;

- (void)tearDownGL;

- (BOOL)loadShaders;

- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file;

- (BOOL)linkProgram:(GLuint)prog;

- (BOOL)validateProgram:(GLuint)prog;

@end

@implementation RMViewController

- (void)viewDidLoad

{

    [super viewDidLoad];

    

    self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];

    if (!self.context) {

        NSLog(@"Failed to create ES context");

    }

    

    GLKView *view = (GLKView *)self.view;

    view.context = self.context;

    view.drawableDepthFormat = GLKViewDrawableDepthFormat24;

    

    [self setupGL];

}

- (void)dealloc

{    

    [self tearDownGL];

    

    if ([EAGLContext currentContext] == self.context) {

        [EAGLContext setCurrentContext:nil];

    }

}

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    if ([self isViewLoaded] && ([[self view] window] == nil)) {

        self.view = nil;

        

        [self tearDownGL];

        

        if ([EAGLContext currentContext] == self.context) {

            [EAGLContext setCurrentContext:nil];

        }

        self.context = nil;

    }

    // Dispose of any resources that can be recreated.

}

- (void)setupGL

{

    [EAGLContext setCurrentContext:self.context];

    

    [self loadShaders];

    

    glEnable(GL_DEPTH_TEST);

    glGenVertexArrays(1, &_vertexArray);

    glBindVertexArray(_vertexArray);

    

    glGenBuffers(1, &_vertexBuffer);

    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);

    glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW);

    

    glEnableVertexAttribArray(ATTRIB_POSITION);

    glVertexAttribPointer(ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0));

    glEnableVertexAttribArray(ATTRIB_NORMAL);

    glVertexAttribPointer(ATTRIB_NORMAL, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12));

    

    glBindVertexArray(0);

}

- (void)tearDownGL

{

    [EAGLContext setCurrentContext:self.context];

    

    glDeleteBuffers(1, &_vertexBuffer);

    glDeleteVertexArrays(1, &_vertexArray);

    

    if (_program) {

        glDeleteProgram(_program);

        _program = 0;

    }

}

#pragma mark - GLKView and GLKViewController delegate methods

- (void)update

{

    float aspect = fabsf(self.view.bounds.size.width / self.view.bounds.size.height);

    GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f);

    

    GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f);

    baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation, 0.0f, 1.0f, 0.0f);

    

    GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f);

    modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f);

    modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);

    

    _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);

    

    _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);

    

    _rotation += self.timeSinceLastUpdate * 0.5f;

}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect

{

    glClearColor(0.65f, 0.65f, 0.65f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    

    glBindVertexArray(_vertexArray);

    

    glUseProgram(_program);

    

    glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, _modelViewProjectionMatrix.m);

    glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, _normalMatrix.m);

    glDrawArrays(GL_TRIANGLES, 0, 36);

}

#pragma mark -  OpenGL ES 2 shader compilation

- (BOOL)loadShaders

{

    GLuint vertShader, fragShader;

    NSString *vertShaderPathname, *fragShaderPathname;

    

    // Create shader program.

    _program = glCreateProgram();

    

    // Create and compile vertex shader.

    vertShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"];

    if (![self compileShader:&vertShader type:GL_VERTEX_SHADER file:vertShaderPathname]) {

        NSLog(@"Failed to compile vertex shader");

        return NO;

    }

    

    // Create and compile fragment shader.

    fragShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"];

    if (![self compileShader:&fragShader type:GL_FRAGMENT_SHADER file:fragShaderPathname]) {

        NSLog(@"Failed to compile fragment shader");

        return NO;

    }

    

    // Attach vertex shader to program.

    glAttachShader(_program, vertShader);

    

    // Attach fragment shader to program.

    glAttachShader(_program, fragShader);

       

    // Link program.

    if (![self linkProgram:_program]) {

        NSLog(@"Failed to link program: %d", _program);

        

        if (vertShader) {

            glDeleteShader(vertShader);

            vertShader = 0;

        }

        if (fragShader) {

            glDeleteShader(fragShader);

            fragShader = 0;

        }

        if (_program) {

            glDeleteProgram(_program);

            _program = 0;

        }

        

        return NO;

    }

    

    // Get uniform locations.

    uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX] = glGetUniformLocation(_program, "modelViewProjectionMatrix");

    uniforms[UNIFORM_NORMAL_MATRIX] = glGetUniformLocation(_program, "normalMatrix");

    

    // Release vertex and fragment shaders.

    if (vertShader) {

        glDetachShader(_program, vertShader);

        glDeleteShader(vertShader);

    }

    if (fragShader) {

        glDetachShader(_program, fragShader);

        glDeleteShader(fragShader);

    }

    

    return YES;

}

- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file

{

    GLint status;

    const GLchar *source;

    

    source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String];

    if (!source) {

        NSLog(@"Failed to load vertex shader");

        return NO;

    }

    

    *shader = glCreateShader(type);

    glShaderSource(*shader, 1, &source, NULL);

    glCompileShader(*shader);

    

#if defined(DEBUG)

    GLint logLength;

    glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);

    if (logLength > 0) {

        GLchar *log = (GLchar *)malloc(logLength);

        glGetShaderInfoLog(*shader, logLength, &logLength, log);

        NSLog(@"Shader compile log:¥n%s", log);

        free(log);

    }

#endif

    

    glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);

    if (status == 0) {

        glDeleteShader(*shader);

        return NO;

    }

    

    return YES;

}

- (BOOL)linkProgram:(GLuint)prog

{

    GLint status;

    glLinkProgram(prog);

    

#if defined(DEBUG)

    GLint logLength;

    glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);

    if (logLength > 0) {

        GLchar *log = (GLchar *)malloc(logLength);

        glGetProgramInfoLog(prog, logLength, &logLength, log);

        NSLog(@"Program link log:¥n%s", log);

        free(log);

    }

#endif

    

    glGetProgramiv(prog, GL_LINK_STATUS, &status);

    if (status == 0) {

        return NO;

    }

    

    return YES;

}

- (BOOL)validateProgram:(GLuint)prog

{

    GLint logLength, status;

    

    glValidateProgram(prog);

    glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);

    if (logLength > 0) {

        GLchar *log = (GLchar *)malloc(logLength);

        glGetProgramInfoLog(prog, logLength, &logLength, log);

        NSLog(@"Program validate log:¥n%s", log);

        free(log);

    }

    

    glGetProgramiv(prog, GL_VALIDATE_STATUS, &status);

    if (status == 0) {

        return NO;

    }

    

    return YES;

}

@end

-------------------------------------


参考
http://ramemiso.hateblo.jp/entry/2013/09/23/175127
| whaison | OpenGL,OpenGLES,glsl,DirectX,hlsl,webGL,metal,vulkan | 19:22 | comments(0) | - | pookmark |
Comment




whaisonStudyNoteBook をFaceBookで いいね!





Share |