Update of /cvsroot/opentnl/tnl/osx
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31063/osx
Added Files:
Info.plist MyOpenGLView.h MyOpenGLView.mm main.mm
version.plist
Log Message:
Initial commit.
--- NEW FILE: MyOpenGLView.h ---
//-----------------------------------------------------------------------------------
//
// Torque Network Library - ZAP example multiplayer vector graphics space game
// Copyright (C) 2004 GarageGames.com, Inc.
// For more information see http://www.opentnl.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// For use in products that are not compatible with the terms of the GNU
// General Public License, alternative licensing options are available
// from GarageGames.com.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//------------------------------------------------------------------------------------
#import <Cocoa/Cocoa.h>
@interface MyOpenGLView : NSOpenGLView
{
id textWindow;
}
- (void) tick;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)insertLogText: (const char *) text;
@end
--- NEW FILE: Info.plist ---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>TNLTest</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.apple.myCocoaApp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.1</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
--- NEW FILE: MyOpenGLView.mm ---
//-----------------------------------------------------------------------------------
//
// Torque Network Library - ZAP example multiplayer vector graphics space game
// Copyright (C) 2004 GarageGames.com, Inc.
// For more information see http://www.opentnl.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// For use in products that are not compatible with the terms of the GNU
// General Public License, alternative licensing options are available
// from GarageGames.com.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//------------------------------------------------------------------------------------
#include <OpenGL/gl.h>
#import "MyOpenGLView.h"
#include "testGame.h"
class TestGameLog : public LogConsumer
{
id myView;
public:
TestGameLog(id aView) { myView = aView; }
void logString(const char *string)
{
printf("%s\n", string); //[myView insertLogText: avar("%s\n", string)];
}
};
TestGameLog *theLog;
@implementation MyOpenGLView
/*
Override NSView's initWithFrame: to specify our pixel format:
*/
- (id) initWithFrame: (NSRect) frame
{
GLuint attribs[] =
{
NSOpenGLPFANoRecovery,
NSOpenGLPFAWindow,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 8,
NSOpenGLPFAAccumSize, 0,
0
};
[NSTimer scheduledTimerWithTimeInterval: 0.02 target: self selector:@selector(tick) userInfo:NULL repeats: true];
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs];
if (!fmt)
NSLog(@"No OpenGL pixel format");
theLog = new TestGameLog(self);
[self restartAsClient:self];
return self = [super initWithFrame:frame pixelFormat: [fmt autorelease]];
}
- (void) tick
{
if(clientGame)
clientGame->tick();
if(serverGame)
serverGame->tick();
[self setNeedsDisplay: YES];
}
- (void) awakeFromNib
{
}
/*
Override the view's drawRect: to draw our GL content.
*/
- (void) drawRect: (NSRect) rect
{
if(clientGame)
clientGame->renderFrame((U32) rect.size.width, (U32) rect.size.height);
else if(serverGame)
serverGame->renderFrame((U32) rect.size.width, (U32) rect.size.height);
[[self openGLContext] flushBuffer];
}
- (void)insertLogText: (const char *) text
{
[textWindow insertText: [NSString stringWithCString:text]];
}
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint mouseLoc;
mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
NSRect tempRect = [self bounds];
Position p;
p.x = mouseLoc.x / NSWidth(tempRect);
p.y = 1.0f - mouseLoc.y / NSHeight(tempRect);
if(clientGame)
clientGame->moveMyPlayerTo(p);
else if(serverGame)
serverGame->moveMyPlayerTo(p);
}
- (void)restartAsServer:sender
{
delete serverGame;
delete clientGame;
serverGame = new TestGame(true, Address(IPProtocol, Address::Any, 28999),
Address("IP:Broadcast:28999"));
clientGame = NULL;
}
- (void)restartAsClientPingingLocalhost:sender
{
delete serverGame;
delete clientGame;
serverGame = NULL;
clientGame = new TestGame(false, Address(IPProtocol, Address::Any, 0),
Address("IP:localhost:28999"));
}
- (void)restartAsClient:sender
{
delete serverGame;
delete clientGame;
serverGame = NULL;
clientGame = new TestGame(false, Address(IPProtocol, Address::Any, 0),
Address("IP:broadcast:28999"));
}
- (void)restartAsClientAndServer:sender
{
delete serverGame;
delete clientGame;
serverGame = new TestGame(true, Address(IPProtocol, Address::Any, 28999),
Address("IP:Broadcast:28999"));
clientGame = new TestGame(false, Address(IPProtocol, Address::Any, 0),
Address("IP:broadcast:28999"));
clientGame->createLocalConnection(serverGame);
}
@end
--- NEW FILE: main.mm ---
//-----------------------------------------------------------------------------------
//
// Torque Network Library - ZAP example multiplayer vector graphics space game
// Copyright (C) 2004 GarageGames.com, Inc.
// For more information see http://www.opentnl.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// For use in products that are not compatible with the terms of the GNU
// General Public License, alternative licensing options are available
// from GarageGames.com.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//------------------------------------------------------------------------------------
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}
--- NEW FILE: version.plist ---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildVersion</key>
<string>17</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>0.1</string>
<key>ProjectName</key>
<string>NibPBTemplates</string>
<key>SourceVersion</key>
<string>1150000</string>
</dict>
</plist>
|