1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-01 13:58:20 +00:00

Reinstated clipped CRT output, with more appropriate ownership of the decision.

This commit is contained in:
Thomas Harte 2016-02-07 22:18:55 -05:00
parent 3a689d14cc
commit b5bcadb8d3
6 changed files with 30 additions and 9 deletions

View File

@ -35,6 +35,7 @@ Machine::Machine() :
"float texValue = texture(texID, coordinate).r;"
"return vec3(step(4.0/256.0, mod(texValue, 8.0/256.0)), step(2.0/256.0, mod(texValue, 4.0/256.0)), step(1.0/256.0, mod(texValue, 2.0/256.0)));"
"}");
_crt.set_visible_area(Outputs::Rect(0.2f, 0.0625f, 0.75f, 0.75f));
memset(_keyStates, 0, sizeof(_keyStates));
memset(_palette, 0xf, sizeof(_palette));

View File

@ -28,7 +28,6 @@ class ElectronDocument: MachineDocument {
super.windowControllerDidLoadNib(aController)
electron.view = openGLView
electron.audioQueue = self.audioQueue
// openGLView.frameBounds = CGRectMake(0.0225, 0.0625, 0.75, 0.75)
}
override var windowNibName: String? {

View File

@ -110,6 +110,7 @@ CRT::CRT() :
_is_in_hsync(false),
_is_in_vsync(false),
_current_frame_mutex(new std::mutex),
_visible_area(Rect(0, 0, 1, 1)),
_rasterPosition({.x = 0, .y = 0})
{
construct_openGL();

View File

@ -19,6 +19,20 @@
namespace Outputs {
struct Rect {
struct {
float x, y;
} origin;
struct {
float width, height;
} size;
Rect() {}
Rect(float x, float y, float width, float height) :
origin({.x = x, .y = y}), size({.width = width, .height =height}) {}
};
class CRT {
public:
~CRT();
@ -195,6 +209,10 @@ class CRT {
// void set_phase_function(const char *shader);
void set_output_device(OutputDevice output_device);
void set_visible_area(Rect visible_area)
{
_visible_area = visible_area;
}
private:
CRT();
@ -303,6 +321,7 @@ class CRT {
CRTFrame *_current_frame, *_last_drawn_frame;
std::shared_ptr<std::mutex> _current_frame_mutex;
int _frame_read_pointer;
Rect _visible_area;
struct OpenGLState;
OpenGLState *_openGL_state;

View File

@ -137,19 +137,19 @@ void CRT::push_size_uniforms(unsigned int output_width, unsigned int output_heig
glUniform2f(_openGL_state->windowSizeUniform, output_width, output_height);
}
// GLfloat outputAspectRatioMultiplier = 1.0;//(viewSize.x / viewSize.y) / (4.0 / 3.0);
GLfloat outputAspectRatioMultiplier = ((float)output_width / (float)output_height) / (4.0f / 3.0f);
// _aspectRatioCorrectedBounds = _frameBounds;
Rect _aspect_ratio_corrected_bounds = _visible_area;
// CGFloat bonusWidth = (outputAspectRatioMultiplier - 1.0f) * _frameBounds.size.width;
// _aspectRatioCorrectedBounds.origin.x -= bonusWidth * 0.5f * _aspectRatioCorrectedBounds.size.width;
// _aspectRatioCorrectedBounds.size.width *= outputAspectRatioMultiplier;
GLfloat bonusWidth = (outputAspectRatioMultiplier - 1.0f) * _visible_area.size.width;
_aspect_ratio_corrected_bounds.origin.x -= bonusWidth * 0.5f * _aspect_ratio_corrected_bounds.size.width;
_aspect_ratio_corrected_bounds.size.width *= outputAspectRatioMultiplier;
if(_openGL_state->boundsOriginUniform >= 0)
glUniform2f(_openGL_state->boundsOriginUniform, 0.0, 0.0); //(GLfloat)_aspectRatioCorrectedBounds.origin.x, (GLfloat)_aspectRatioCorrectedBounds.origin.y);
glUniform2f(_openGL_state->boundsOriginUniform, (GLfloat)_aspect_ratio_corrected_bounds.origin.x, (GLfloat)_aspect_ratio_corrected_bounds.origin.y);
if(_openGL_state->boundsSizeUniform >= 0)
glUniform2f(_openGL_state->boundsSizeUniform, 1.0, 1.0);//(GLfloat)_aspectRatioCorrectedBounds.size.width, (GLfloat)_aspectRatioCorrectedBounds.size.height);
glUniform2f(_openGL_state->boundsSizeUniform, (GLfloat)_aspect_ratio_corrected_bounds.size.width, (GLfloat)_aspect_ratio_corrected_bounds.size.height);
}
void CRT::set_composite_sampling_function(const char *shader)

View File

@ -51,7 +51,8 @@ Shader::Shader(const char *vertex_shader, const char *fragment_shader)
Shader::~Shader()
{
glDeleteProgram(_shader_program);
// TODO: ensure this is destructed within the correct context.
// glDeleteProgram(_shader_program);
}
void Shader::bind()