Commit | Line | Data |
---|---|---|
ef79bbde P |
1 | /*************************************************************************** |
2 | drawgl.m | |
3 | PeopsSoftGPU | |
4 | ||
5 | Created by Gil Pedersen on Sun April 18 2004. | |
6 | Copyright (c) 2004 Gil Pedersen. | |
7 | ***************************************************************************/ | |
8 | ||
9 | /*************************************************************************** | |
10 | * * | |
11 | * This program is free software; you can redistribute it and/or modify * | |
12 | * it under the terms of the GNU General Public License as published by * | |
13 | * the Free Software Foundation; either version 2 of the License, or * | |
14 | * (at your option) any later version. See also the license.txt file for * | |
15 | * additional informations. * | |
16 | * * | |
17 | ***************************************************************************/ | |
18 | ||
19 | #import "PluginWindowController.h" | |
20 | #import "PluginGLView.h" | |
21 | #include "ExtendedKeys.h" | |
22 | #include "externals.h" | |
23 | #include "draw.h" | |
24 | #include "gpu.h" | |
25 | #include "menu.h" | |
26 | ||
27 | //////////////////////////////////////////////////////////////////////////////////// | |
28 | // misc globals | |
29 | //////////////////////////////////////////////////////////////////////////////////// | |
30 | ||
31 | int iResX; | |
32 | int iResY; | |
33 | long lLowerpart; | |
34 | BOOL bIsFirstFrame = TRUE; | |
35 | BOOL bCheckMask=FALSE; | |
36 | unsigned short sSetMask=0; | |
37 | unsigned long lSetMask=0; | |
38 | int iDesktopCol=16; | |
39 | int iShowFPS=0; | |
40 | int iWinSize; | |
41 | int iUseScanLines=0; | |
42 | int iUseNoStretchBlt=0; | |
43 | int iFastFwd=0; | |
44 | int iDebugMode=0; | |
45 | int iFVDisplay=0; | |
46 | PSXPoint_t ptCursorPoint[8]; | |
47 | unsigned short usCursorActive=0; | |
48 | char * Xpixels; | |
49 | char * pCaptionText; | |
50 | ||
51 | //static PluginWindowController *windowController; | |
52 | static PluginGLView *glView; | |
53 | ||
54 | //////////////////////////////////////////////////////////////////////// | |
55 | ||
56 | void DoBufferSwap(void) // SWAP BUFFERS | |
57 | { | |
58 | #if 1 | |
59 | [glView swapBuffer]; | |
60 | #else | |
61 | static long long lastTickCount = -1; | |
62 | static int skipCount = 0; | |
63 | long long microTickCount; | |
64 | long deltaTime; | |
65 | ||
66 | Microseconds((struct UnsignedWide *)µTickCount); | |
67 | deltaTime = (long)(microTickCount - lastTickCount); | |
68 | if (deltaTime <= (PSXDisplay.PAL ? 1000000/50 : 100000000 / 5994) || | |
69 | skipCount >= 3) { | |
70 | skipCount = 0; | |
71 | [glView swapBuffer]; | |
72 | } else { | |
73 | skipCount++; | |
74 | } | |
75 | NSLog(@"count: %i", deltaTime); | |
76 | lastTickCount = microTickCount; | |
77 | #endif | |
78 | } | |
79 | ||
80 | ||
81 | //////////////////////////////////////////////////////////////////////// | |
82 | ||
83 | void DoClearScreenBuffer(void) // CLEAR DX BUFFER | |
84 | { | |
85 | // clear the screen, and DON'T flush it | |
86 | [glView clearBuffer:NO]; | |
87 | } | |
88 | ||
89 | ||
90 | //////////////////////////////////////////////////////////////////////// | |
91 | ||
92 | void DoClearFrontBuffer(void) // CLEAR DX BUFFER | |
93 | { | |
94 | // clear the screen, and flush it | |
95 | [glView clearBuffer:YES]; | |
96 | } | |
97 | ||
98 | //////////////////////////////////////////////////////////////////////// | |
99 | ||
100 | unsigned long ulInitDisplay(void) // OPEN GAME WINDOW | |
101 | { | |
102 | bUsingTWin=FALSE; | |
103 | ||
104 | InitMenu(); | |
105 | ||
106 | bIsFirstFrame = FALSE; | |
107 | ||
108 | if(iShowFPS) | |
109 | { | |
110 | //iShowFPS=0; | |
111 | ulKeybits|=KEY_SHOWFPS; | |
112 | szDispBuf[0]=0; | |
113 | BuildDispMenu(0); | |
114 | } | |
115 | ||
116 | PluginWindowController *windowController = [PluginWindowController openGameView]; | |
117 | glView = [windowController getOpenGLView]; | |
118 | ||
119 | [[windowController window] setTitle:[NSString stringWithCString:pCaptionText]]; | |
120 | ||
121 | return (unsigned long)[windowController window]; | |
122 | } | |
123 | ||
124 | ||
125 | //////////////////////////////////////////////////////////////////////// | |
126 | ||
127 | void CloseDisplay(void) | |
128 | { | |
129 | if (gameController) { | |
130 | [gameController close]; | |
131 | [gameController release]; | |
132 | gameController = nil; | |
133 | gameWindow = nil; | |
134 | } | |
135 | } | |
136 | ||
137 | ||
138 | //////////////////////////////////////////////////////////////////////// | |
139 | ||
140 | void CreatePic(unsigned char * pMem) | |
141 | { | |
142 | } | |
143 | ||
144 | ||
145 | /////////////////////////////////////////////////////////////////////////////////////// | |
146 | ||
147 | void DestroyPic(void) | |
148 | { | |
149 | } | |
150 | ||
151 | ||
152 | /////////////////////////////////////////////////////////////////////////////////////// | |
153 | ||
154 | void DisplayPic(void) | |
155 | { | |
156 | } | |
157 | ||
158 | ||
159 | /////////////////////////////////////////////////////////////////////////////////////// | |
160 | ||
161 | void ShowGpuPic(void) | |
162 | { | |
163 | // this is the default implementation... | |
164 | } | |
165 | ||
166 | /////////////////////////////////////////////////////////////////////////////////////// | |
167 | ||
168 | void ShowTextGpuPic(void) | |
169 | { | |
170 | // this is the default implementation... | |
171 | } | |
172 | ||
173 | ||
174 | void HandleKey(int keycode) | |
175 | { | |
176 | switch (keycode) { | |
177 | case GPU_FULLSCREEN_KEY: | |
178 | [gameController setFullscreen:![gameController fullscreen]]; | |
179 | break; | |
180 | } | |
181 | } |