Post

Replies

Boosts

Views

Activity

MacOs Metal antialiasing
I'm making an app for MacOs, but I'm having problems with the antialiasing implementation in Metal. When compiling I get the following error: validateAttachmentOnDevice:540: failed assertion MTLRenderPassDescriptor render targets have inconsistent sample counts.' This is the code I use to implement the textures: - (void)makeTextures {     if ([depthTexture width] != drawableSize.width || [depthTexture height] != drawableSize.height)     {         MTLTextureDescriptor *colorDescriptor = [MTLTextureDescriptor new];         colorDescriptor.textureType = MTLTextureType2DMultisample;         colorDescriptor.sampleCount = 4;         colorDescriptor.pixelFormat = vista.colorPixelFormat;         colorDescriptor.width = drawableSize.width;         colorDescriptor.height = drawableSize.height;         colorDescriptor.usage = MTLTextureUsageRenderTarget;         colorDescriptor.storageMode = MTLStorageModePrivate;         msaaColorTexture = [view.device newTextureWithDescriptor:colorDescriptor];         MTLTextureDescriptor *resolveDescriptor = [MTLTextureDescriptor new];         resolveDescriptor.textureType = MTLTextureType2D;         resolveDescriptor.pixelFormat = vista.colorPixelFormat;         resolveDescriptor.width = drawableSize.width;         resolveDescriptor.height = drawableSize.height;         resolveDescriptor.storageMode = MTLStorageModePrivate;         msaaResolveColorTexture = [view.device newTextureWithDescriptor:resolveDescriptor];         MTLTextureDescriptor *desc = [MTLTextureDescriptor new];         desc.textureType = MTLTextureType2DMultisample;         desc.sampleCount = 4;         desc.pixelFormat = MTLPixelFormatDepth32Float;         desc.width = drawableSize.width;         desc.height = drawableSize.height;         desc.usage = MTLTextureUsageRenderTarget;         desc.storageMode = MTLStorageModePrivate;         depthTexture = [view.device newTextureWithDescriptor:desc];     } } If at the time of creating the MTLRenderPipelineDescriptor I add .samplecount = 4;, the error disappears, but nothing is drawing in the view. This are de PipelineDescriptor creation: MTLRenderPipelineDescriptor *pipelineStateDescriptor = [MTLRenderPipelineDescriptor new];     pipelineStateDescriptor.label = @"Simple Pipeline";     pipelineStateDescriptor.vertexFunction = vertexFunction;     pipelineStateDescriptor.fragmentFunction = fragmentFunction;     pipelineStateDescriptor.colorAttachments[0].pixelFormat = vista.colorPixelFormat;     pipelineStateDescriptor.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float; // No error but black view.     //pipelineStateDescriptor.sampleCount = 4;     NSError *error;     pipelineState = [view.device newRenderPipelineStateWithDescriptor:pipelineStateDescriptor error:&error];     // Depth stencil.     MTLDepthStencilDescriptor *depthStencilDescriptor = [MTLDepthStencilDescriptor new];     depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionLess;     depthStencilDescriptor.depthWriteEnabled = YES;     depthStencilState = [view.device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; And passDescriptor: if (passDescriptor != nil) {         passDescriptor.colorAttachments[0].texture = msaaColorTexture;         passDescriptor.colorAttachments[0].resolveTexture = msaaResolveColorTexture;         passDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(1.0f, 1.0f, 1.0f, 1.0f);         passDescriptor.colorAttachments[0].storeAction = MTLStoreActionMultisampleResolve;         passDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;         passDescriptor.depthAttachment.texture = depthTexture;         passDescriptor.depthAttachment.clearDepth = 1.0;         passDescriptor.depthAttachment.loadAction = MTLLoadActionClear;         passDescriptor.depthAttachment.storeAction = MTLStoreActionStore; . . . Any suggestion. Thanks by advice. Manuel C.
0
0
702
Aug ’22
Open Recent Menu only works inside Xcode.
Hi.I am implementing the Open Recent Menu in a not NSDocument app.After getting the url of the file throught NSOpenPanel whith the full path to the file, the app proceds to open the file and peocces it, in succes, the app cals:[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:self.URLFile];this adds the file to Open Recent Menu, at this point all ok.When I try to open the file throught Open Recent Menu, the app cals:- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenamereturning YES if the file is sucesfully open, at this point all ok Works fine.... BUT only works if the app is running into XCode, if archive the app export an launch in Finder, not works. Simple this last method is neveer called.A thinkg at I ma missing somethig... any help to make this works outside Xcode will be apreciated.Manuel.Edit:After loogin the app inside XCode as in Terminal App, the problem is when I try to convert from NSString to NSURL. this is the code:- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { // paths in NSDocumentController recentDocumentURLs array NSLog(@"Paths in recentDocumentURLs"); for (NSURL *url in [NSDocumentController sharedDocumentController].recentDocumentURLs) { NSLog(@"Path: %@",[url absoluteString]); } NSLog(@"Path filename: %@", filename); NSString *temp = [filename stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"Path temp: %@", temp); self.archivoURL = [NSURL fileURLWithPath:filename isDirectory:NO]; NSLog(@"Path self.archivoURL: %@", self.archivoURL); if (self.archivoURL == nil) return NO; // open file... return YES; } // Fin de application:OpenFilethis code inside XCode logs: Paths in recentDocumentURLs2016-12-21 00:08:23.118577 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/X_single_Ring_round_40.stl 2016-12-21 00:08:23.118612 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/pirinola.stl 2016-12-21 00:08:23.118625 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stl 2016-12-21 00:08:23.118636 AppMake[9424:253018] Path filename: /Users/Manuel/Documents/Modelos 3D/cubo 3.stl2016-12-21 00:08:23.118665 AppMake[9424:253018] Path temp: /Users/Manuel/Documents/Modelos%203D/cubo%203.stl2016-12-21 00:08:23.118706 AppMake[9424:253018] Path self.archivoURL: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stlthis code outside XCode and launch app throught Terminal.app for see logs, logs:2016-12-21 00:08:05.564 AppMake[9410:252746] Paths in recentDocumentURLs2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/X_single_Ring_round_40.stl2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/pirinola.stl2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stl2016-12-21 00:08:05.566 AppMake[9410:252746] Path filename: /Users/Manuel/Documents/Modelos 3D/cubo 3.stl2016-12-21 00:08:05.566 AppMake[9410:252746] Path temp: /Users/Manuel/Documents/Modelos%203D/cubo%203.stl2016-12-21 00:08:05.566 AppMake[9410:252746] Path self.archivoURL: (null)Any Idea??Thanks Manuel
6
0
1.9k
Dec ’16
Swift NSAttributedString with foregroundColor crash app.
I have the next func to draw a string in a view using Core Graphics with swift 5.3 in Catalina. private func drawString(_ string : String, at point : CGPoint, withFont font : NSFont, andColor color : NSColor ) {     let attributes : [NSAttributedString.Key : Any] = [NSAttributedString.Key.font : font, NSAttributedString.Key.foregroundColor : color.cgColor]     let attStr = NSAttributedString(string:string, attributes:attributes) 		attStr.draw(at:point) } When the app draw the string (line 8) the app crash, and in the Xcode.debug area I read: 2020-10-21 10:17:34.535356-0500 MyApp[15037:1374731] -[__NSCFType set]: unrecognized selector sent to instance 0x60000214ef80 If remove the foregroundColor att, the app runs, but the string is drawing in black. Some Suggestion. Thanks Manuel C.
2
0
1.9k
Oct ’20
swift 5.3 - CGColor.init(red: r, green: g, blue: b, alpha: 1.0) returns NSObject for macOs
I am trying to create a CGColor in Swift 5.3 in macOS Catalina 10.15.7, using: let colour : CGColor = CGColor.init(red: r, green: g, blue: b, alpha: 1.0) where r,g,b, are between 0.0 and 1.0, but the returned object is a NSObject. Same result as using let colour : CGColor = NSColor.init(red: r, green: g, blue: b, alpha: 1.0).cgColor The NSColor is created correctly but at retrieve the CGColor, the result is NSObject. Some suggestions. Thanks. Manuel
5
0
981
Oct ’20
SCNGeometry snapshot
Hi.I need create a NSImaage representation from a custom SCNGeometry to be able use as icon in my app. I be awared that I can take a snapShot fron a SCeneView usin the method - (NSImage *)snapshot, but I need only the image of a geometry with no other element from a scene. Some gide.Thans in advance.
0
0
447
Mar ’20