added preliminary gui for movie capture
parent
bcfcfe45cf
commit
a5b3ddb3a0
|
@ -70,5 +70,8 @@ class CelestiaCore;
|
||||||
-(void)showInfoURL;
|
-(void)showInfoURL;
|
||||||
-(void)keyDown:(int)c withModifiers:(int)m;
|
-(void)keyDown:(int)c withModifiers:(int)m;
|
||||||
-(void)keyUp:(int)c withModifiers:(int)m;
|
-(void)keyUp:(int)c withModifiers:(int)m;
|
||||||
|
- (BOOL) captureMovie: (NSString*)filename width: (int)width height: (int)height
|
||||||
|
frameRate: (float)framerate;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#import "CelestiaController.h"
|
#import "CelestiaController.h"
|
||||||
#include "celestiacore.h"
|
#include "celestiacore.h"
|
||||||
|
#include "qtcapture.h"
|
||||||
/*
|
/*
|
||||||
|
|
||||||
void initMovieCapture(MovieCapture *)
|
void initMovieCapture(MovieCapture *)
|
||||||
|
@ -676,5 +677,21 @@ static NSMutableDictionary* tagDict;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) captureMovie: (NSString*) filename width: (int) width height: (int) height
|
||||||
|
frameRate: (float) framerate
|
||||||
|
{
|
||||||
|
MovieCapture* movieCapture = new QTCapture();
|
||||||
|
|
||||||
|
bool success = movieCapture->start([filename cString], width, height, framerate);
|
||||||
|
if (success)
|
||||||
|
appCore->initMovieCapture(movieCapture);
|
||||||
|
else
|
||||||
|
delete movieCapture;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@
|
||||||
|
|
||||||
-(IBAction) showPanel: (id) sender;
|
-(IBAction) showPanel: (id) sender;
|
||||||
|
|
||||||
|
- (IBAction) captureMovie: (id) sender;
|
||||||
|
|
||||||
-(void)addSurfaceMenu:(NSMenu*)contextMenu;
|
-(void)addSurfaceMenu:(NSMenu*)contextMenu;
|
||||||
-(BOOL)validateMenuItem:(id)item;
|
-(BOOL)validateMenuItem:(id)item;
|
||||||
-(IBAction)activateMenuItem:(id)item;
|
-(IBAction)activateMenuItem:(id)item;
|
||||||
|
|
|
@ -697,6 +697,38 @@ NSString* fatalErrorMessage;
|
||||||
[appCore showInfoURL];
|
[appCore showInfoURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) moviePanelDidEnd:(NSSavePanel*)savePanel returnCode: (int) rc contextInfo: (void *) ci
|
||||||
|
{
|
||||||
|
// if (rc == NSOKButton )
|
||||||
|
if (rc == 0 ) return;
|
||||||
|
{
|
||||||
|
NSString *path;
|
||||||
|
path = [savePanel filename];
|
||||||
|
NSLog(@"Saving movie: %@",path);
|
||||||
|
[appCore captureMovie: path width: 640 height: 480 frameRate: 30 ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) captureMovie: (id) sender
|
||||||
|
{
|
||||||
|
// Remove following line to enable movie capture...
|
||||||
|
NSRunAlertPanel(@"No Movie Capture",@"Movie capture is not available in this version of Celestia.",nil,nil,nil); return;
|
||||||
|
|
||||||
|
NSSavePanel* panel = [[NSSavePanel alloc] init];
|
||||||
|
NSString* lastMovie = nil; // temporary; should be saved in defaults
|
||||||
|
|
||||||
|
[panel setRequiredFileType: @"mov"];
|
||||||
|
[panel setTitle: @"Capture Movie"];
|
||||||
|
[panel setMessage: @"Capture Movie"];
|
||||||
|
[ panel beginSheetForDirectory: [lastMovie stringByDeletingLastPathComponent]
|
||||||
|
file: [lastMovie lastPathComponent]
|
||||||
|
modalForWindow: [glView window]
|
||||||
|
modalDelegate: self
|
||||||
|
didEndSelector: @selector(moviePanelDidEnd:returnCode:contextInfo:)
|
||||||
|
contextInfo: nil
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// GUI Tag Methods ----------------------------------------------------------
|
// GUI Tag Methods ----------------------------------------------------------
|
||||||
|
|
||||||
- (BOOL) validateMenuItem: (id) item
|
- (BOOL) validateMenuItem: (id) item
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
ACTIONS = {
|
ACTIONS = {
|
||||||
activateMenuItem = id;
|
activateMenuItem = id;
|
||||||
back = id;
|
back = id;
|
||||||
|
captureMovie = id;
|
||||||
forward = id;
|
forward = id;
|
||||||
openScript = id;
|
openScript = id;
|
||||||
rerunScript = id;
|
rerunScript = id;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<key>242</key>
|
<key>242</key>
|
||||||
<string>441 337 270 342 0 0 1152 746 </string>
|
<string>441 337 270 342 0 0 1152 746 </string>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
<string>57 787 721 44 0 0 1280 832 </string>
|
<string>90 957 721 44 0 0 1600 1002 </string>
|
||||||
<key>296</key>
|
<key>296</key>
|
||||||
<string>555 398 170 341 0 0 1280 832 </string>
|
<string>555 398 170 341 0 0 1280 832 </string>
|
||||||
<key>335</key>
|
<key>335</key>
|
||||||
|
@ -27,12 +27,12 @@
|
||||||
</array>
|
</array>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>383</integer>
|
|
||||||
<integer>21</integer>
|
|
||||||
<integer>29</integer>
|
|
||||||
<integer>1310</integer>
|
<integer>1310</integer>
|
||||||
|
<integer>383</integer>
|
||||||
|
<integer>29</integer>
|
||||||
|
<integer>21</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>7W98</string>
|
<string>7D28</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
Binary file not shown.
|
@ -65,6 +65,59 @@
|
||||||
//082
|
//082
|
||||||
//083
|
//083
|
||||||
//084
|
//084
|
||||||
|
//0C0
|
||||||
|
//0C1
|
||||||
|
//0C2
|
||||||
|
//0C3
|
||||||
|
//0C4
|
||||||
|
0C76BFC0085215B100D31A90 = {
|
||||||
|
fileEncoding = 30;
|
||||||
|
isa = PBXFileReference;
|
||||||
|
lastKnownFileType = sourcecode.c.h;
|
||||||
|
name = moviecapture.h;
|
||||||
|
path = ../src/celestia/moviecapture.h;
|
||||||
|
refType = 2;
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
0C76BFC1085215B100D31A90 = {
|
||||||
|
fileRef = 0C76BFC0085215B100D31A90;
|
||||||
|
isa = PBXBuildFile;
|
||||||
|
settings = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
0C76BFCF08537EDB00D31A90 = {
|
||||||
|
fileEncoding = 30;
|
||||||
|
isa = PBXFileReference;
|
||||||
|
lastKnownFileType = sourcecode.cpp.cpp;
|
||||||
|
path = qtcapture.cpp;
|
||||||
|
refType = 2;
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
0C76BFD008537EDB00D31A90 = {
|
||||||
|
fileEncoding = 30;
|
||||||
|
isa = PBXFileReference;
|
||||||
|
lastKnownFileType = sourcecode.c.h;
|
||||||
|
path = qtcapture.h;
|
||||||
|
refType = 2;
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
0C76BFD108537EDB00D31A90 = {
|
||||||
|
fileRef = 0C76BFCF08537EDB00D31A90;
|
||||||
|
isa = PBXBuildFile;
|
||||||
|
settings = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
0C76BFD208537EDB00D31A90 = {
|
||||||
|
fileRef = 0C76BFD008537EDB00D31A90;
|
||||||
|
isa = PBXBuildFile;
|
||||||
|
settings = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
//0C0
|
||||||
|
//0C1
|
||||||
|
//0C2
|
||||||
|
//0C3
|
||||||
|
//0C4
|
||||||
//100
|
//100
|
||||||
//101
|
//101
|
||||||
//102
|
//102
|
||||||
|
@ -567,6 +620,8 @@
|
||||||
E589B6DE078AC511005B8DD9,
|
E589B6DE078AC511005B8DD9,
|
||||||
E589B6E0078AC511005B8DD9,
|
E589B6E0078AC511005B8DD9,
|
||||||
E56A5AEC0848F92200A21D7E,
|
E56A5AEC0848F92200A21D7E,
|
||||||
|
0C76BFC1085215B100D31A90,
|
||||||
|
0C76BFD208537EDB00D31A90,
|
||||||
);
|
);
|
||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -1544,6 +1599,7 @@
|
||||||
E589B6DF078AC511005B8DD9,
|
E589B6DF078AC511005B8DD9,
|
||||||
E56A3DB80848C19800A21D7E,
|
E56A3DB80848C19800A21D7E,
|
||||||
E56A5AED0848F92200A21D7E,
|
E56A5AED0848F92200A21D7E,
|
||||||
|
0C76BFD108537EDB00D31A90,
|
||||||
);
|
);
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -3229,17 +3285,20 @@
|
||||||
};
|
};
|
||||||
F51C6D51029596B4014901DC = {
|
F51C6D51029596B4014901DC = {
|
||||||
children = (
|
children = (
|
||||||
E56431450776D52D00E2C4A3,
|
|
||||||
F51C6D8B02959960014901DC,
|
F51C6D8B02959960014901DC,
|
||||||
|
E56431450776D52D00E2C4A3,
|
||||||
F51C6D8C02959960014901DC,
|
F51C6D8C02959960014901DC,
|
||||||
F51C6D8D02959960014901DC,
|
F51C6D8D02959960014901DC,
|
||||||
F51C6D8E02959960014901DC,
|
F51C6D8E02959960014901DC,
|
||||||
|
0C76BFCF08537EDB00D31A90,
|
||||||
|
F53036BB03D908CE01000002,
|
||||||
F51C6D9A02959960014901DC,
|
F51C6D9A02959960014901DC,
|
||||||
E56431460776D52D00E2C4A3,
|
E56431460776D52D00E2C4A3,
|
||||||
F51C6D9B02959960014901DC,
|
F51C6D9B02959960014901DC,
|
||||||
F51C6D9C02959960014901DC,
|
F51C6D9C02959960014901DC,
|
||||||
F51C6D9D02959960014901DC,
|
F51C6D9D02959960014901DC,
|
||||||
F53036BB03D908CE01000002,
|
0C76BFC0085215B100D31A90,
|
||||||
|
0C76BFD008537EDB00D31A90,
|
||||||
F53036BC03D908CE01000002,
|
F53036BC03D908CE01000002,
|
||||||
);
|
);
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
// qtcapture.cpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "../src/celengine/gl.h"
|
||||||
|
#include "../src/celengine/glext.h"
|
||||||
|
|
||||||
|
#include <celutil/debug.h>
|
||||||
|
#include "qtcapture.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
QTCapture::QTCapture() :
|
||||||
|
width(-1),
|
||||||
|
height(-1),
|
||||||
|
frameRate(30.0f),
|
||||||
|
frameCounter(0),
|
||||||
|
capturing(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTCapture::~QTCapture()
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QTCapture::start(const string& filename,
|
||||||
|
int w, int h,
|
||||||
|
float fps)
|
||||||
|
{
|
||||||
|
if (capturing)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
frameRate = fps;
|
||||||
|
|
||||||
|
capturing = true;
|
||||||
|
frameCounter = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QTCapture::end()
|
||||||
|
{
|
||||||
|
capturing = false;
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QTCapture::captureFrame()
|
||||||
|
{
|
||||||
|
if (!capturing)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Get the dimensions of the current viewport
|
||||||
|
GLint viewport[4];
|
||||||
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
|
|
||||||
|
int x = viewport[0] + (viewport[2] - width) / 2;
|
||||||
|
int y = viewport[1] + (viewport[3] - height) / 2;
|
||||||
|
|
||||||
|
frameCounter++;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QTCapture::cleanup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QTCapture::getWidth() const
|
||||||
|
{
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QTCapture::getHeight() const
|
||||||
|
{
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
float QTCapture::getFrameRate() const
|
||||||
|
{
|
||||||
|
return frameRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QTCapture::getFrameCount() const
|
||||||
|
{
|
||||||
|
return frameCounter;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
// qtcapture.h
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef _QTCAPTURE_H_
|
||||||
|
#define _QTCAPTURE_H_
|
||||||
|
|
||||||
|
// #include <vfw.h>
|
||||||
|
#include "moviecapture.h"
|
||||||
|
|
||||||
|
|
||||||
|
class QTCapture : public MovieCapture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QTCapture();
|
||||||
|
virtual ~QTCapture();
|
||||||
|
|
||||||
|
bool start(const std::string& filename, int w, int h, float fps);
|
||||||
|
bool end();
|
||||||
|
bool captureFrame();
|
||||||
|
|
||||||
|
int getWidth() const;
|
||||||
|
int getHeight() const;
|
||||||
|
float getFrameRate() const;
|
||||||
|
int getFrameCount() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float frameRate;
|
||||||
|
int frameCounter;
|
||||||
|
bool capturing;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _QTCAPTURE_H_
|
Loading…
Reference in New Issue