mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Changelog: - added Cocoa target: higan can now be compiled for OS X Lion [Cydrak, byuu] - SNES/accuracy profile hires color blending improvements - fixes Marvelous text [AWJ] - fixed a slight bug in SNES/SA-1 VBR support caused by a typo - added support for multi-pass shaders that can load external textures (requires OpenGL 3.2+) - added game library path (used by ananke->Import Game) to Settings->Advanced - system profiles, shaders and cheats database can be stored in "all users" shared folders now (eg /usr/share on Linux) - all configuration files are in BML format now, instead of XML (much easier to read and edit this way) - main window supports drag-and-drop of game folders (but not game files / ZIP archives) - audio buffer clears when entering a modal loop on Windows (prevents audio repetition with DirectSound driver) - a substantial amount of code clean-up (probably the biggest refactoring to date) One highly desired target for this release was to default to the optimal drivers instead of the safest drivers, but because AMD drivers don't seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD has too big a market share. Hopefully with v093 officially released, we can get some public input on what AMD doesn't like.
190 lines
4.4 KiB
C++
190 lines
4.4 KiB
C++
#include "opengl/opengl.hpp"
|
|
|
|
namespace ruby {
|
|
class pVideoCGL;
|
|
}
|
|
|
|
@interface RubyVideoCGL : NSOpenGLView {
|
|
@public
|
|
ruby::pVideoCGL* video;
|
|
}
|
|
-(id) initWith:(ruby::pVideoCGL*)video pixelFormat:(NSOpenGLPixelFormat*)pixelFormat;
|
|
-(void) reshape;
|
|
@end
|
|
|
|
namespace ruby {
|
|
|
|
struct pVideoCGL : OpenGL {
|
|
RubyVideoCGL* view;
|
|
|
|
struct {
|
|
NSView* handle;
|
|
|
|
bool synchronize;
|
|
unsigned filter;
|
|
string shader;
|
|
} settings;
|
|
|
|
bool cap(const string& name) {
|
|
if(name == Video::Handle) return true;
|
|
if(name == Video::Synchronize) return true;
|
|
if(name == Video::Filter) return true;
|
|
if(name == Video::Shader) return true;
|
|
return false;
|
|
}
|
|
|
|
any get(const string& name) {
|
|
if(name == Video::Handle) return (uintptr_t)settings.handle;
|
|
if(name == Video::Synchronize) return settings.synchronize;
|
|
if(name == Video::Filter) return settings.filter;
|
|
return false;
|
|
}
|
|
|
|
bool set(const string& name, const any& value) {
|
|
if(name == Video::Handle) {
|
|
settings.handle = (NSView*)any_cast<uintptr_t>(value);
|
|
return true;
|
|
}
|
|
|
|
if(name == Video::Synchronize) {
|
|
if(settings.synchronize != any_cast<bool>(value)) {
|
|
settings.synchronize = any_cast<bool>(value);
|
|
|
|
if(view) {
|
|
@autoreleasepool {
|
|
[[view openGLContext] makeCurrentContext];
|
|
int synchronize = settings.synchronize;
|
|
[[view openGLContext] setValues:&synchronize forParameter:NSOpenGLCPSwapInterval];
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if(name == Video::Filter) {
|
|
settings.filter = any_cast<unsigned>(value);
|
|
if(settings.shader.empty()) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
|
return true;
|
|
}
|
|
|
|
if(name == Video::Shader) {
|
|
settings.shader = any_cast<const char*>(value);
|
|
@autoreleasepool {
|
|
[[view openGLContext] makeCurrentContext];
|
|
}
|
|
OpenGL::shader(settings.shader);
|
|
if(settings.shader.empty()) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) {
|
|
OpenGL::size(width, height);
|
|
return OpenGL::lock(data, pitch);
|
|
}
|
|
|
|
void unlock() {
|
|
}
|
|
|
|
void clear() {
|
|
@autoreleasepool {
|
|
[view lockFocus];
|
|
OpenGL::clear();
|
|
[[view openGLContext] flushBuffer];
|
|
[view unlockFocus];
|
|
}
|
|
}
|
|
|
|
void refresh() {
|
|
@autoreleasepool {
|
|
if([view lockFocusIfCanDraw]) {
|
|
auto area = [view frame];
|
|
outputWidth = area.size.width, outputHeight = area.size.height;
|
|
OpenGL::refresh();
|
|
[[view openGLContext] flushBuffer];
|
|
[view unlockFocus];
|
|
}
|
|
}
|
|
}
|
|
|
|
bool init() {
|
|
term();
|
|
|
|
@autoreleasepool {
|
|
NSOpenGLPixelFormatAttribute attributes[] = {
|
|
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
|
NSOpenGLPFAColorSize, 24,
|
|
NSOpenGLPFAAlphaSize, 8,
|
|
NSOpenGLPFADoubleBuffer,
|
|
0
|
|
};
|
|
|
|
auto size = [settings.handle frame].size;
|
|
auto format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease];
|
|
auto context = [[[NSOpenGLContext alloc] initWithFormat:format shareContext:nil] autorelease];
|
|
|
|
view = [[RubyVideoCGL alloc] initWith:this pixelFormat:format];
|
|
[view setOpenGLContext:context];
|
|
[view setFrame:NSMakeRect(0, 0, size.width, size.height)];
|
|
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
[settings.handle addSubview:view];
|
|
[context setView:view];
|
|
|
|
[view lockFocus];
|
|
|
|
OpenGL::init();
|
|
//print((const char*)glGetString(GL_VERSION), "\n");
|
|
|
|
int synchronize = settings.synchronize;
|
|
[[view openGLContext] setValues:&synchronize forParameter:NSOpenGLCPSwapInterval];
|
|
|
|
[view unlockFocus];
|
|
}
|
|
|
|
clear();
|
|
return true;
|
|
}
|
|
|
|
void term() {
|
|
OpenGL::term();
|
|
|
|
@autoreleasepool {
|
|
[view removeFromSuperview];
|
|
[view release];
|
|
view = nil;
|
|
}
|
|
}
|
|
|
|
pVideoCGL() {
|
|
view = nil;
|
|
|
|
settings.handle = nil;
|
|
settings.synchronize = false;
|
|
settings.filter = 0;
|
|
}
|
|
|
|
~pVideoCGL() {
|
|
term();
|
|
}
|
|
};
|
|
|
|
DeclareVideo(CGL)
|
|
|
|
}
|
|
|
|
@implementation RubyVideoCGL : NSOpenGLView
|
|
|
|
-(id) initWith:(ruby::pVideoCGL*)videoPointer pixelFormat:(NSOpenGLPixelFormat*)pixelFormat {
|
|
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0) pixelFormat:pixelFormat]) {
|
|
video = videoPointer;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void) reshape {
|
|
video->refresh();
|
|
}
|
|
|
|
@end
|