首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏大壮

    OpenGL ES 使用着色器(OC)(一)

    几乎每行代码都会增加注释 1.OpenGL ES 3.0环境 在iOS需要先引用 <OpenGLES/ES2/gl.h> <GLKit/GLKit.h> 上屏 上屏部分需要使用GLKView,CAEAGLLayer 其中GLKView初始化: - (GLKView *)glkView { if (_glkView == nil) { _glkView = [[GLKView alloc] init]; _glkView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width ); _glkView.backgroundColor = [UIColor clearColor]; } return _glkView; } 其中CAEAGLLayer * scale, self.glkView.frame.origin.y * scale, self.glkView.frame.size.width

    85920发布于 2020-06-29
  • 来自专栏Code_iOS

    OpenGL ES 2.0 Making the Hardware Work for You

    view --> GLKView 核心代码: ? *view = (GLKView *)self.view; NSAssert([view isKindOfClass:[GLKView class]], @"View controller's view is not a GLKView"); // Create an OpenGL ES 2.0 context and provide it to the // view :(GLKView *)view drawInRect:(CGRect)rect { [self.baseEffect prepareToDraw]; // Clear Frame 绘制的方法是,- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect 这个方法是 GLKView 的代理方法; Dash 中查看代理方法: ?

    96220发布于 2018-09-04
  • 来自专栏音视频直播技术专家

    iOS下 WebRTC 视频渲染

    GLKView的好处是,开发人员可以将自己的精力聚焦在OpenGL ES渲染的工作上。 GLKView展示的基本流程如下: ? 使用GLKView有两种方法,一种是实现一个类,直接继承自GLKView,并实现drawRect方法。 首先,创建GLKView. // GLKView manages a framebuffer for us. //创建GLKView,在创建时,就将 EAGLContext 设置好。 = GLKViewDrawableMultisampleNone; //设置GLKView的delegate _glkView.delegate = self; _glkView.layer.masksToBounds ]; 创建好GLKView后,需要将glkView.delegate设置为RTCEAGLVideoView,这样就可以将绘制工作交由RTCEAGLVideoView来完成了。

    2.6K30发布于 2020-04-02
  • 来自专栏小黑娃Henry

    OpenGLES(三)- GLKit: 多边形纹理、旋转OpenGLES(三)- GLKit: 多边形纹理、旋转

    上下文创建 不同于上文中的GLKView的创建方式。使用这种initWithFrame方式可以不用依赖GLKViewController。 content){return;} [EAGLContext setCurrentContext:content]; //GLKView创建 glkView = [[GLKView = self; self.view = glkView; glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888 ; glkView.drawableDepthFormat = GLKViewDrawableDepthFormat24; glClearColor(0.3, 0.1, 0.7, 1.0f 代理 - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT

    1K50发布于 2021-08-09
  • 来自专栏iOSer成长记录

    OpenGL ES(二) 三角形

    因为苹果公司给我们封装了工具类GLKBaseEffect,下面是一个简单的绘制三角形的例子: -(void)setupGL{ // 创建设备上下文,用OpenGL ES 2.0的API GLKView *view = (GLKView *)self.view; view.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 ]; // GLKView的深度缓存 view.drawableDepthFormat = GLKViewDrawableDepthFormat24; [EAGLContext :(GLKView *)view drawInRect:(CGRect)rect { // 清除颜色(设置背景颜色) glClearColor(0xeb/255.f, 0xf5/255. *view = (GLKView *)self.view; [EAGLContext setCurrentContext:view.context]; if (0 !

    75730发布于 2018-06-29
  • 来自专栏APP自动化测试

    iOS给图片添加滤镜&使用openGLES动态渲染图片

    imageView]; openGLES 下面来介绍怎么用openGLES来使用滤镜渲染图片 使用openGlES的步骤大致如下: #1.导入要渲染的图片 #2.获取OpenGLES渲染的上下文 #3.创建出渲染的GLKView [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; 7 8 //创建出渲染的buffer 9 GLKView *glkView = [[GLKView alloc] initWithFrame:rect 10 context :eagContext]; 11 [glkView bindDrawable]; 12 [self.view addSubview:glkView]; 13 14 // , glkView.drawableHeight) 29 fromRect:[ciImage extent]]; 30 31 [glkView display

    2.4K60发布于 2019-10-15
  • 来自专栏Helloted

    OpenGL ES实践

    三、HelloWorld 1、渲染整个context的背景色 - (void)viewDidLoad { [super viewDidLoad]; GLKView *glkView = (GLKView *)self.view; glkView.context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES2 ]; glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; glkView.drawableDepthFormat [EAGLContext setCurrentContext:glkView.context]; } - (void)glkView:(GLKView *)view drawInRect:(CGRect :(GLKView *)view drawInRect:(CGRect)rect { // 指定刷新整个context颜色缓冲区时所用的颜色,RGBA glClearColor(0.3f

    97710编辑于 2022-06-07
  • 来自专栏小黑娃Henry

    OpenGLES(二)- GLKit: 纹理贴图OpenGLES(二)- GLKit: 纹理贴图

    content){ NSLog(@"create eagl failed"); return; } //创建GLKView GLKView *view = (GLKView *)self.view ; view.context = content; //将content设置为当前EAGLContext [EAGLContext setCurrentContext:content]; //设置GLKView bEffect.texture2d0.enabled = GL_TRUE; bEffect.texture2d0.name = info.name; GLKViewDelegate代理方法 - (void)glkView :(GLKView *)view drawInRect:(CGRect)rect{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    1.3K20发布于 2021-08-09
  • 来自专栏大壮

    OpenGL ES 3.0 使用着色器(OC)

    **几乎每行代码都会增加注释** 1.OpenGL ES 3.0环境 在iOS需要先引用 <OpenGLES/ES2/gl.h> <GLKit/GLKit.h> * 上屏 上屏部分需要使用GLKView ,CAEAGLLaye 其中GLKView初始化: - (GLKView \*)glkView { if (\_glkView == nil) { \_glkView = [ [GLKView alloc] init]; \_glkView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width ); \_glkView.backgroundColor = [UIColor clearColor]; } return \_glkView; } 其中CAEAGLLayer \* scale, self.glkView.frame.origin.y \* scale, self.glkView.frame.size.width

    1.5K80发布于 2020-06-16
  • 来自专栏每日一篇技术文章

    OpenGL ES _ 入门_01

    alloc]initWithAPI:kEAGLRenderingAPIOpenGLES2]; [EAGLContext setCurrentContext:self.eagcontext]; } 第七步.配置GLKView (刚才创建的控制器的view的类型就是GLKView类型) // MARK: - 配置GLKView -(void)configure{ GLKView *view = (GLKView*)self.view 绘制数据 -(void)glkView:(GLKView *)view drawInRect:(CGRect)rect{ static NSInteger count = 0; // 清除颜色缓冲区

    85920发布于 2018-09-14
  • 来自专栏每日一篇技术文章

    OpenGLES_实战04_教你绘制球体

    让学习成为一种习惯 第四步 配置我们的GLKViewController 控制器 GLKView *glkView = (GLKView*)self.view; glkView.drawableDepthFormat = GLKViewDrawableDepthFormat24;// 设置深度缓冲区格式 // 创建管理上下文 glkView.context = [[EAGLContext alloc]initWithAPI :kEAGLRenderingAPIOpenGLES2]; // 设置当前上下文 [EAGLContext setCurrentContext:glkView.context]; 第五步 创建一个负责渲染的类 self.baseEffect.transform.modelviewMatrix = GLKMatrix4Rotate(self.baseEffect.transform.modelviewMatrix, 0.1, 0, 1, 0); } 第十二步 开始绘制 -(void)glkView :(GLKView *)view drawInRect:(CGRect)rect{ // 清除颜色缓冲区 glClearColor(1.0, 0, 1.0, 1); glClear(GL_COLOR_BUFFER_BIT

    1.4K10发布于 2018-09-14
  • 来自专栏小黑娃Henry

    OpenGLES(一)- GLKit以及常见API

    GLKView、GLKController GLKView提供了绘制的场所,继承自UIView,并提供一系列简便调用的API。 GLKController 是GLKView的容器,继承自UIViewController。用于绘制视图内容的管理与呈现。 ios12以后苹果大大废弃了GLKit,使用了Metal。 使用GLKit视图呈现流程 通过上图可以看到,使用GLKit将一张图片绘制到屏幕需要三步: 使用GLKView进行创建和参数配置(深度、颜色缓存区)。 完成绘制并保存到帧缓存区中。 并根据数据创建新纹理 - cabeMapWithContentsOfURL:options:queue:completionHandler: 一般使用:从本地文件加载2D纹理图像 GLKit视图渲染 GLKView //在该回调中准备、开始绘制 - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect; GLKViewController管理渲染循环的视图控制器

    1.9K30编辑于 2022-05-13
  • 来自专栏Helloted

    OpenGL ES编程指南(二)

    GLKView类管理OpenGL ES基础结构并为绘图代码提供位置,而GLKViewController类则为GLKit视图中的OpenGL ES内容的平滑动画提供渲染循环。 GLKit View GLKView类提供了基于OpenGL ES的的绘图,与标准UIView绘图循环等价。 创建并配置一个GLKit View 您可以通过编程或使用Interface Builder来创建和配置GLKView对象。 您可以使用其drawableMultisample属性为GLKView实例启用多重采样。 您的渲染器类不使用GLKView的子类并实现drawRect:方法,而是使用GLKViewDelegate协议并实现glkView:drawInRect:方法。

    2.6K20编辑于 2022-06-07
  • 来自专栏iOSer成长记录

    OpenGL ES(三) 纹理

    下面是OpenGL ES载入一个简单纹理的例子 -(void)setupGL{ // 创建设备上下文,用OpenGL ES 2.0的API GLKView *view = (GLKView *)self.view; view.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; // GLKView GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), BUFFER_OFFSET(3*sizeof(GLfloat))); } // 绘图函数 -(void)glkView :(GLKView *)view drawInRect:(CGRect)rect{ glClearColor(0xeb/255.f, 0xf5/255.f, 0xff/255.f, 1.0f glDrawArrays(GL_TRIANGLES, 0, 6); } // 清除缓存 - (void)dealloc { [EAGLContext setCurrentContext:((GLKView

    79150发布于 2018-06-29
  • 来自专栏Helloted

    OpenGL ES编程指南(三)

    为您的GLKView对象的drawableColorFormat和drawableDepthFormat属性使用较低精度的格式。通过这样做,可以减少在底层渲染缓冲区上操作所需的内存带宽。 要为GLKView对象启用多重采样,请更改其drawableMultisample属性的值。 默认情况下,GLKViewController和GLKView类会自动处理方向更改:当用户将设备旋转到支持的方向时,系统会激活方向更改并更改视图控制器视图的大小。 当其大小改变时,GLKView对象相应地调整其帧缓冲区和视口的大小。 如果使用GLKit进行渲染,请设置GLKViewController和GLKView(或您的自定义子类)的实例,并使用其rootViewController属性将它们添加到窗口中。

    2.9K10编辑于 2022-06-07
  • 来自专栏每日一篇技术文章

    OpenGL ES _ 入门练习_002

    kEAGLRenderingAPIOpenGLES1]; [EAGLContext setCurrentContext:self.eagContext]; } /** *  配置view */ - (void)configure{ GLKView *view = (GLKView*)self.view; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; view.context = viewDidLoad { [super viewDidLoad]; [self createEagContext]; [self configure]; [self setClipping]; } -(void)glkView :(GLKView *)view drawInRect:(CGRect)rect{ [self clear]; [self initModelViewMatrix]; [self loadVertexData

    45820编辑于 2022-05-13
  • 来自专栏落影的专栏

    iOS开发-OpenGL ES入门教程1

    self.mContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; //2.0,还有1.0和3.0 GLKView * view = (GLKView *)self.view; //storyboard记得添加 view.context = self.mContext; view.drawableColorFormat GLKViewDrawableColorFormatRGBA8888; //颜色缓冲区格式 [EAGLContext setCurrentContext:self.mContext]; } GLKView * view = (GLKView *)self.view;这里需要在storyboard里面把view的类设置成GLKView,其他代码是OpenGL ES上下文的创建。

    1.7K90发布于 2018-04-27
  • 来自专栏落影的专栏

    iOS开发-OpenGL ES入门教程4

    OpenGL ES 上下文 self.mContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; GLKView * view = (GLKView *)self.view; view.context = self.mContext; view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888 /** * 渲染场景代码 */ - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { glClearColor(0.3f, 0.3f

    1.6K50发布于 2018-04-27
  • 来自专栏每日一篇技术文章

    OPenGL ES _ 入门练习_003

    kEAGLRenderingAPIOpenGLES1]; [EAGLContext setCurrentContext:self.eagContex]; } /** *  配置view */ -(void)configure{ GLKView *view = (GLKView*)self.view; view.context = self.eagContex; view.drawableDepthFormat = GLKViewDrawableDepthFormat24 createEagContext]; // 2 [self configure]; } // GLKViewController  提供了一个回调函数,把我们的加载绘制代码写在里面即可完成 -(void)glkView :(GLKView *)view drawInRect:(CGRect)rect{ [self clear]; //3 [self initProjectionMatrix]; //4 [self initModelView

    43020编辑于 2022-05-13
  • 来自专栏每日一篇技术文章

    OpenGL ES _ 入门练习_004

    } [EAGLContext setCurrentContext:self.context]; // 设置为当前上下文 } // MARK: - 配置view -(void) configure{ GLKView *view = (GLKView *)self.view; view.context = self.context; view.drawableDepthFormat = GLKViewDrawableDepthFormat24 配置 [self createBaseEffect]; // 3.创建渲染管理 [self addVertexAndNormal]; // 4.添加顶点坐标和法线坐标 } #pragma mark - GLKView and GLKViewController delegate methods - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { [self

    52220编辑于 2022-05-13
领券