Posts

Post not yet marked as solved
0 Replies
482 Views
I build an iOS UI framework which Target is "iOS 9.0" only for the iPhone platform, the framework has some png file, so I add in the Assets.xcassets, I build the framework using "Generic iOS Device" so that the formwork can show the image which in Assets.xcassets in any iPhone platform which iOS version ">=iOS 9.0", but the Assets.car file in the framework bundle is too big that I can not accept! I know the Xcode compiles the Assets.xcassets use this command line:/Applications/Xcode.app/Contents/Developer/usr/bin/actool Assets.xcassets --compile build --platform iphoneos --minimum-deployment-target 9.0it can build multiple version png with the same png for different iPhone, I guess that causes the Assets.car big, can I use only one version png for all iPhone platform which iOS version ">=iOS 9.0"?thanks a lot!
Posted
by lslboyhh.
Last updated
.
Post not yet marked as solved
1 Replies
726 Views
I build an iOS UI framework which Target is "iOS 9.0" only for the iPhone platform, the framework has some png file, so I add in the Assets.xcassets, I build the framework using "Generic iOS Device" so that the formwork can show the image which in Assets.xcassets in any iPhone platform which iOS version ">=iOS 9.0", but the Assets.car file in the framework bundle is too big that I can not accept! I know the Xcode compiles the Assets.xcassets use this command line:/Applications/Xcode.app/Contents/Developer/usr/bin/actool Assets.xcassets --compile build --platform iphoneos --minimum-deployment-target 9.0it can build multiple version png with the same png for different iPhone, I guess that causes the Assets.car big, can I use only one version png for all iPhone platform which iOS version ">=iOS 9.0"?thanks a lot!
Posted
by lslboyhh.
Last updated
.
Post not yet marked as solved
0 Replies
424 Views
Hi: I am studying OpenGL on macosx and studying OpenGLES on iOS, on the iOS, I can use the GLKBaseEffect to develop a OpenGLES app and It worked very well, here is my code which for iOS platform.#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize baseEffect; ////////////////////////////////// // This data type is used to store information for each vertex typedef struct { GLKVector3 positionCoords; } SceneVertex; static const SceneVertex vertices[] = { {{-0.5f, -0.5f, 0.0}}, // lower left corner {{0.5f, -0.5f, 0.0}}, // lower right corner {{-0.5f, 0.5f, 0.0}} // upper left corner }; ////////////////////////////////////////////////////// // Called when the view controller's view is loaded // Perform initialization before the view is asked to draw - (void)viewDidLoad { [super viewDidLoad]; // Verify the type of view created automatically by the // Interface Builder storyboard 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 view.context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES2]; // Make the new context current [EAGLContext setCurrentContext:view.context]; // Create a base effect that provides standard OpenGL ES 2.0 // Shading Language programs and set constants to be used for // all subsequent rendering self.baseEffect = [[GLKBaseEffect alloc]init]; self.baseEffect.useConstantColor = GL_TRUE; self.baseEffect.constantColor = GLKVector4Make(1.0f, 1.0f, 1.0f, 1.0f); // Set the background color stored in the current context; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // background color // Generate, bind , and initialize contents of a buffer // stored in GPU memory glGenBuffers(1, // STEP 1 &vertexBufferID); glBindBuffer(GL_ARRAY_BUFFER, // STEP 2 vertexBufferID); glBufferData( // STEP 3 GL_ARRAY_BUFFER, // Initialize buffer contentw sizeof(vertices), // Number of bytes to copy vertices, // Address of bytes to copy GL_STATIC_DRAW); // Hint: cache in GPU memory } /////////////////////////////////////////////////////// // GLKView delegate method: Called by the view controller's view // whenever Cocoa Touch asks the view controller;s view to // draw itself. (In this case, render into a frame buffer that // shares memory with a Core Animation Layer) -(void)glkView:(GLKView *)view drawInRect:(CGRect)rect{ [self.baseEffect prepareToDraw]; // Clear Frame Buffer (erase previous drawing) glClear(GL_COLOR_BUFFER_BIT); // Enable use if position from bound vertex buffer glEnableVertexAttribArray( // STEP 4 GLKVertexAttribPosition); glVertexAttribPointer( // STEP 5 GLKVertexAttribPosition, 3, // three components per vertex GL_FLOAT, // data is floating point GL_FALSE, // no fixex point scalling sizeof(SceneVertex), // no gaps in data NULL); // NULL tells GPU to start at beginning of bound buffer // Draw triangles using the first three vertices in the // currently bound vertex buffer glDrawArrays(GL_TRIANGLES, // STEP 6 0, // Start with first vertex in currently bound buffer 3); // Use three vertices from currently bound buffer }so I tried use the GLKBaseEffect to render the macosx OpenGL app,here is the code for macosx platform:// // MyOpenGLView.h // OpenGLES_Ch6_1_MacOSX // // Created by LEE on 1/16/20. // Copyright © 2020 LEE. All rights reserved. // #import <Cocoa/Cocoa.h> #import <GLKit/GLKit.h> @class AGLKVertexAttribArrayBuffer; NS_ASSUME_NONNULL_BEGIN @interface MyOpenGLView : NSOpenGLView @end NS_ASSUME_NONNULL_END// // MyOpenGLView.m // OpenGLES_Ch6_1_MacOSX // // Created by LEE on 1/16/20. // Copyright © 2020 LEE. All rights reserved. // #import "MyOpenGLView.h" #import <OpenGL/gl.h> #import "SceneCarModel.h" #import "SceneRinkModel.h" @interface MyOpenGLView () { GLuint _program; GLuint vertexBufferID; } @property (strong,nonatomic) GLKBaseEffect *baseEffect; @end @implementation MyOpenGLView @synthesize baseEffect; ////////////////////////////////////////////////////////////////// // GLSL program uniform indices. enum{ UNIFORM_MODELVIEWPROJECTION_MATRIX, USECONSTANTCOLOR, NUM_UNIFORMS }; //////////////////////////////////////////////////////////////// // GLSL program uniform IDs. GLint uniforms[NUM_UNIFORMS]; typedef struct { GLKVector3 positionCoords; } SceneVertex; static const SceneVertex vertices[] = { {{-0.5f, -0.5f, 0.0}}, // lower left corner {{0.5f, -0.5f, 0.0}}, // lower right corner {{-0.5f, 0.5f, 0.0}} // upper left corner }; -(instancetype)initWithCoder:(NSCoder *)coder{ if (self = [super initWithCoder:coder]) { [self.openGLContext makeCurrentContext]; self.baseEffect = [[GLKBaseEffect alloc]init]; self.baseEffect.useConstantColor = GL_TRUE; self.baseEffect.constantColor = GLKVector4Make(0.0f, 1.0f, 1.0f, 1.0f); // Create a base effect that provides standard OpenGL ES 2.0 // Shading Language programs and set constants to be used for // all subsequent rendering // Set the background color stored in the current context; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // background color // Generate, bind , and initialize contents of a buffer // stored in GPU memory glGenBuffers(1, // STEP 1 &vertexBufferID); glBindBuffer(GL_ARRAY_BUFFER, // STEP 2 vertexBufferID); glBufferData( // STEP 3 GL_ARRAY_BUFFER, // Initialize buffer contentw sizeof(vertices), // Number of bytes to copy vertices, // Address of bytes to copy GL_STATIC_DRAW); // Hint: cache in GPU memory } return self; } -(void)drawRect:(NSRect)dirtyRect{ [super drawRect:dirtyRect]; // glFinish(); } -(void)update{ // [super update]; [self.baseEffect prepareToDraw]; // Clear Frame Buffer (erase previous drawing) glClear(GL_COLOR_BUFFER_BIT); // Enable use if position from bound vertex buffer glEnableVertexAttribArray( // STEP 4 GLKVertexAttribPosition); glVertexAttribPointer( // STEP 5 GLKVertexAttribPosition, 3, // three components per vertex GL_FLOAT, // data is floating point GL_FALSE, // no fixex point scalling sizeof(SceneVertex), // no gaps in data NULL); // NULL tells GPU to start at beginning of bound buffer // Draw triangles using the first three vertices in the // currently bound vertex buffer glDrawArrays(GL_TRIANGLES, // STEP 6 0, // Start with first vertex in currently bound buffer 3); // Use three vertices from currently bound buffer glFinish(); } @endit's seems the GLKBaseEffect not work on the macosx OpenGL app, I don't why! could you give me some suggestion, thanks a lot!
Posted
by lslboyhh.
Last updated
.
Post not yet marked as solved
0 Replies
635 Views
Hi: I developed an Opengles use the Opengles3 on iOS, I had read the OpenGL ES Programming Guide, Many techniques introduced in OpenGL ES Programming Guide are aimed specifically at creating OpenGL apps that exhibit great CPU-GPU parallelism, that meaning the CPU time is almost equal to the GPU time when displaying the OpenGL framebuffer. so I create I sample Opengles demo, custom a UIView class to display Opengles content which named NewOpenGLView, in the NewOpenGLView.m I create a CADisplayLink object to display the render content:-(void)createDisplayLink{ self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkMethod)]; self.displayLink.preferredFramesPerSecond = 30; [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } -(void)displayLinkMethod{ [self render]; } -(void)render { glClearColor(0.3, 0.5, 0.8, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, openGLSize.width, openGLSize.height); glEnable(GL_DEPTH_TEST); glUseProgram(_programHandle); [self setupProjectionMatrixAndModelViewMatrix]; [self drawFirstCube]; [self drawSecondCube]; [self drawThirdCube]; glUseProgram(_textureProgram); [self setupTextureProjectionMatrixAndModelViewMatrix]; [self drawTextrue]; [_context presentRenderbuffer:_colorBuffer]; }the 'Show the debug navigator' window show the fps is 30 and the CPU time is 0ms and GPU time is about 1ms, it seems my Opengles app performance pretty good, I know that the render method should run on the background thread for the better UI performance,so I create a background thread to run the render method,so I change the displayLinkMethod code:-(void)displayLinkMethod{ dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0); dispatch_async(globalQueue, ^{ if (testBool == false) { [EAGLContext setCurrentContext:_context]; } testBool = true; dispatch_semaphore_wait(signal, DISPATCH_TIME_FOREVER); [self render]; dispatch_semaphore_signal(signal); }); }after changing the displayLinkMethod code, the Opengles content can show right ar before, but the CPU time increase to 33ms, the GPU time decrease to 0ms, I think the CPU time is not suitable, it makes me confused, what should I do if I want to run the render method in the background thread and decrease the CPU time to suitable value?
Posted
by lslboyhh.
Last updated
.