Initial import.
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1483 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
6d7b97c7a0
commit
4722680fda
2
samples/cocoa/English.lproj/InfoPlist.strings
Normal file
2
samples/cocoa/English.lproj/InfoPlist.strings
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
3979
samples/cocoa/English.lproj/MainMenu.xib
Normal file
3979
samples/cocoa/English.lproj/MainMenu.xib
Normal file
File diff suppressed because it is too large
Load diff
20
samples/cocoa/SfmlController.h
Normal file
20
samples/cocoa/SfmlController.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <SFML/Graphics.hpp>
|
||||
|
||||
@interface SfmlController : NSWindowController
|
||||
{
|
||||
IBOutlet NSView* myView;
|
||||
sf::RenderWindow *mySfmlWindow;
|
||||
sf::Color myColor;
|
||||
}
|
||||
|
||||
- (void)display:(NSTimer*)theTimer;
|
||||
- (void)onInit;
|
||||
|
||||
- (IBAction)onApply:(id)sender;
|
||||
|
||||
@end
|
80
samples/cocoa/SfmlController.mm
Normal file
80
samples/cocoa/SfmlController.mm
Normal file
|
@ -0,0 +1,80 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Note :
|
||||
// - we use .mm extension (Objective-C++) instead of .m (Objective-C) to allow
|
||||
// the use of SFML objects in a Cocoa application
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#import "SfmlController.h"
|
||||
|
||||
#define FPS 60.0f // framerate limit
|
||||
|
||||
@implementation SfmlController
|
||||
|
||||
// Called when all the outlets are valid
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
// Bind the SFML window to the 'myView' NSView object
|
||||
mySfmlWindow = new sf::RenderWindow(myView);
|
||||
|
||||
// Create the SFML loop for handling events and drawing
|
||||
[NSTimer scheduledTimerWithTimeInterval:(1.f/FPS)
|
||||
target:self
|
||||
selector:@selector(display:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
|
||||
[self onInit];
|
||||
}
|
||||
|
||||
- (void)onInit
|
||||
{
|
||||
// Do your SFML initialization stuff here
|
||||
myColor = sf::Color::Blue;
|
||||
}
|
||||
|
||||
// Called when the Apply button is clicked
|
||||
- (IBAction)onApply:(id)sender
|
||||
{
|
||||
// Define your 'Apply' action here
|
||||
if (myColor == sf::Color::Blue) {
|
||||
myColor = sf::Color::Red;
|
||||
} else {
|
||||
myColor = sf::Color::Blue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)display:(NSTimer *)theTimer
|
||||
{
|
||||
if(!mySfmlWindow->IsOpened()) {
|
||||
// Stop the SFML loop as soon as the window is closed
|
||||
// (thus the user can still use the app)
|
||||
[theTimer invalidate];
|
||||
} else {
|
||||
// Do the general SFML event handling
|
||||
sf::Event Event;
|
||||
while (mySfmlWindow->GetEvent(Event)) {
|
||||
if (Event.Type == sf::Event::Closed) {
|
||||
mySfmlWindow->Close();
|
||||
}
|
||||
|
||||
if ((Event.Type == sf::Event::KeyPressed) &&
|
||||
(Event.Key.Code == sf::Key::Escape)) {
|
||||
mySfmlWindow->Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Do the general SFML display process
|
||||
mySfmlWindow->SetActive();
|
||||
mySfmlWindow->Clear();
|
||||
mySfmlWindow->Draw(sf::Shape::Circle(50.f, 50.f, 20.f, myColor));
|
||||
mySfmlWindow->Display();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
14
samples/cocoa/main.m
Normal file
14
samples/cocoa/main.m
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// main.m
|
||||
// Cocoa
|
||||
//
|
||||
// Created by someone on 26/03/10.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
}
|
Loading…
Reference in a new issue