[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [270] branches/fusegl/fuse/fusepb
Brought to you by:
fredm
From: <fr...@us...> - 2006-12-29 13:50:19
|
Revision: 270 http://svn.sourceforge.net/fuse-for-macosx/?rev=270&view=rev Author: fredm Date: 2006-12-29 05:50:18 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Refactor drawing to DisplayScene object. Modified Paths: -------------- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj branches/fusegl/fuse/fusepb/FuseMenus.m branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m Added Paths: ----------- branches/fusegl/fuse/fusepb/views/DisplayScene.h branches/fusegl/fuse/fusepb/views/DisplayScene.m Modified: branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-29 12:29:57 UTC (rev 269) +++ branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-29 13:50:18 UTC (rev 270) @@ -11,6 +11,8 @@ B615BFE80B4261E50082D535 /* HIDJoysticks.m in Sources */ = {isa = PBXBuildFile; fileRef = B615BFE60B4261E50082D535 /* HIDJoysticks.m */; }; B615C0130B45159B0082D535 /* DisplayController.h in Headers */ = {isa = PBXBuildFile; fileRef = B615C0110B45159B0082D535 /* DisplayController.h */; }; B615C0140B45159B0082D535 /* DisplayController.m in Sources */ = {isa = PBXBuildFile; fileRef = B615C0120B45159B0082D535 /* DisplayController.m */; }; + B615C02B0B454A7F0082D535 /* DisplayScene.h in Headers */ = {isa = PBXBuildFile; fileRef = B615C0290B454A7E0082D535 /* DisplayScene.h */; }; + B615C02C0B454A7F0082D535 /* DisplayScene.m in Sources */ = {isa = PBXBuildFile; fileRef = B615C02A0B454A7F0082D535 /* DisplayScene.m */; }; B61F459309121DF100C8096C /* Fuse Help in CopyFiles */ = {isa = PBXBuildFile; fileRef = B6F905ED05CDA24300C2F10D /* Fuse Help */; }; B61F459409121DF100C8096C /* disk_plus3.szx in CopyFiles */ = {isa = PBXBuildFile; fileRef = B650C3F2076596C700DE7E81 /* disk_plus3.szx */; }; B61F459509121DF100C8096C /* tape_16.szx in CopyFiles */ = {isa = PBXBuildFile; fileRef = B650C3F4076596FD00DE7E81 /* tape_16.szx */; }; @@ -363,6 +365,8 @@ B615BFE60B4261E50082D535 /* HIDJoysticks.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = HIDJoysticks.m; path = content_arrays/HIDJoysticks.m; sourceTree = "<group>"; }; B615C0110B45159B0082D535 /* DisplayController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DisplayController.h; sourceTree = "<group>"; }; B615C0120B45159B0082D535 /* DisplayController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DisplayController.m; sourceTree = "<group>"; }; + B615C0290B454A7E0082D535 /* DisplayScene.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DisplayScene.h; sourceTree = "<group>"; }; + B615C02A0B454A7F0082D535 /* DisplayScene.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DisplayScene.m; sourceTree = "<group>"; }; B619FC2E090D9BC200344F94 /* SavePanelAccessoryView.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = SavePanelAccessoryView.nib; path = nibs/SavePanelAccessoryView.nib; sourceTree = "<group>"; }; B61EF5B905FED7930081DF70 /* hq3x.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = hq3x.cpp; path = scaler/hq3x.cpp; sourceTree = SOURCE_ROOT; }; B61F46A909121DF100C8096C /* Info-Fuse.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-Fuse.plist"; sourceTree = "<group>"; }; @@ -923,6 +927,8 @@ B6CE7FCF0B28FBEC00EB65B3 /* Views */ = { isa = PBXGroup; children = ( + B615C0290B454A7E0082D535 /* DisplayScene.h */, + B615C02A0B454A7F0082D535 /* DisplayScene.m */, B615C0110B45159B0082D535 /* DisplayController.h */, B615C0120B45159B0082D535 /* DisplayController.m */, B6CE7FCB0B28FBD600EB65B3 /* DisplayOpenGLView.h */, @@ -1234,6 +1240,7 @@ B6A6F11F0B3EA737000B88E9 /* cocoascreenshot.h in Headers */, B615BFE70B4261E50082D535 /* HIDJoysticks.h in Headers */, B615C0130B45159B0082D535 /* DisplayController.h in Headers */, + B615C02B0B454A7F0082D535 /* DisplayScene.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1472,6 +1479,7 @@ B6A6F1200B3EA737000B88E9 /* cocoascreenshot.m in Sources */, B615BFE80B4261E50082D535 /* HIDJoysticks.m in Sources */, B615C0140B45159B0082D535 /* DisplayController.m in Sources */, + B615C02C0B454A7F0082D535 /* DisplayScene.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: branches/fusegl/fuse/fusepb/FuseMenus.m =================================================================== --- branches/fusegl/fuse/fusepb/FuseMenus.m 2006-12-29 12:29:57 UTC (rev 269) +++ branches/fusegl/fuse/fusepb/FuseMenus.m 2006-12-29 13:50:18 UTC (rev 270) @@ -28,6 +28,7 @@ */ #import "DisplayOpenGLView.h" +#import "DisplayScene.h" #import "FuseController.h" #import "FuseMenus.h" @@ -48,12 +49,12 @@ void CreateTexture(Cocoa_Texture* new_screen) { - [[DisplayOpenGLView instance] createTexture:new_screen]; + [[[DisplayOpenGLView instance] scene] createTexture:new_screen]; } void DestroyTexture(void) { - [[DisplayOpenGLView instance] destroyTexture]; + [[[DisplayOpenGLView instance] scene] destroyTexture]; } void SetEmulationHz( float hz ) Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2006-12-29 12:29:57 UTC (rev 269) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2006-12-29 13:50:18 UTC (rev 270) @@ -24,35 +24,26 @@ #import <Cocoa/Cocoa.h> -#include <OpenGL/gl.h> -#include <OpenGL/glext.h> -#include <OpenGL/glu.h> +@class DisplayScene; -#include <libspectrum.h> - -#include "input.h" -#include "ui/cocoa/cocoadisplay.h" - @interface DisplayOpenGLView : NSOpenGLView { NSTimer* timer; - - /* Need texture size and dimensions and two backing textures */ - Cocoa_Texture screenTex; /* Screen texture */ - - BOOL screenTexInitialised; - CFAbsoluteTime time; + /* Model */ + DisplayScene *scene; + /* Controller */ IBOutlet NSResponder *controller; } +(DisplayOpenGLView *) instance; --(void) createTexture:(Cocoa_Texture*)newScreen; --(void) destroyTexture; +- (void)dealloc; --(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime; +- (DisplayScene *)scene; + +-(void) emulationTimerFired:(NSTimer *)timer; -(void) setEmulationHz:(float)hz; -(id) initWithFrame:(NSRect)frameRect; Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-29 12:29:57 UTC (rev 269) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-29 13:50:18 UTC (rev 270) @@ -24,16 +24,8 @@ #import "DisplayOpenGLView.h" -#include "event.h" -#include "fuse.h" -#include "settings.h" -#include "sound.h" +#import "DisplayScene.h" -#include <CoreAudio/AudioHardware.h> -#include "sound/sfifo.h" - -extern sfifo_t sound_fifo; - @implementation DisplayOpenGLView static DisplayOpenGLView *instance = nil; @@ -65,6 +57,9 @@ self = instance; } else { self = [super initWithFrame:frameRect pixelFormat:pixFmt]; + if (self) { + scene = [[DisplayScene alloc] init]; + } instance = self; } @@ -72,15 +67,18 @@ timer = nil; - /* Setup some basic OpenGL stuff */ - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + return self; +} - screenTexInitialised = NO; +- (void)dealloc +{ + [scene release]; + [super dealloc]; +} - return self; +- (DisplayScene *)scene +{ + return scene; } -(void) awakeFromNib @@ -91,184 +89,41 @@ time = CFAbsoluteTimeGetCurrent(); /* set emulation time start time */ } --(void) drawRect:(NSRect)aRect +-(void) emulationTimerFired:(NSTimer *)timer { CFTimeInterval nowTime = CFAbsoluteTimeGetCurrent(); CFTimeInterval deltaTime = nowTime - time; if (deltaTime <= 1.0) { /* skip pauses */ - [self updateEmulationForTimeDelta:deltaTime]; + [scene updateEmulationForTimeDelta:deltaTime]; } time = nowTime; - if( NO == screenTexInitialised ) return; + [self setNeedsDisplay:YES]; +} - /* Need to draw texture to screen here */ - memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.full_height); +-(void) drawRect:(NSRect)aRect +{ + /* Delegate to our scene object for rendering. */ + [scene render]; - [[self openGLContext] makeCurrentContext]; - - /* Bind, update and draw new image */ - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); - - glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, screenTex.full_width, - screenTex.full_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - screenTex.pixels); - - glBegin(GL_QUADS); - - glTexCoord2f((float)screenTex.image_width, (float)(screenTex.image_xoffset)); - glVertex2f(1.0f, 1.0f); - - glTexCoord2f((float)screenTex.image_width, (float)screenTex.image_height); - glVertex2f(1.0f, -1.0f); - - glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_height); - glVertex2f(-1.0f, -1.0f); - - glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_yoffset); - glVertex2f(-1.0f, 1.0f); - - glEnd(); - - /* FIXME: Probably still need to glFlush() in fullscreen mode */ - //glFlush(); - /* Swap buffer to screen */ [[self openGLContext] flushBuffer]; } -/* moved or resized */ --(void) update -{ - NSRect rect; - - [super update]; - - [[self openGLContext] makeCurrentContext]; - [[self openGLContext] update]; - - rect = [self bounds]; - - glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - [self setNeedsDisplay:true]; -} - /* scrolled, moved or resized */ -(void) reshape { - NSRect rect; - - [super reshape]; - - [[self openGLContext] makeCurrentContext]; - [[self openGLContext] update]; - - rect = [self bounds]; - - glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - [self setNeedsDisplay:true]; + /* Delegate to our scene object to update for a change in the view size. */ + [scene setViewportRect:[self bounds]]; } --(void) destroyTexture -{ - GLuint i; - - if( screenTexInitialised == NO) return; - /* FIXME: May want to have a double buffered texture later */ - for(i = 0; i < 1; i++) { - GLint dt = i+1; - glDeleteTextures(1, &dt); - } - screenTexInitialised = NO; -} - --(void) createTexture:(Cocoa_Texture*)newScreen; -{ - GLint i; - - screenTex.full_width = newScreen->full_width; - screenTex.full_height = newScreen->full_height; - screenTex.image_width = newScreen->image_width; - screenTex.image_height = newScreen->image_height; - screenTex.image_xoffset = newScreen->image_xoffset; - screenTex.image_yoffset = newScreen->image_yoffset; - screenTex.pixels = calloc(screenTex.full_width*screenTex.full_height, sizeof(uint32_t)); - if( !screenTex.pixels ) { - fprintf( stderr, "%s: couldn't create screenTex.pixels\n", fuse_progname ); - return; - } - screenTex.pitch = screenTex.full_width * sizeof(uint32_t); - - [[self openGLContext] makeCurrentContext]; - [[self openGLContext] update]; - - /* FIXME: May want to have a double buffered texture later */ - for(i = 0; i < 1; i++) - { - glDisable(GL_TEXTURE_2D); - glEnable(GL_TEXTURE_RECTANGLE_EXT); - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i+1); - - glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, - screenTex.full_width*screenTex.pitch, - screenTex.pixels ); - - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, - GL_STORAGE_CACHED_APPLE); - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - - glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, screenTex.full_width, - screenTex.full_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - screenTex.pixels ); - } - screenTexInitialised = YES; -} - -/* given a delta time in seconds, update overall emulation state */ --(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime -{ - if( sound_enabled ) { - /* emulate until fifo is full */ - while( sfifo_space( &sound_fifo ) >= (sound_stereo+1) * 2 * sound_framesiz ) { - event_do_frame(); - } - } else { - float speed = ( settings_current.emulation_speed < 1 ? - 100.0 : - settings_current.emulation_speed ) / 100.0; - libspectrum_dword time_tstates = deltaTime * - machine_current->timings.processor_speed * - speed + 0.5; - event_do_timer( time_tstates ); - } -} - -(void) setEmulationHz:(float)hz { [timer invalidate]; [timer release]; timer = [[NSTimer scheduledTimerWithTimeInterval: (1.0f / hz) - target:self selector:@selector(drawRect:) + target:self selector:@selector(emulationTimerFired:) userInfo:self repeats:true] retain]; } Copied: branches/fusegl/fuse/fusepb/views/DisplayScene.h (from rev 269, branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h) =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayScene.h (rev 0) +++ branches/fusegl/fuse/fusepb/views/DisplayScene.h 2006-12-29 13:50:18 UTC (rev 270) @@ -0,0 +1,44 @@ +/* DisplayScene.h: Implementation for the DisplayScene class + Copyright (c) 2006 Fredrick Meunier + + 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. + + 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 + + Author contact information: + + E-mail: fr...@sp... + Postal address: 3/66 Roslyn Gardens, Ruscutters Bay, NSW 2011, Australia + +*/ + +#import <Cocoa/Cocoa.h> + +#include "ui/cocoa/cocoadisplay.h" + +@interface DisplayScene : NSObject +{ + /* Need texture size and dimensions and two backing textures */ + Cocoa_Texture screenTex; /* Screen texture */ + + BOOL screenTexInitialised; +} +-(void) setViewportRect:(NSRect)bounds; +-(void) render; + +-(void) createTexture:(Cocoa_Texture*)newScreen; +-(void) destroyTexture; + +-(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime; + +@end Copied: branches/fusegl/fuse/fusepb/views/DisplayScene.m (from rev 269, branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m) =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayScene.m (rev 0) +++ branches/fusegl/fuse/fusepb/views/DisplayScene.m 2006-12-29 13:50:18 UTC (rev 270) @@ -0,0 +1,176 @@ +/* DisplayScene.m: Implementation for the DisplayScene class + Copyright (c) 2006 Fredrick Meunier + + 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. + + 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 + + Author contact information: + + E-mail: fr...@sp... + Postal address: 3/66 Roslyn Gardens, Ruscutters Bay, NSW 2011, Australia + +*/ + +#import "DisplayScene.h" + +#include <OpenGL/gl.h> +#include <OpenGL/glext.h> +#include <OpenGL/glu.h> + +#include "event.h" +#include "fuse.h" +#include "settings.h" +#include "sound.h" +#include "sound/sfifo.h" + +extern sfifo_t sound_fifo; + +@implementation DisplayScene + +- (void)dealloc +{ + [self destroyTexture]; + [super dealloc]; +} + +-(void) setViewportRect:(NSRect)bounds +{ + glViewport(0, 0, (int) bounds.size.width, (int) bounds.size.height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +-(void) render +{ + if( NO == screenTexInitialised ) return; + + /* Need to draw texture to screen here */ + memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.full_height); + + /* Setup some basic OpenGL stuff */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + /* Bind, update and draw new image */ + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); + + glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, screenTex.full_width, + screenTex.full_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + screenTex.pixels); + + glBegin(GL_QUADS); + + glTexCoord2f((float)screenTex.image_width, (float)(screenTex.image_xoffset)); + glVertex2f(1.0f, 1.0f); + + glTexCoord2f((float)screenTex.image_width, (float)screenTex.image_height); + glVertex2f(1.0f, -1.0f); + + glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_height); + glVertex2f(-1.0f, -1.0f); + + glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_yoffset); + glVertex2f(-1.0f, 1.0f); + + glEnd(); + + // Flush out any unfinished rendering before swapping. + //glFinish(); +} + +-(void) destroyTexture +{ + GLuint i; + + if( screenTexInitialised == NO) return; + /* FIXME: May want to have a double buffered texture later */ + for(i = 0; i < 1; i++) { + GLint dt = i+1; + glDeleteTextures(1, &dt); + free( screenTex.pixels ); + screenTex.pixels = NULL; + } + screenTexInitialised = NO; +} + +-(void) createTexture:(Cocoa_Texture*)newScreen; +{ + GLint i; + + screenTex.full_width = newScreen->full_width; + screenTex.full_height = newScreen->full_height; + screenTex.image_width = newScreen->image_width; + screenTex.image_height = newScreen->image_height; + screenTex.image_xoffset = newScreen->image_xoffset; + screenTex.image_yoffset = newScreen->image_yoffset; + screenTex.pixels = calloc(screenTex.full_width*screenTex.full_height, sizeof(uint32_t)); + if( !screenTex.pixels ) { + fprintf( stderr, "%s: couldn't create screenTex.pixels\n", fuse_progname ); + return; + } + screenTex.pitch = screenTex.full_width * sizeof(uint32_t); + + /* FIXME: May want to have a double buffered texture later */ + for(i = 0; i < 1; i++) + { + glDisable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_RECTANGLE_EXT); + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i+1); + + glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, + screenTex.full_width*screenTex.pitch, + screenTex.pixels ); + + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_CACHED_APPLE); + glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + + glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, screenTex.full_width, + screenTex.full_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + screenTex.pixels ); + } + screenTexInitialised = YES; +} + +/* given a delta time in seconds, update overall emulation state */ +-(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime +{ + if( sound_enabled ) { + /* emulate until fifo is full */ + while( sfifo_space( &sound_fifo ) >= (sound_stereo+1) * 2 * sound_framesiz ) { + event_do_frame(); + } + } else { + float speed = ( settings_current.emulation_speed < 1 ? + 100.0 : + settings_current.emulation_speed ) / 100.0; + libspectrum_dword time_tstates = deltaTime * + machine_current->timings.processor_speed * + speed + 0.5; + event_do_timer( time_tstates ); + } +} + +@end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |