forked from overtake/telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documents progress and add contacts and many design changes
- Loading branch information
Showing
166 changed files
with
10,367 additions
and
1,413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// GLView.h | ||
// Telegram | ||
// | ||
// Created by keepcoder on 16.10.14. | ||
// Copyright (c) 2014 keepcoder. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
// for display link | ||
#import <QuartzCore/QuartzCore.h> | ||
|
||
@interface GLView : NSOpenGLView | ||
{ | ||
CVDisplayLinkRef displayLink; | ||
|
||
double deltaTime; | ||
double outputTime; | ||
float viewWidth; | ||
float viewHeight; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#import "GLView.h" | ||
|
||
@interface GLView (InternalMethods) | ||
|
||
- (CVReturn)getFrameForTime:(const CVTimeStamp *)outputTime; | ||
- (void)drawFrame; | ||
|
||
@end | ||
|
||
@implementation GLView | ||
|
||
#pragma mark - | ||
#pragma mark Display Link | ||
|
||
static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, | ||
const CVTimeStamp *outputTime, CVOptionFlags flagsIn, | ||
CVOptionFlags *flagsOut, void *displayLinkContext) | ||
{ | ||
// go back to Obj-C for easy access to instance variables | ||
CVReturn result = [(__bridge GLView *)displayLinkContext getFrameForTime:outputTime]; | ||
return result; | ||
} | ||
|
||
- (CVReturn)getFrameForTime:(const CVTimeStamp *)outputTime | ||
{ | ||
// deltaTime is unused in this bare bones demo, but here's how to calculate it using display link info | ||
deltaTime = 1.0 / (outputTime->rateScalar * (double)outputTime->videoTimeScale / (double)outputTime->videoRefreshPeriod); | ||
|
||
[self drawFrame]; | ||
|
||
return kCVReturnSuccess; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
CVDisplayLinkRelease(displayLink); | ||
|
||
} | ||
|
||
- (id)initWithFrame:(NSRect)frameRect | ||
{ | ||
// context setup | ||
NSOpenGLPixelFormat *windowedPixelFormat; | ||
NSOpenGLPixelFormatAttribute attribs[] = { | ||
NSOpenGLPFAWindow, | ||
NSOpenGLPFAColorSize, 32, | ||
NSOpenGLPFAAccelerated, | ||
NSOpenGLPFADoubleBuffer, | ||
NSOpenGLPFASingleRenderer, | ||
0 }; | ||
|
||
windowedPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; | ||
if (windowedPixelFormat == nil) | ||
{ | ||
NSLog(@"Unable to create windowed pixel format."); | ||
exit(0); | ||
} | ||
self = [super initWithFrame:frameRect pixelFormat:windowedPixelFormat]; | ||
if (self == nil) | ||
{ | ||
NSLog(@"Unable to create a windowed OpenGL context."); | ||
exit(0); | ||
} | ||
|
||
// set synch to VBL to eliminate tearing | ||
GLint vblSynch = 1; | ||
[[self openGLContext] setValues:&vblSynch forParameter:NSOpenGLCPSwapInterval]; | ||
|
||
// set up the display link | ||
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink); | ||
CVDisplayLinkSetOutputCallback(displayLink, MyDisplayLinkCallback, (__bridge void *)(self)); | ||
CGLContextObj cglContext = (CGLContextObj)[[self openGLContext] CGLContextObj]; | ||
CGLPixelFormatObj cglPixelFormat = (CGLPixelFormatObj)[[self pixelFormat] CGLPixelFormatObj]; | ||
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat); | ||
|
||
return self; | ||
} | ||
|
||
- (void)awakeFromNib | ||
{ | ||
NSSize viewBounds = [self bounds].size; | ||
viewWidth = viewBounds.width; | ||
viewHeight = viewBounds.height; | ||
|
||
// activate the display link | ||
CVDisplayLinkStart(displayLink); | ||
} | ||
|
||
- (void)reshape | ||
{ | ||
NSSize viewBounds = [self bounds].size; | ||
viewWidth = viewBounds.width; | ||
viewHeight = viewBounds.height; | ||
|
||
NSOpenGLContext *currentContext = [self openGLContext]; | ||
[currentContext makeCurrentContext]; | ||
|
||
// remember to lock the context before we touch it since display link is threaded | ||
CGLLockContext((CGLContextObj)[currentContext CGLContextObj]); | ||
|
||
// let the context know we've changed size | ||
[[self openGLContext] update]; | ||
|
||
CGLUnlockContext((CGLContextObj)[currentContext CGLContextObj]); | ||
} | ||
|
||
- (void)drawRect:(NSRect)rect | ||
{ | ||
[self drawFrame]; | ||
} | ||
|
||
- (void)drawFrame | ||
{ | ||
NSOpenGLContext *currentContext = [self openGLContext]; | ||
[currentContext makeCurrentContext]; | ||
|
||
// must lock GL context because display link is threaded | ||
CGLLockContext((CGLContextObj)[currentContext CGLContextObj]); | ||
|
||
glViewport(0, 0, viewWidth, viewHeight); | ||
|
||
// Draw something that changes over time to prove to yourself that it's really updating in a tight loop | ||
glClearColor( | ||
sin(CFAbsoluteTimeGetCurrent()), | ||
sin(7.0*CFAbsoluteTimeGetCurrent()), | ||
sin(CFAbsoluteTimeGetCurrent()/3.0),0); | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
|
||
// draw here | ||
|
||
[currentContext flushBuffer]; | ||
|
||
CGLUnlockContext((CGLContextObj)[currentContext CGLContextObj]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
Copyright (c) 2014-present, Facebook, Inc. | ||
All rights reserved. | ||
This source code is licensed under the BSD-style license found in the | ||
LICENSE file in the root directory of this source tree. An additional grant | ||
of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#ifndef POP_POP_H | ||
#define POP_POP_H | ||
|
||
#import "POPAnimatableProperty.h" | ||
#import "POPAnimation.h" | ||
#import "POPAnimationEvent.h" | ||
#import "POPAnimationExtras.h" | ||
#import "POPAnimationTracer.h" | ||
#import "POPAnimator.h" | ||
#import "POPBasicAnimation.h" | ||
#import "POPCustomAnimation.h" | ||
#import "POPDecayAnimation.h" | ||
#import "POPDefines.h" | ||
#import "POPGeometry.h" | ||
#import "POPPropertyAnimation.h" | ||
#import "POPSpringAnimation.h" | ||
|
||
|
||
#endif /* POP_POP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
Copyright (c) 2014-present, Facebook, Inc. | ||
All rights reserved. | ||
This source code is licensed under the BSD-style license found in the | ||
LICENSE file in the root directory of this source tree. An additional grant | ||
of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#ifndef POPACTION_H | ||
#define POPACTION_H | ||
|
||
#import <QuartzCore/CATransaction.h> | ||
#import "POPDefines.h" | ||
|
||
#ifdef __cplusplus | ||
|
||
namespace POP { | ||
|
||
/** | ||
@abstract Disables Core Animation actions using RAII. | ||
@discussion The disablement of actions is scoped to the current transaction. | ||
*/ | ||
class ActionDisabler | ||
{ | ||
BOOL state; | ||
|
||
public: | ||
ActionDisabler() POP_NOTHROW | ||
{ | ||
state = [CATransaction disableActions]; | ||
[CATransaction setDisableActions:YES]; | ||
} | ||
|
||
~ActionDisabler() | ||
{ | ||
[CATransaction setDisableActions:state]; | ||
} | ||
}; | ||
|
||
/** | ||
@abstract Enables Core Animation actions using RAII. | ||
@discussion The enablement of actions is scoped to the current transaction. | ||
*/ | ||
class ActionEnabler | ||
{ | ||
BOOL state; | ||
|
||
public: | ||
ActionEnabler() POP_NOTHROW | ||
{ | ||
state = [CATransaction disableActions]; | ||
[CATransaction setDisableActions:NO]; | ||
} | ||
|
||
~ActionEnabler() | ||
{ | ||
[CATransaction setDisableActions:state]; | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif /* __cplusplus */ | ||
|
||
#endif /* POPACTION_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.