diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings
index 9d96a5a39..84ea3275e 100644
Binary files a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings and b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings differ
diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.xib b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib
index 6aea53e8d..4555cd07f 100644
--- a/desmume/src/cocoa/translations/English.lproj/MainMenu.xib
+++ b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib
@@ -4252,7 +4252,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
{1.79769e+308, 1.79769e+308}
- {{74, 226}, {295, 54}}
+ {{74, 209}, {295, 74}}
{0, 0}
@@ -8846,6 +8862,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
{489, 425}
+
+
NSView
@@ -16019,14 +16037,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
279
2
- {{230, 79}, {284, 462}}
+ {{230, 59}, {284, 482}}
-461896704
3D Rendering Settings
NSPanel
{1.79769e+308, 1.79769e+308}
-
+
256
YES
@@ -16043,8 +16061,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
- {{15, 97}, {206, 18}}
+ {{15, 77}, {206, 18}}
+
YES
-2080244224
@@ -16065,8 +16084,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
- {{15, 77}, {134, 18}}
+ {{15, 57}, {134, 18}}
+
YES
-2080244224
@@ -16087,8 +16107,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
- {{15, 57}, {80, 18}}
+ {{15, 37}, {80, 18}}
+
YES
-2080244224
@@ -16106,33 +16127,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
25
-
-
- 268
- {{15, 37}, {108, 18}}
-
- YES
-
- -2080244224
- 131072
- Enable Textures
-
-
- 1211912703
- 2
-
-
-
-
- 200
- 25
-
-
268
{{185, 12}, {45, 19}}
+
YES
-1804468671
@@ -16213,6 +16213,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
{{15, 14}, {165, 14}}
+
YES
68288064
@@ -16225,12 +16226,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
- {{1, 1}, {248, 123}}
+ {{1, 1}, {248, 103}}
+
- {{17, 163}, {250, 139}}
+ {{17, 163}, {250, 119}}
+
{0, 0}
67239424
@@ -16254,6 +16257,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
{{65, 18}, {154, 19}}
+
YES
-2080244224
@@ -16282,10 +16286,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
- {{18, 14}, {107, 38}}
+ {{18, 14}, {107, 58}}
+
YES
- 2
+ 3
1
YES
@@ -16409,6 +16414,19 @@ QXBwbGUgQ29tcHV0ZXIsIEluYy4sIDIwMDUAAAAAA
400
75
+
+ 67239424
+ 131072
+ OpenGL
+
+
+ 2
+ 1211912703
+ 0
+
+ 400
+ 75
+
{107, 18}
{4, 2}
@@ -16473,12 +16491,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
- {{1, 1}, {248, 62}}
+ {{1, 1}, {248, 82}}
+
- {{17, 364}, {250, 78}}
+ {{17, 364}, {250, 98}}
+
{0, 0}
67239424
@@ -16512,6 +16532,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
{{18, 14}, {120, 78}}
+
YES
4
1
@@ -16763,10 +16784,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
{{1, 1}, {248, 102}}
+
{{17, 41}, {250, 118}}
+
{0, 0}
67239424
@@ -16798,8 +16821,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
268
- {{16, 12}, {113, 18}}
+ {{16, 32}, {113, 18}}
+
YES
-2080244224
@@ -16817,13 +16841,38 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
25
+
+
+ 268
+ {{15, 12}, {108, 18}}
+
+
+ YES
+
+ -2080244224
+ 131072
+ Enable Textures
+
+
+ 1211912703
+ 2
+
+
+
+
+ 200
+ 25
+
+
- {{1, 1}, {248, 38}}
+ {{1, 1}, {248, 58}}
+
- {{17, 306}, {250, 54}}
+ {{17, 286}, {250, 74}}
+
{0, 0}
67239424
@@ -16843,7 +16892,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
NO
- {284, 462}
+ {284, 482}
+
+
{{0, 0}, {1920, 1178}}
{1.79769e+308, 1.79769e+308}
@@ -28884,6 +28935,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
6232
+
+
+ change3DRenderMethod:
+
+
+
+ 6235
+
@@ -33715,12 +33774,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
-
+
@@ -33880,10 +33939,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
-
-
+
+
@@ -33892,24 +33951,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
-
-
-
-
+
+
+
-
- 3777
-
-
- YES
-
-
-
-
3775
@@ -33990,11 +34039,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
-
- 3778
-
-
-
3793
@@ -34014,24 +34058,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
+
+
-
-
-
-
- 3804
-
-
- YES
-
-
-
-
3803
@@ -34111,11 +34145,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
-
- 3805
-
-
-
3837
@@ -34133,6 +34162,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
+
@@ -34176,6 +34206,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
+
@@ -34256,6 +34287,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
+
@@ -34343,6 +34375,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
YES
+
@@ -39367,6 +39400,44 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
+
+ 6233
+
+
+
+
+ 6234
+
+
+
+
+ 3777
+
+
+ YES
+
+
+
+
+
+ 3778
+
+
+
+
+ 3804
+
+
+ YES
+
+
+
+
+
+ 3805
+
+
+
@@ -40255,6 +40326,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
3810.IBPluginDependency
3811.IBPluginDependency
3837.IBPluginDependency
+ 3837.IBViewBoundsToFrameTransform
3838.IBPluginDependency
3838.IBViewBoundsToFrameTransform
3839.IBAttributePlaceholdersKey
@@ -40287,8 +40359,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
3883.IBAttributePlaceholdersKey
3884.IBAttributePlaceholdersKey
3885.IBPluginDependency
+ 3885.IBViewBoundsToFrameTransform
3886.IBAttributePlaceholdersKey
3886.IBPluginDependency
+ 3886.IBViewBoundsToFrameTransform
3887.IBPluginDependency
3888.IBAttributePlaceholdersKey
3888.IBPluginDependency
@@ -41284,6 +41358,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
6190.IBPluginDependency
6191.IBAttributePlaceholdersKey
6191.IBPluginDependency
+ 6233.IBAttributePlaceholdersKey
+ 6233.IBPluginDependency
+ 6234.IBAttributePlaceholdersKey
627.IBEditorWindowLastContentRect
627.IBPluginDependency
627.IBWindowTemplateEditedContentRect
@@ -42057,7 +42134,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{858, 521}, {489, 425}}
+ {{1004, 578}, {489, 425}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -42931,9 +43008,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
{3.40282e+38, 3.40282e+38}
{256, 408}
- {{1295, 577}, {288, 511}}
+ {{941, 205}, {288, 511}}
com.apple.InterfaceBuilder.CocoaPlugin
- {{1295, 577}, {288, 511}}
+ {{941, 205}, {288, 511}}
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43058,7 +43135,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABDegAAxDLAAA
+ P4AAAL+AAABBcAAAwuIAAA
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43071,7 +43148,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABDegAAxC3AAA
+ P4AAAL+AAABBcAAAwroAAA
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43084,7 +43161,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABDegAAxCjAAA
+ P4AAAL+AAABBcAAAwpIAAA
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43092,12 +43169,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
ToolTip
- When set, SoftRasterizer will render textures onto 3D surfaces. When not set, all 3D surfaces will be solid colored (usually white). Low CPU usage.
+ When set, the 3D renderer will render textures onto 3D surfaces. When not set, all 3D surfaces will be solid colored (usually white). May slightly reduce CPU usage.
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABDegAAxCPAAA
+ P4AAAL+AAABBcAAAweAAAA
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43127,12 +43204,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- AUGIAABDTAAAA
+ AUGIAABDIwAAA
com.apple.InterfaceBuilder.CocoaPlugin
- {{1312, 630}, {284, 462}}
+ {{1269, 175}, {284, 482}}
com.apple.InterfaceBuilder.CocoaPlugin
- {{1312, 630}, {284, 462}}
+ {{1269, 175}, {284, 482}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43170,7 +43247,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABCCAAAwuwAAA
+ P4AAAL+AAABBgAAAwuYAAA
ToolTip
@@ -43182,7 +43259,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABCCAAAwsQAAA
+ P4AAAL+AAABBgAAAwr4AAA
ToolTip
@@ -43201,12 +43278,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
ToolTip
- When set, SoftRasterizer will render textures onto 3D surfaces. When not set, all 3D surfaces will be solid colored (usually white). Low CPU usage.
+ When set, the 3D renderer will render textures onto 3D surfaces. When not set, all 3D surfaces will be solid colored (usually white). May slightly reduce CPU usage.
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABCCAAAwmgAAA
+ P4AAAL+AAABBgAAAweAAAA
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43218,9 +43295,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
+
+ AUGIAABDxoAAA
+
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABBkAAAwkgAAA
+ P4AAAL+AAABBkAAAwqoAAA
ToolTip
@@ -43236,7 +43316,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
ToolTip
- DeSmuME's internal software 3D rendering engine. Very high CPU usage.
+ DeSmuME's internal software 3D rendering engine. Very high CPU usage. Recommended setting.
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43254,7 +43334,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
P4AAAL+AAABDXAAAw5qAAA
com.apple.InterfaceBuilder.CocoaPlugin
- {{626, 935}, {161, 43}}
+ {{1233, 861}, {152, 63}}
com.apple.InterfaceBuilder.CocoaPlugin
ToolTip
@@ -43270,7 +43350,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
ToolTip
- DeSmuME's internal software 3D rendering engine. Very high CPU usage.
+ DeSmuME's internal software 3D rendering engine. Very high CPU usage. Recommended setting.
com.apple.InterfaceBuilder.CocoaPlugin
@@ -43323,6 +43403,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
+
+ AUGIAABDmQAAA
+
ToolTip
@@ -43332,6 +43415,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
+
+ P4AAAL+AAABBgAAAwkAAAA
+
com.apple.InterfaceBuilder.CocoaPlugin
ToolTip
@@ -43391,7 +43477,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- AUKUAABDcQAAA
+ AUKUAABDXQAAA
ToolTip
@@ -43403,7 +43489,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
- P4AAAL+AAABBgAAAweAAAA
+ P4AAAL+AAABBgAAAwjQAAA
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -45274,6 +45360,23 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
com.apple.InterfaceBuilder.CocoaPlugin
+
+ ToolTip
+
+ ToolTip
+
+ OpenGL-based 3D rendering engine. Some 3D objects may have better looking texturing, but the geometry may be less accurate. Extremely high CPU usage.
+
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ ToolTip
+
+ ToolTip
+
+ OpenGL-based 3D rendering engine. Some 3D objects may have better looking texturing, but the geometry may be less accurate. Extremely high CPU usage.
+
+
{{609, 360}, {400, 100}}
com.apple.InterfaceBuilder.CocoaPlugin
{{609, 360}, {400, 100}}
@@ -45653,7 +45756,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
- 6232
+ 6235
@@ -46190,13 +46293,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
closeMigrationSheet:
closeRom:
copy:
- ejectCard:
executeCoreToggle:
exportRomSave:
hudDisable:
importRomSave:
loadEmuSaveStateSlot:
loadLastRom:
+ loadReplay:
loadRomToggle:
openEmuSaveState:
openRom:
@@ -46327,13 +46430,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
closeMigrationSheet:
closeRom:
copy:
- ejectCard:
executeCoreToggle:
exportRomSave:
hudDisable:
importRomSave:
loadEmuSaveStateSlot:
loadLastRom:
+ loadReplay:
loadRomToggle:
openEmuSaveState:
openRom:
@@ -46487,10 +46590,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
copy:
id
-
- ejectCard:
- id
-
executeCoreToggle:
id
@@ -46515,6 +46614,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
loadLastRom:
id
+
+ loadReplay:
+ id
+
loadRomToggle:
id
diff --git a/desmume/src/cocoa/userinterface/displayView.h b/desmume/src/cocoa/userinterface/displayView.h
index 279f01f74..ceee7f4c4 100644
--- a/desmume/src/cocoa/userinterface/displayView.h
+++ b/desmume/src/cocoa/userinterface/displayView.h
@@ -119,25 +119,31 @@
@interface OpenGLDisplayView : NSOpenGLView
{
+ CGLContextObj cglDisplayContext;
+ NSOpenGLContext *oglRendererContext;
+
DisplayViewDelegate *dispViewDelegate;
GLint glTexRenderStyle;
GLenum glTexPixelFormat;
GLvoid *glTexBack;
NSSize glTexBackSize;
- GLuint swRasterizerDrawTexture[2];
- GLfloat swRasterizerMainTexCoord[4][2];
- GLfloat swRasterizerMainVertex[4][2];
- GLfloat swRasterizerTouchTexCoord[4][2];
- GLfloat swRasterizerTouchVertex[4][2];
- GLuint swRasterizerDisplayListIndex;
+ GLfloat mainDisplayTexCoord[4][2];
+ GLfloat touchDisplayTexCoord[4][2];
+ GLint mainDisplayVtx[4][2];
+ GLint touchDisplayVtx[4][2];
+
+ GLuint mainDisplayTexIndex;
+ GLuint touchDisplayTexIndex;
+ GLuint renderDisplayListIndex;
}
- (void) drawVideoFrame;
-- (void) uploadSWRasterizerTextureData:(const GLvoid *)textureData textureSize:(NSSize)textureSize;
-- (void) renderSWRasterizer;
-- (void) setupSWRasterizerVertices;
-- (void) updateDisplayLists;
+- (void) uploadDisplayTextures:(const GLvoid *)textureData textureSize:(NSSize)textureSize;
+- (void) renderDisplay;
+- (void) calculateDisplayVertices;
+- (void) updateRenderDisplayLists;
+- (void) updateDisplays;
@end
@@ -146,7 +152,6 @@ extern "C"
{
#endif
-void SetupOpenGLView(GLsizei width, GLsizei height, GLfloat scalar, GLfloat angleDegrees);
bool OSXOpenGLRendererInit();
bool OSXOpenGLRendererBegin();
void OSXOpenGLRendererEnd();
diff --git a/desmume/src/cocoa/userinterface/displayView.mm b/desmume/src/cocoa/userinterface/displayView.mm
index 6300f5595..dba2923dc 100644
--- a/desmume/src/cocoa/userinterface/displayView.mm
+++ b/desmume/src/cocoa/userinterface/displayView.mm
@@ -29,7 +29,7 @@
#undef BOOL
-NSOpenGLContext *OSXDefaultOpenGLContext = nil;
+CGLContextObj OSXOpenGLRendererContext = NULL;
@implementation DisplayViewDelegate
@@ -900,47 +900,64 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
UInt32 h = GetNearestPositivePOT((UInt32)(GPU_DISPLAY_HEIGHT * 2.0));
glTexBack = (GLvoid *)calloc(w * h, sizeof(UInt16));
glTexBackSize = NSMakeSize(w, h);
+ cglDisplayContext = (CGLContextObj)[[self openGLContext] CGLContextObj];
- OSXDefaultOpenGLContext = [[self openGLContext] retain];
+ CGLContextObj prevContext = CGLGetCurrentContext();
+ CGLSetCurrentContext(cglDisplayContext);
- NSOpenGLContext *prevContext = [NSOpenGLContext currentContext];
- [OSXDefaultOpenGLContext makeCurrentContext];
-
- glGenTextures(2, swRasterizerDrawTexture);
- swRasterizerDisplayListIndex = glGenLists(3);
+ renderDisplayListIndex = glGenLists(3);
+ glGenTextures(1, &mainDisplayTexIndex);
+ glGenTextures(1, &touchDisplayTexIndex);
SetOpenGLRendererFunctions(&OSXOpenGLRendererInit,
&OSXOpenGLRendererBegin,
&OSXOpenGLRendererEnd);
- if (prevContext != nil)
+ CGLSetCurrentContext(prevContext);
+
+ NSOpenGLPixelFormatAttribute attrs[] =
{
- [prevContext makeCurrentContext];
- }
- else
- {
- [NSOpenGLContext clearCurrentContext];
- }
+ NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24,
+ NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8,
+ NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
+ NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)8,
+ NSOpenGLPFAOffScreen,
+ (NSOpenGLPixelFormatAttribute)0
+ };
+
+ NSOpenGLPixelFormat *tempPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
+ NSOpenGLPixelBuffer *tempPixelBuffer = [[NSOpenGLPixelBuffer alloc]
+ initWithTextureTarget:GL_TEXTURE_2D
+ textureInternalFormat:GL_RGBA
+ textureMaxMipMapLevel:0
+ pixelsWide:GPU_DISPLAY_WIDTH
+ pixelsHigh:GPU_DISPLAY_HEIGHT*2];
+
+ NSOpenGLContext *newOGLRendererContext = [[NSOpenGLContext alloc] initWithFormat:tempPixelFormat shareContext:nil];
+ [newOGLRendererContext setPixelBuffer:tempPixelBuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:0];
+
+ [tempPixelFormat release];
+ [tempPixelBuffer release];
+
+ oglRendererContext = newOGLRendererContext;
+ OSXOpenGLRendererContext = (CGLContextObj)[oglRendererContext CGLContextObj];
return self;
}
- (void)dealloc
{
- NSOpenGLContext *prevContext = [NSOpenGLContext currentContext];
- [[self openGLContext] makeCurrentContext];
+ [oglRendererContext release];
+ OSXOpenGLRendererContext = NULL;
- glDeleteTextures(2, swRasterizerDrawTexture);
- glDeleteLists(swRasterizerDisplayListIndex, 3);
+ CGLContextObj prevContext = CGLGetCurrentContext();
+ CGLSetCurrentContext(cglDisplayContext);
- if (prevContext != nil)
- {
- [prevContext makeCurrentContext];
- }
- else
- {
- [NSOpenGLContext clearCurrentContext];
- }
+ glDeleteTextures(1, &mainDisplayTexIndex);
+ glDeleteTextures(1, &touchDisplayTexIndex);
+ glDeleteLists(renderDisplayListIndex, 3);
+
+ CGLSetCurrentContext(prevContext);
free(glTexBack);
glTexBack = NULL;
@@ -974,8 +991,10 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glDisable(GL_STENCIL_TEST);
+ glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDisable(GL_DEPTH_TEST);
+
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -985,10 +1004,10 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
- (void) drawVideoFrame
{
- CGLFlushDrawable((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ CGLFlushDrawable(cglDisplayContext);
}
-- (void) uploadSWRasterizerTextureData:(const GLvoid *)textureData textureSize:(NSSize)textureSize
+- (void) uploadDisplayTextures:(const GLvoid *)textureData textureSize:(NSSize)textureSize
{
NSInteger displayType = [dispViewDelegate displayType];
@@ -1000,12 +1019,12 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
switch (displayType)
{
case DS_DISPLAY_TYPE_MAIN:
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (GLsizei)textureSize.width, (GLsizei)textureSize.height, GL_RGBA, glTexPixelFormat, textureData);
break;
case DS_DISPLAY_TYPE_TOUCH:
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (GLsizei)textureSize.width, (GLsizei)textureSize.height, GL_RGBA, glTexPixelFormat, textureData);
break;
@@ -1014,10 +1033,10 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
textureSize.height /= 2;
size_t offset = (size_t)textureSize.width * (size_t)textureSize.height;
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (GLsizei)textureSize.width, (GLsizei)textureSize.height, GL_RGBA, glTexPixelFormat, textureData);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
if (glTexPixelFormat == GL_UNSIGNED_SHORT_1_5_5_5_REV)
{
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (GLsizei)textureSize.width, (GLsizei)textureSize.height, GL_RGBA, glTexPixelFormat, (uint16_t *)textureData + offset);
@@ -1034,25 +1053,25 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
break;
}
- glBindTexture(GL_TEXTURE_2D, NULL);
+ glBindTexture(GL_TEXTURE_2D, 0);
}
-- (void) renderSWRasterizer
+- (void) renderDisplay
{
NSInteger displayType = [dispViewDelegate displayType];
switch (displayType)
{
case DS_DISPLAY_TYPE_MAIN:
- glCallList(swRasterizerDisplayListIndex);
+ glCallList(renderDisplayListIndex);
break;
case DS_DISPLAY_TYPE_TOUCH:
- glCallList(swRasterizerDisplayListIndex + 1);
+ glCallList(renderDisplayListIndex + 1);
break;
case DS_DISPLAY_TYPE_COMBO:
- glCallList(swRasterizerDisplayListIndex + 2);
+ glCallList(renderDisplayListIndex + 2);
break;
default:
@@ -1060,11 +1079,11 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
}
}
-- (void) setupSWRasterizerVertices
+- (void) calculateDisplayVertices
{
NSInteger displayType = [dispViewDelegate displayType];
- GLfloat w = (GLfloat)dispViewDelegate.normalSize.width * [dispViewDelegate scale];
- GLfloat h = (GLfloat)dispViewDelegate.normalSize.height * [dispViewDelegate scale];
+ GLint w = (GLint)((dispViewDelegate.normalSize.width * [dispViewDelegate scale]) + 0.75);
+ GLint h = (GLint)((dispViewDelegate.normalSize.height * [dispViewDelegate scale]) + 0.75);
if (displayType == DS_DISPLAY_TYPE_COMBO)
{
@@ -1075,176 +1094,239 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
{
if (displayOrder == DS_DISPLAY_ORDER_MAIN_FIRST)
{
- swRasterizerMainVertex[0][0] = -w/2.0f;
- swRasterizerMainVertex[0][1] = h/2.0f;
- swRasterizerMainVertex[1][0] = w/2.0f;
- swRasterizerMainVertex[1][1] = h/2.0f;
- swRasterizerMainVertex[2][0] = w/2.0f;
- swRasterizerMainVertex[2][1] = 0.0f;
- swRasterizerMainVertex[3][0] = -w/2.0f;
- swRasterizerMainVertex[3][1] = 0.0f;
+ mainDisplayVtx[0][0] = 0;
+ mainDisplayVtx[0][1] = h;
+ mainDisplayVtx[1][0] = w;
+ mainDisplayVtx[1][1] = h;
+ mainDisplayVtx[2][0] = w;
+ mainDisplayVtx[2][1] = h/2;
+ mainDisplayVtx[3][0] = 0;
+ mainDisplayVtx[3][1] = h/2;
- swRasterizerTouchVertex[0][0] = -w/2.0f;
- swRasterizerTouchVertex[0][1] = 0.0f;
- swRasterizerTouchVertex[1][0] = w/2.0f;
- swRasterizerTouchVertex[1][1] = 0.0f;
- swRasterizerTouchVertex[2][0] = w/2.0f;
- swRasterizerTouchVertex[2][1] = -h/2.0f;
- swRasterizerTouchVertex[3][0] = -w/2.0f;
- swRasterizerTouchVertex[3][1] = -h/2.0f;
+ touchDisplayVtx[0][0] = 0;
+ touchDisplayVtx[0][1] = h/2;
+ touchDisplayVtx[1][0] = w;
+ touchDisplayVtx[1][1] = h/2;
+ touchDisplayVtx[2][0] = w;
+ touchDisplayVtx[2][1] = 0;
+ touchDisplayVtx[3][0] = 0;
+ touchDisplayVtx[3][1] = 0;
}
else // displayOrder == DS_DISPLAY_ORDER_TOUCH_FIRST
{
- swRasterizerTouchVertex[0][0] = -w/2.0f;
- swRasterizerTouchVertex[0][1] = h/2.0f;
- swRasterizerTouchVertex[1][0] = w/2.0f;
- swRasterizerTouchVertex[1][1] = h/2.0f;
- swRasterizerTouchVertex[2][0] = w/2.0f;
- swRasterizerTouchVertex[2][1] = 0.0f;
- swRasterizerTouchVertex[3][0] = -w/2.0f;
- swRasterizerTouchVertex[3][1] = 0.0f;
+ touchDisplayVtx[0][0] = 0;
+ touchDisplayVtx[0][1] = h;
+ touchDisplayVtx[1][0] = w;
+ touchDisplayVtx[1][1] = h;
+ touchDisplayVtx[2][0] = w;
+ touchDisplayVtx[2][1] = h/2;
+ touchDisplayVtx[3][0] = 0;
+ touchDisplayVtx[3][1] = h/2;
- swRasterizerMainVertex[0][0] = -w/2.0f;
- swRasterizerMainVertex[0][1] = 0.0f;
- swRasterizerMainVertex[1][0] = w/2.0f;
- swRasterizerMainVertex[1][1] = 0.0f;
- swRasterizerMainVertex[2][0] = w/2.0f;
- swRasterizerMainVertex[2][1] = -h/2.0f;
- swRasterizerMainVertex[3][0] = -w/2.0f;
- swRasterizerMainVertex[3][1] = -h/2.0f;
+ mainDisplayVtx[0][0] = 0;
+ mainDisplayVtx[0][1] = h/2;
+ mainDisplayVtx[1][0] = w;
+ mainDisplayVtx[1][1] = h/2;
+ mainDisplayVtx[2][0] = w;
+ mainDisplayVtx[2][1] = 0;
+ mainDisplayVtx[3][0] = 0;
+ mainDisplayVtx[3][1] = 0;
}
}
else // displayOrientation == DS_DISPLAY_ORIENTATION_HORIZONTAL
{
if (displayOrder == DS_DISPLAY_ORDER_MAIN_FIRST)
{
- swRasterizerMainVertex[0][0] = -w/2.0f;
- swRasterizerMainVertex[0][1] = h/2.0f;
- swRasterizerMainVertex[1][0] = 0.0f;
- swRasterizerMainVertex[1][1] = h/2.0f;
- swRasterizerMainVertex[2][0] = 0.0f;
- swRasterizerMainVertex[2][1] = -h/2.0f;
- swRasterizerMainVertex[3][0] = -w/2.0f;
- swRasterizerMainVertex[3][1] = -h/2.0f;
+ mainDisplayVtx[0][0] = 0;
+ mainDisplayVtx[0][1] = h;
+ mainDisplayVtx[1][0] = w/2;
+ mainDisplayVtx[1][1] = h;
+ mainDisplayVtx[2][0] = w/2;
+ mainDisplayVtx[2][1] = 0;
+ mainDisplayVtx[3][0] = 0;
+ mainDisplayVtx[3][1] = 0;
- swRasterizerTouchVertex[0][0] = 0.0f;
- swRasterizerTouchVertex[0][1] = h/2.0f;
- swRasterizerTouchVertex[1][0] = w/2.0f;
- swRasterizerTouchVertex[1][1] = h/2.0f;
- swRasterizerTouchVertex[2][0] = w/2.0f;
- swRasterizerTouchVertex[2][1] = -h/2.0f;
- swRasterizerTouchVertex[3][0] = 0.0f;
- swRasterizerTouchVertex[3][1] = -h/2.0f;
+ touchDisplayVtx[0][0] = w/2;
+ touchDisplayVtx[0][1] = h;
+ touchDisplayVtx[1][0] = w;
+ touchDisplayVtx[1][1] = h;
+ touchDisplayVtx[2][0] = w;
+ touchDisplayVtx[2][1] = 0;
+ touchDisplayVtx[3][0] = w/2;
+ touchDisplayVtx[3][1] = 0;
}
else // displayOrder == DS_DISPLAY_ORDER_TOUCH_FIRST
{
- swRasterizerTouchVertex[0][0] = -w/2.0f;
- swRasterizerTouchVertex[0][1] = h/2.0f;
- swRasterizerTouchVertex[1][0] = 0.0f;
- swRasterizerTouchVertex[1][1] = h/2.0f;
- swRasterizerTouchVertex[2][0] = 0.0f;
- swRasterizerTouchVertex[2][1] = -h/2.0f;
- swRasterizerTouchVertex[3][0] = -w/2.0f;
- swRasterizerTouchVertex[3][1] = -h/2.0f;
+ touchDisplayVtx[0][0] = 0;
+ touchDisplayVtx[0][1] = h;
+ touchDisplayVtx[1][0] = w/2;
+ touchDisplayVtx[1][1] = h;
+ touchDisplayVtx[2][0] = w/2;
+ touchDisplayVtx[2][1] = 0;
+ touchDisplayVtx[3][0] = 0;
+ touchDisplayVtx[3][1] = 0;
- swRasterizerMainVertex[0][0] = 0.0f;
- swRasterizerMainVertex[0][1] = h/2.0f;
- swRasterizerMainVertex[1][0] = w/2.0f;
- swRasterizerMainVertex[1][1] = h/2.0f;
- swRasterizerMainVertex[2][0] = w/2.0f;
- swRasterizerMainVertex[2][1] = -h/2.0f;
- swRasterizerMainVertex[3][0] = 0.0f;
- swRasterizerMainVertex[3][1] = -h/2.0f;
+ mainDisplayVtx[0][0] = w/2;
+ mainDisplayVtx[0][1] = h;
+ mainDisplayVtx[1][0] = w;
+ mainDisplayVtx[1][1] = h;
+ mainDisplayVtx[2][0] = w;
+ mainDisplayVtx[2][1] = 0;
+ mainDisplayVtx[3][0] = w/2;
+ mainDisplayVtx[3][1] = 0;
}
}
}
else // displayType == DS_DISPLAY_TYPE_MAIN || displayType == DS_DISPLAY_TYPE_TOUCH
{
- swRasterizerMainVertex[0][0] = -w/2.0f;
- swRasterizerMainVertex[0][1] = h/2.0f;
- swRasterizerMainVertex[1][0] = w/2.0f;
- swRasterizerMainVertex[1][1] = h/2.0f;
- swRasterizerMainVertex[2][0] = w/2.0f;
- swRasterizerMainVertex[2][1] = -h/2.0f;
- swRasterizerMainVertex[3][0] = -w/2.0f;
- swRasterizerMainVertex[3][1] = -h/2.0f;
+ mainDisplayVtx[0][0] = 0;
+ mainDisplayVtx[0][1] = h;
+ mainDisplayVtx[1][0] = w;
+ mainDisplayVtx[1][1] = h;
+ mainDisplayVtx[2][0] = w;
+ mainDisplayVtx[2][1] = 0;
+ mainDisplayVtx[3][0] = 0;
+ mainDisplayVtx[3][1] = 0;
- swRasterizerTouchVertex[0][0] = -w/2.0f;
- swRasterizerTouchVertex[0][1] = h/2.0f;
- swRasterizerTouchVertex[1][0] = w/2.0f;
- swRasterizerTouchVertex[1][1] = h/2.0f;
- swRasterizerTouchVertex[2][0] = w/2.0f;
- swRasterizerTouchVertex[2][1] = -h/2.0f;
- swRasterizerTouchVertex[3][0] = -w/2.0f;
- swRasterizerTouchVertex[3][1] = -h/2.0f;
+ touchDisplayVtx[0][0] = 0;
+ touchDisplayVtx[0][1] = h;
+ touchDisplayVtx[1][0] = w;
+ touchDisplayVtx[1][1] = h;
+ touchDisplayVtx[2][0] = w;
+ touchDisplayVtx[2][1] = 0;
+ touchDisplayVtx[3][0] = 0;
+ touchDisplayVtx[3][1] = 0;
}
}
-- (void) updateDisplayLists
+- (void) updateRenderDisplayLists
{
+ GLfloat angleDegrees = (GLfloat)CLOCKWISE_DEGREES([dispViewDelegate rotation]);
+ GLfloat frameWidth = (GLfloat)[self frame].size.width;
+ GLfloat frameHeight = (GLfloat)[self frame].size.height;
+ GLfloat displayWidth = (GLfloat)(dispViewDelegate.normalSize.width * [dispViewDelegate scale]);
+ GLfloat displayHeight = (GLfloat)(dispViewDelegate.normalSize.height * [dispViewDelegate scale]);
+
// Main screen only
- glNewList(swRasterizerDisplayListIndex, GL_COMPILE);
- glClear(GL_COLOR_BUFFER_BIT);
+ glNewList(renderDisplayListIndex, GL_COMPILE);
+ glViewport(0, 0, frameWidth, frameHeight);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0, frameWidth, 0.0, frameHeight, -1.0, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTranslatef(frameWidth/2.0f, frameHeight/2.0f, 0.0f);
+ glRotatef(angleDegrees, 0.0f, 0.0f, 1.0f);
+ glTranslatef(-displayWidth/2.0f, -displayHeight/2.0f, 0.0f);
+
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glBegin(GL_QUADS);
for (unsigned int i = 0; i < 4; i++)
{
- glTexCoord2f(swRasterizerMainTexCoord[i][0], swRasterizerMainTexCoord[i][1]);
- glVertex2f(swRasterizerMainVertex[i][0], swRasterizerMainVertex[i][1]);
+ glTexCoord2fv(mainDisplayTexCoord[i]);
+ glVertex2iv(mainDisplayVtx[i]);
}
glEnd();
- glBindTexture(GL_TEXTURE_2D, NULL);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ glPopMatrix();
glEndList();
// Touch screen only
- glNewList(swRasterizerDisplayListIndex + 1, GL_COMPILE);
- glClear(GL_COLOR_BUFFER_BIT);
+ glNewList(renderDisplayListIndex + 1, GL_COMPILE);
+ glViewport(0, 0, frameWidth, frameHeight);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0, frameWidth, 0.0, frameHeight, -1.0, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTranslatef(frameWidth/2.0f, frameHeight/2.0f, 0.0f);
+ glRotatef(angleDegrees, 0.0f, 0.0f, 1.0f);
+ glTranslatef(-displayWidth/2.0f, -displayHeight/2.0f, 0.0f);
+
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
glBegin(GL_QUADS);
for (unsigned int i = 0; i < 4; i++)
{
- glTexCoord2f(swRasterizerTouchTexCoord[i][0], swRasterizerTouchTexCoord[i][1]);
- glVertex2f(swRasterizerTouchVertex[i][0], swRasterizerTouchVertex[i][1]);
+ glTexCoord2fv(touchDisplayTexCoord[i]);
+ glVertex2iv(touchDisplayVtx[i]);
}
glEnd();
- glBindTexture(GL_TEXTURE_2D, NULL);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ glPopMatrix();
glEndList();
// Combo screens
- glNewList(swRasterizerDisplayListIndex + 2, GL_COMPILE);
- glClear(GL_COLOR_BUFFER_BIT);
+ glNewList(renderDisplayListIndex + 2, GL_COMPILE);
+ glViewport(0, 0, frameWidth, frameHeight);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0, frameWidth, 0.0, frameHeight, -1.0, 1.0);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTranslatef(frameWidth/2.0f, frameHeight/2.0f, 0.0f);
+ glRotatef(angleDegrees, 0.0f, 0.0f, 1.0f);
+ glTranslatef(-displayWidth/2.0f, -displayHeight/2.0f, 0.0f);
+
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glBegin(GL_QUADS);
for (unsigned int i = 0; i < 4; i++)
{
- glTexCoord2f(swRasterizerMainTexCoord[i][0], swRasterizerMainTexCoord[i][1]);
- glVertex2f(swRasterizerMainVertex[i][0], swRasterizerMainVertex[i][1]);
+ glTexCoord2fv(mainDisplayTexCoord[i]);
+ glVertex2iv(mainDisplayVtx[i]);
}
glEnd();
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
glBegin(GL_QUADS);
for (unsigned int i = 0; i < 4; i++)
{
- glTexCoord2f(swRasterizerTouchTexCoord[i][0], swRasterizerTouchTexCoord[i][1]);
- glVertex2f(swRasterizerTouchVertex[i][0], swRasterizerTouchVertex[i][1]);
+ glTexCoord2fv(touchDisplayTexCoord[i]);
+ glVertex2iv(touchDisplayVtx[i]);
}
glEnd();
- glBindTexture(GL_TEXTURE_2D, NULL);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ glPopMatrix();
glEndList();
}
+- (void) updateDisplays
+{
+ [self calculateDisplayVertices];
+
+ CGLLockContext(cglDisplayContext);
+
+ CGLSetCurrentContext(cglDisplayContext);
+ [self updateRenderDisplayLists];
+
+ CGLUnlockContext(cglDisplayContext);
+}
+
- (void)keyDown:(NSEvent *)theEvent
{
BOOL isHandled = [dispViewDelegate handleKeyPress:theEvent keyPressed:YES];
@@ -1349,61 +1431,40 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
- (void)doInitVideoOutput:(NSDictionary *)properties
{
- GLfloat scale = (GLfloat)[dispViewDelegate scale];
- GLfloat rotation = (GLfloat)[dispViewDelegate rotation];
- NSRect rect = [self frame];
-
- CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
-
- [[self openGLContext] makeCurrentContext];
- SetupOpenGLView((GLsizei)rect.size.width, (GLsizei)rect.size.height, scale, rotation);
- [[self openGLContext] update];
-
- CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ // No init needed, so do nothing.
}
- (void)doProcessVideoFrame:(const void *)videoFrameData frameSize:(NSSize)frameSize
{
- CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ CGLLockContext(cglDisplayContext);
- [[self openGLContext] makeCurrentContext];
-
- [self uploadSWRasterizerTextureData:videoFrameData textureSize:frameSize];
- [self renderSWRasterizer];
+ CGLSetCurrentContext(cglDisplayContext);
+ [self uploadDisplayTextures:videoFrameData textureSize:frameSize];
+ [self renderDisplay];
[self drawVideoFrame];
- CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ CGLUnlockContext(cglDisplayContext);
}
- (void)doResizeView:(NSRect)rect
{
- CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
-
- [[self openGLContext] makeCurrentContext];
- SetupOpenGLView((GLsizei)rect.size.width, (GLsizei)rect.size.height, (GLfloat)[dispViewDelegate scale], (GLfloat)[dispViewDelegate rotation]);
- [[self openGLContext] update];
-
- CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
-
- [self setupSWRasterizerVertices];
- [self updateDisplayLists];
+ [self updateDisplays];
}
- (void)doRedraw
{
- CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ CGLLockContext(cglDisplayContext);
- [[self openGLContext] makeCurrentContext];
- [self renderSWRasterizer];
+ CGLSetCurrentContext(cglDisplayContext);
+ [self renderDisplay];
[self drawVideoFrame];
- CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);
+ CGLUnlockContext(cglDisplayContext);
}
- (void)doDisplayTypeChanged:(NSInteger)displayTypeID
{
- [self setupSWRasterizerVertices];
- [self updateDisplayLists];
+ [self updateDisplays];
}
- (void)doBilinearOutputChanged:(BOOL)useBilinear
@@ -1414,27 +1475,29 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
glTexRenderStyle = GL_LINEAR;
}
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
+ CGLLockContext(cglDisplayContext);
+
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexRenderStyle);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexRenderStyle);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexRenderStyle);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexRenderStyle);
glBindTexture(GL_TEXTURE_2D, NULL);
+
+ CGLUnlockContext(cglDisplayContext);
}
- (void) doDisplayOrientationChanged:(NSInteger)displayOrientationID
{
- [self setupSWRasterizerVertices];
- [self updateDisplayLists];
+ [self updateDisplays];
}
- (void) doDisplayOrderChanged:(NSInteger)displayOrderID
{
- [self setupSWRasterizerVertices];
- [self updateDisplayLists];
+ [self updateDisplays];
if ([dispViewDelegate displayType] == DS_DISPLAY_TYPE_COMBO)
{
@@ -1451,7 +1514,7 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
swapInt = 1;
}
- [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
+ CGLSetParameter(cglDisplayContext, kCGLCPSwapInterval, &swapInt);
}
- (void)doVideoFilterChanged:(NSInteger)videoFilterTypeID frameSize:(NSSize)videoFilterDestSize
@@ -1487,63 +1550,53 @@ NSOpenGLContext *OSXDefaultOpenGLContext = nil;
}
// Main screen
- swRasterizerMainTexCoord[0][0] = 0.0f;
- swRasterizerMainTexCoord[0][1] = 0.0f;
- swRasterizerMainTexCoord[1][0] = (GLfloat)(videoFilterDestSize.width / w);
- swRasterizerMainTexCoord[1][1] = 0.0f;
- swRasterizerMainTexCoord[2][0] = (GLfloat)(videoFilterDestSize.width / w);
- swRasterizerMainTexCoord[2][1] = (GLfloat)(videoFilterDestSize.height / h);
- swRasterizerMainTexCoord[3][0] = 0.0f;
- swRasterizerMainTexCoord[3][1] = (GLfloat)(videoFilterDestSize.height / h);
-
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, glTexPixelFormat, glTexBack);
+ mainDisplayTexCoord[0][0] = 0.0f;
+ mainDisplayTexCoord[0][1] = 0.0f;
+ mainDisplayTexCoord[1][0] = (GLfloat)(videoFilterDestSize.width / w);
+ mainDisplayTexCoord[1][1] = 0.0f;
+ mainDisplayTexCoord[2][0] = (GLfloat)(videoFilterDestSize.width / w);
+ mainDisplayTexCoord[2][1] = (GLfloat)(videoFilterDestSize.height / h);
+ mainDisplayTexCoord[3][0] = 0.0f;
+ mainDisplayTexCoord[3][1] = (GLfloat)(videoFilterDestSize.height / h);
// Touch screen
- swRasterizerTouchTexCoord[0][0] = 0.0f;
- swRasterizerTouchTexCoord[0][1] = 0.0f;
- swRasterizerTouchTexCoord[1][0] = (GLfloat)(videoFilterDestSize.width / w);
- swRasterizerTouchTexCoord[1][1] = 0.0f;
- swRasterizerTouchTexCoord[2][0] = (GLfloat)(videoFilterDestSize.width / w);
- swRasterizerTouchTexCoord[2][1] = (GLfloat)(videoFilterDestSize.height / h);
- swRasterizerTouchTexCoord[3][0] = 0.0f;
- swRasterizerTouchTexCoord[3][1] = (GLfloat)(videoFilterDestSize.height / h);
+ touchDisplayTexCoord[0][0] = 0.0f;
+ touchDisplayTexCoord[0][1] = 0.0f;
+ touchDisplayTexCoord[1][0] = (GLfloat)(videoFilterDestSize.width / w);
+ touchDisplayTexCoord[1][1] = 0.0f;
+ touchDisplayTexCoord[2][0] = (GLfloat)(videoFilterDestSize.width / w);
+ touchDisplayTexCoord[2][1] = (GLfloat)(videoFilterDestSize.height / h);
+ touchDisplayTexCoord[3][0] = 0.0f;
+ touchDisplayTexCoord[3][1] = (GLfloat)(videoFilterDestSize.height / h);
- glBindTexture(GL_TEXTURE_2D, swRasterizerDrawTexture[1]);
+ CGLLockContext(cglDisplayContext);
+
+ glBindTexture(GL_TEXTURE_2D, mainDisplayTexIndex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, glTexPixelFormat, glTexBack);
+ glBindTexture(GL_TEXTURE_2D, touchDisplayTexIndex);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, glTexPixelFormat, glTexBack);
+ glBindTexture(GL_TEXTURE_2D, 0);
- glBindTexture(GL_TEXTURE_2D, NULL);
+ [self updateRenderDisplayLists];
- [self updateDisplayLists];
+ CGLUnlockContext(cglDisplayContext);
}
@end
-void SetupOpenGLView(GLsizei width, GLsizei height, GLfloat scalar, GLfloat angleDegrees)
-{
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-width/2.0, width/2.0, -height/2.0, height/2.0, -1.0, 1.0);
- glRotatef((GLfloat)CLOCKWISE_DEGREES(angleDegrees), 0.0f, 0.0f, 1.0f);
-}
-
bool OSXOpenGLRendererInit()
{
- [OSXDefaultOpenGLContext makeCurrentContext];
-
return true;
}
bool OSXOpenGLRendererBegin()
{
- CGLLockContext((CGLContextObj)[OSXDefaultOpenGLContext CGLContextObj]);
- [OSXDefaultOpenGLContext makeCurrentContext];
+ CGLSetCurrentContext(OSXOpenGLRendererContext);
return true;
}
void OSXOpenGLRendererEnd()
{
- CGLUnlockContext((CGLContextObj)[OSXDefaultOpenGLContext CGLContextObj]);
+
}