From a2fe2fdd21b829797c34b77745fe09a6d0e31cc8 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 5 Dec 2012 09:17:49 +0000 Subject: [PATCH] Cocoa Port: - Add support for the OpenGL 3D renderer. - Improve thread-safety of the display code. - Fix a pixel alignment issue when resizing the display window. - Lots of refactoring and cleanup of the display code. --- .../English.lproj/MainMenu.strings | Bin 269664 -> 271872 bytes .../translations/English.lproj/MainMenu.xib | 413 +++++++++------ desmume/src/cocoa/userinterface/displayView.h | 27 +- .../src/cocoa/userinterface/displayView.mm | 489 ++++++++++-------- 4 files changed, 545 insertions(+), 384 deletions(-) diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings index 9d96a5a397023bb55a7c707a9fa0faad2a7fbfd7..84ea3275e99aa7d7ad55d46020e6280f907c5081 100644 GIT binary patch delta 1219 zcmds0-z$S*6h7~HXXI+k%!c_U8Opc$(Jr{5Xc8esa%IfVF|(27W*16PQlFd)sr?1o zg<84L=gtL%J0lZy6z zbkTh|>UsSz0SPKKS&RyN3min<;6_O zEA?mc4arv8n-*pE0a%6*EI|PJpb>(sKgRhK2^Aa1h9LrroGQ=)T^u6}nCE;F;tW%` z$Ir$4EbnVyxFE+kuMn(oJTLL@Mo&{ RuQFQYDE|LHtDzkV;S=^?7pwpP delta 228 zcmZoTBk*9CKtl`T7N!r3(--_>G@Gu$#B^Z#v??Zr=?(uG6{dSIGkKs&CYJ5zG?`LZ aA$sfdA$nCNDrkVUw*%E~zhJ<8;4J`fwof1c 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} - + 256 YES @@ -4273,7 +4273,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{20, 302}, {128, 128}} - YES 130560 @@ -4294,7 +4293,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 18 {{13, 10}, {524, 290}} - YES @@ -4317,9 +4315,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 2322 - {490, 0} + {{0, -14}, {490, 14}} - @@ -4399,7 +4396,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {490, 244} - @@ -4414,7 +4410,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 256 {{490, 0}, {15, 244}} - _doScroller: 0.96240601503759393 @@ -4424,7 +4419,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA -2147483392 {{-100, -100}, {87, 18}} - 1 _doScroller: @@ -4434,7 +4428,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{-3, -3}, {505, 244}} - 16 @@ -4444,7 +4437,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{10, 33}, {504, 244}} - Read Me @@ -4847,7 +4839,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 270 {{153, 343}, {377, 87}} - YES 69336577 @@ -4865,7 +4856,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 270 {{153, 302}, {377, 33}} - YES 73530881 @@ -4881,8 +4871,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {550, 450} - - {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} @@ -7050,7 +7038,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA InputPrefsView - + 268 YES @@ -7059,6 +7047,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 12 {{13, 10}, {463, 401}} + YES @@ -7083,6 +7072,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{72, 44}, {84, 17}} + YES 68288064 @@ -7099,6 +7089,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{44, 16}, {112, 17}} + YES 68288064 @@ -7115,6 +7106,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{158, 38}, {126, 26}} + YES -2076049856 @@ -7195,6 +7187,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{289, 14}, {96, 22}} + YES -1804468671 @@ -7272,6 +7265,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{63, 72}, {93, 17}} + YES 68288064 @@ -7288,6 +7282,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{158, 66}, {126, 26}} + YES -2076049856 @@ -7355,6 +7350,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{158, 11}, {126, 26}} + YES -2076049856 @@ -7456,10 +7452,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {429, 100}} + {{6, 187}, {431, 116}} + {0, 0} 67239424 @@ -7503,6 +7501,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{18, 14}, {100, 38}} + YES 2 1 @@ -7693,10 +7692,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {194, 62}} + {{15, 10}, {196, 78}} + {0, 0} 67239424 @@ -7730,6 +7731,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{18, 14}, {150, 38}} + YES 2 1 @@ -7920,10 +7922,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {194, 62}} + {{218, 10}, {196, 78}} + {0, 0} 67239424 @@ -7945,10 +7949,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {429, 98}} + {{6, 69}, {431, 114}} + {0, 0} 67239424 @@ -7970,6 +7976,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{10, 33}, {443, 355}} + Display Views @@ -8345,7 +8352,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{16, 99}, {239, 18}} + {{16, 82}, {239, 18}} YES @@ -8367,7 +8374,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{16, 79}, {154, 18}} + {{16, 62}, {154, 18}} YES @@ -8389,7 +8396,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{16, 59}, {91, 18}} + {{16, 42}, {91, 18}} YES @@ -8408,28 +8415,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 25 - - - 268 - {{16, 39}, {124, 18}} - - YES - - -2080244224 - 0 - Enable Textures - - - 1211912703 - 2 - - - - - 200 - 25 - - 268 @@ -8577,11 +8562,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {{1, 1}, {293, 125}} + {{1, 1}, {293, 108}} - {{74, 81}, {295, 141}} + {{74, 81}, {295, 124}} {0, 0} @@ -8618,17 +8603,16 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 400 75 - + - SoftRasterizer + OpenGL - 1048576 2147483647 1 _popUpItemAction: - 1 + 2 YES @@ -8640,18 +8624,28 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA None - 1048576 2147483647 _popUpItemAction: - + + + SoftRasterizer + + 2147483647 + + + _popUpItemAction: + 1 + + + - 1 + 2 1 YES YES @@ -8782,7 +8776,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{16, 12}, {129, 18}} + {{16, 32}, {129, 18}} YES @@ -8801,12 +8795,34 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 25 + + + 268 + {{16, 12}, {124, 18}} + + YES + + -2080244224 + 0 + Enable Textures + + + 1211912703 + 2 + + + + + 200 + 25 + + - {{1, 1}, {293, 38}} + {{1, 1}, {293, 58}} - {{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]); + }