mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-14 13:33:42 +00:00
Ensured GL context is active when destructing CRTOpenGL.
This commit is contained in:
parent
acab22d95a
commit
d221c712b0
@ -42,10 +42,16 @@ void Machine::setup_output(float aspect_ratio)
|
||||
_crt->set_output_device(Outputs::CRT::Television);
|
||||
}
|
||||
|
||||
void Machine::close_output()
|
||||
{
|
||||
delete _crt;
|
||||
_crt = nullptr;
|
||||
}
|
||||
|
||||
Machine::~Machine()
|
||||
{
|
||||
delete[] _rom;
|
||||
delete _crt;
|
||||
close_output();
|
||||
}
|
||||
|
||||
void Machine::switch_region()
|
||||
|
@ -31,6 +31,7 @@ class Machine: public CPU6502::Processor<Machine> {
|
||||
|
||||
Outputs::CRT::CRT *get_crt() { return _crt; }
|
||||
void setup_output(float aspect_ratio);
|
||||
void close_output();
|
||||
|
||||
private:
|
||||
uint8_t *_rom, *_romPages[4], _ram[128];
|
||||
|
@ -77,6 +77,11 @@ void Machine::setup_output(float aspect_ratio)
|
||||
_speaker.set_input_rate(2000000 / clock_rate_audio_divider);
|
||||
}
|
||||
|
||||
void Machine::close_output()
|
||||
{
|
||||
_crt = nullptr;
|
||||
}
|
||||
|
||||
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
||||
{
|
||||
unsigned int cycles = 1;
|
||||
|
@ -157,6 +157,7 @@ class Machine: public CPU6502::Processor<Machine>, Tape::Delegate {
|
||||
void clear_all_keys();
|
||||
|
||||
void setup_output(float aspect_ratio);
|
||||
void close_output();
|
||||
Outputs::CRT::CRT *get_crt() { return _crt.get(); }
|
||||
Outputs::Speaker *get_speaker() { return &_speaker; }
|
||||
|
||||
|
@ -83,4 +83,10 @@ struct CRTDelegate: public Outputs::CRT::Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeOutput {
|
||||
@synchronized(self) {
|
||||
_atari2600.close_output();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -171,4 +171,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeOutput {
|
||||
@synchronized(self) {
|
||||
_electron.close_output();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -17,5 +17,6 @@
|
||||
- (void)performAsync:(dispatch_block_t)action;
|
||||
- (void)performSync:(dispatch_block_t)action;
|
||||
- (void)setupOutputWithAspectRatio:(float)aspectRatio;
|
||||
- (void)closeOutput;
|
||||
|
||||
@end
|
||||
|
@ -16,5 +16,6 @@
|
||||
- (void)setView:(CSOpenGLView *)view aspectRatio:(float)aspectRatio;
|
||||
|
||||
@property (nonatomic, weak) AudioQueue *audioQueue;
|
||||
@property (nonatomic, readonly) CSOpenGLView *view;
|
||||
|
||||
@end
|
||||
|
@ -37,6 +37,12 @@ struct SpeakerDelegate: public Outputs::Speaker::Delegate {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_view performWithGLContext:^{
|
||||
[self closeOutput];
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)setSpeakerDelegate:(Outputs::Speaker::Delegate *)delegate sampleRate:(int)sampleRate {
|
||||
return NO;
|
||||
}
|
||||
@ -53,7 +59,10 @@ struct SpeakerDelegate: public Outputs::Speaker::Delegate {
|
||||
|
||||
- (void)setupOutputWithAspectRatio:(float)aspectRatio {}
|
||||
|
||||
- (void)closeOutput {}
|
||||
|
||||
- (void)setView:(CSOpenGLView *)view aspectRatio:(float)aspectRatio {
|
||||
_view = view;
|
||||
[view performWithGLContext:^{
|
||||
[self setupOutputWithAspectRatio:aspectRatio];
|
||||
}];
|
||||
|
@ -80,8 +80,7 @@ Shader::Shader(const char *vertex_shader, const char *fragment_shader, const Att
|
||||
|
||||
Shader::~Shader()
|
||||
{
|
||||
// TODO: ensure this is destructed within the correct context.
|
||||
// glDeleteProgram(_shader_program);
|
||||
glDeleteProgram(_shader_program);
|
||||
}
|
||||
|
||||
void Shader::bind()
|
||||
|
Loading…
x
Reference in New Issue
Block a user