mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
eliminate some useless code
This commit is contained in:
parent
4130ecfe96
commit
b1c76ea153
@ -17,7 +17,7 @@ namespace OpenTK.Graphics {
|
||||
|
||||
public abstract void SwapBuffers();
|
||||
|
||||
public abstract bool VSync { get; set; }
|
||||
public abstract bool VSync { set; }
|
||||
|
||||
public virtual void Update(INativeWindow window) { }
|
||||
|
||||
|
@ -10,7 +10,6 @@ namespace OpenTK.Platform.MacOS {
|
||||
|
||||
class AglContext : IGraphicsContext {
|
||||
|
||||
bool mVSync = false;
|
||||
// Todo: keep track of which display adapter was specified when the context was created.
|
||||
// IntPtr displayID;
|
||||
bool mIsFullscreen = false;
|
||||
@ -182,11 +181,9 @@ namespace OpenTK.Platform.MacOS {
|
||||
}
|
||||
|
||||
public override bool VSync {
|
||||
get { return mVSync; }
|
||||
set {
|
||||
int intVal = value ? 1 : 0;
|
||||
Agl.aglSetInteger(ContextHandle, Agl.AGL_SWAP_INTERVAL, ref intVal);
|
||||
mVSync = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,27 +19,17 @@ namespace OpenTK.Platform.Windows {
|
||||
}
|
||||
|
||||
internal static void LoadEntryPoints() {
|
||||
IntPtr address = GetAddress("wglGetSwapIntervalEXT");
|
||||
if (address != IntPtr.Zero) {
|
||||
wglGetSwapIntervalEXT = (GetSwapIntervalEXT)Marshal.GetDelegateForFunctionPointer(
|
||||
address, typeof(GetSwapIntervalEXT));
|
||||
}
|
||||
IntPtr address = GetAddress("wglSwapIntervalEXT");
|
||||
if (address == IntPtr.Zero) return;
|
||||
|
||||
address = GetAddress("wglSwapIntervalEXT");
|
||||
if (address != IntPtr.Zero) {
|
||||
wglSwapIntervalEXT = (SwapIntervalEXT)Marshal.GetDelegateForFunctionPointer(
|
||||
address, typeof(SwapIntervalEXT));
|
||||
}
|
||||
wglSwapIntervalEXT = (SwapIntervalEXT)Marshal.GetDelegateForFunctionPointer(
|
||||
address, typeof(SwapIntervalEXT));
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal delegate Boolean SwapIntervalEXT(int interval);
|
||||
internal static SwapIntervalEXT wglSwapIntervalEXT;
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal delegate int GetSwapIntervalEXT();
|
||||
internal static GetSwapIntervalEXT wglGetSwapIntervalEXT;
|
||||
|
||||
[DllImport("OPENGL32.DLL", SetLastError = true)]
|
||||
internal extern static IntPtr wglCreateContext(IntPtr hDc);
|
||||
[DllImport("OPENGL32.DLL", SetLastError = true)]
|
||||
|
@ -46,9 +46,9 @@ namespace OpenTK.Platform.Windows {
|
||||
"Error: " + Marshal.GetLastWin32Error());
|
||||
}
|
||||
|
||||
dc = Wgl.wglGetCurrentDC();
|
||||
dc = Wgl.wglGetCurrentDC();
|
||||
Wgl.LoadEntryPoints();
|
||||
vsync_supported = Wgl.wglGetSwapIntervalEXT != null && Wgl.wglSwapIntervalEXT != null;
|
||||
vsync_supported = Wgl.wglSwapIntervalEXT != null;
|
||||
}
|
||||
|
||||
public override void SwapBuffers() {
|
||||
@ -58,10 +58,8 @@ namespace OpenTK.Platform.Windows {
|
||||
}
|
||||
|
||||
public override bool VSync {
|
||||
get { return vsync_supported && Wgl.wglGetSwapIntervalEXT() != 0; }
|
||||
set {
|
||||
if (vsync_supported)
|
||||
Wgl.wglSwapIntervalEXT(value ? 1 : 0);
|
||||
if (vsync_supported) Wgl.wglSwapIntervalEXT(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ namespace OpenTK.Platform.X11 {
|
||||
#if !USE_DX
|
||||
X11Window cur;
|
||||
bool vsync_supported;
|
||||
int vsync_interval;
|
||||
|
||||
public X11GLContext(GraphicsMode mode, X11Window window) {
|
||||
Debug.Print("Creating X11GLContext context: ");
|
||||
@ -54,14 +53,10 @@ namespace OpenTK.Platform.X11 {
|
||||
}
|
||||
|
||||
public override bool VSync {
|
||||
get { return vsync_supported && vsync_interval != 0; }
|
||||
set {
|
||||
if (vsync_supported) {
|
||||
int result = Glx.glXSwapIntervalSGI(value ? 1 : 0);
|
||||
if (result != 0)
|
||||
Debug.Print("VSync = {0} failed, error code: {1}.", value, result);
|
||||
vsync_interval = value ? 1 : 0;
|
||||
}
|
||||
if (!vsync_supported) return;
|
||||
int result = Glx.glXSwapIntervalSGI(value ? 1 : 0);
|
||||
if (result != 0) Debug.Print("VSync = {0} failed, error {1}.", value, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,6 @@
|
||||
<Filter Include="Header Files\Entities">
|
||||
<UniqueIdentifier>{dead5fb3-a62a-4eb7-8d74-ce73e66ab9e6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Rendering\Env">
|
||||
<UniqueIdentifier>{8ceea67c-909a-4224-824e-30407393055e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Rendering\Map">
|
||||
<UniqueIdentifier>{7704f4d9-92d9-424b-904f-80ec51f313f6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -231,9 +228,6 @@
|
||||
<ClInclude Include="2DStructs.h">
|
||||
<Filter>Header Files\2D\Utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EnvRenderer.h">
|
||||
<Filter>Header Files\Rendering\Env</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MapGenerator.h">
|
||||
<Filter>Header Files\Generator</Filter>
|
||||
</ClInclude>
|
||||
@ -345,6 +339,9 @@
|
||||
<ClInclude Include="Window.h">
|
||||
<Filter>Header Files\Platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EnvRenderer.h">
|
||||
<Filter>Header Files\Rendering</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="WinPlatform.c">
|
||||
|
@ -207,7 +207,7 @@ static void WoM_CheckMotd(void) {
|
||||
static void WoM_CheckSendWomID(void) {
|
||||
if (wom_sendId && !wom_sentId) {
|
||||
String msg = String_FromConst("/womid WoMClient-2.0.7");
|
||||
ServerConnection_SendChat(&msg);
|
||||
Chat_Send(&msg, false);
|
||||
wom_sentId = true;
|
||||
}
|
||||
}
|
||||
|
@ -673,9 +673,7 @@ void GLContext_SelectGraphicsMode(struct GraphicsMode mode) {
|
||||
HGLRC ctx_Handle;
|
||||
HDC ctx_DC;
|
||||
typedef BOOL (WINAPI *FN_WGLSWAPINTERVAL)(int interval);
|
||||
typedef int (WINAPI *FN_WGLGETSWAPINTERVAL)(void);
|
||||
FN_WGLSWAPINTERVAL wglSwapIntervalEXT;
|
||||
FN_WGLGETSWAPINTERVAL wglGetSwapIntervalEXT;
|
||||
bool ctx_supports_vSync;
|
||||
|
||||
void GLContext_Init(struct GraphicsMode mode) {
|
||||
@ -691,11 +689,10 @@ void GLContext_Init(struct GraphicsMode mode) {
|
||||
if (!wglMakeCurrent(win_DC, ctx_Handle)) {
|
||||
ErrorHandler_FailWithCode(GetLastError(), "Failed to make OpenGL context current");
|
||||
}
|
||||
ctx_DC = wglGetCurrentDC();
|
||||
|
||||
wglGetSwapIntervalEXT = (FN_WGLGETSWAPINTERVAL)GLContext_GetAddress("wglGetSwapIntervalEXT");
|
||||
ctx_DC = wglGetCurrentDC();
|
||||
wglSwapIntervalEXT = (FN_WGLSWAPINTERVAL)GLContext_GetAddress("wglSwapIntervalEXT");
|
||||
ctx_supports_vSync = wglGetSwapIntervalEXT != NULL && wglSwapIntervalEXT != NULL;
|
||||
ctx_supports_vSync = wglSwapIntervalEXT != NULL;
|
||||
}
|
||||
|
||||
void GLContext_Update(void) { }
|
||||
@ -717,10 +714,6 @@ void GLContext_SwapBuffers(void) {
|
||||
}
|
||||
}
|
||||
|
||||
bool GLContext_GetVSync(void) {
|
||||
return ctx_supports_vSync && wglGetSwapIntervalEXT();
|
||||
}
|
||||
|
||||
void GLContext_SetVSync(bool enabled) {
|
||||
if (ctx_supports_vSync) wglSwapIntervalEXT(enabled);
|
||||
}
|
||||
|
@ -33,10 +33,10 @@
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define WINDOW_STATE_NORMAL 0
|
||||
#define WINDOW_STATE_MINIMISED 1
|
||||
#define WINDOW_STATE_MAXIMISED 2
|
||||
#define WINDOW_STATE_FULLSCREEN 3
|
||||
enum WINDOW_STATE {
|
||||
WINDOW_STATE_NORMAL, WINDOW_STATE_MINIMISED,
|
||||
WINDOW_STATE_MAXIMISED, WINDOW_STATE_FULLSCREEN,
|
||||
};
|
||||
|
||||
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
|
||||
struct GraphicsMode* mode, struct DisplayDevice* device);
|
||||
@ -81,7 +81,6 @@ void GLContext_Free(void);
|
||||
#define GLContext_IsInvalidAddress(ptr) (ptr == (void*)0 || ptr == (void*)1 || ptr == (void*)-1 || ptr == (void*)2)
|
||||
void* GLContext_GetAddress(const UChar* function);
|
||||
void GLContext_SwapBuffers(void);
|
||||
bool GLContext_GetVSync(void);
|
||||
void GLContext_SetVSync(bool enabled);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -668,7 +668,6 @@ GLXContext ctx_Handle;
|
||||
typedef int (*FN_GLXSWAPINTERVAL)(int interval);
|
||||
FN_GLXSWAPINTERVAL glXSwapIntervalSGI;
|
||||
bool ctx_supports_vSync;
|
||||
Int32 ctx_vsync_interval;
|
||||
|
||||
void GLContext_Init(struct GraphicsMode mode) {
|
||||
ctx_Handle = glXCreateContext(win_display, &win_visual, NULL, true);
|
||||
@ -712,18 +711,11 @@ void GLContext_SwapBuffers(void) {
|
||||
glXSwapBuffers(win_display, win_handle);
|
||||
}
|
||||
|
||||
bool GLContext_GetVSync(void) {
|
||||
return ctx_supports_vSync && ctx_vsync_interval;
|
||||
}
|
||||
|
||||
void GLContext_SetVSync(bool enabled) {
|
||||
if (!ctx_supports_vSync) return;
|
||||
|
||||
int result = glXSwapIntervalSGI(enabled);
|
||||
if (result != 0) {
|
||||
Platform_Log1("Set VSync failed, error: %i", &result);
|
||||
}
|
||||
ctx_vsync_interval = enabled;
|
||||
if (result != 0) {Platform_Log1("Set VSync failed, error: %i", &result); }
|
||||
}
|
||||
|
||||
static void GLContext_GetAttribs(struct GraphicsMode mode, Int32* attribs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user