summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2013-01-17 13:31:30 +0000
committerTim Angus <tim@ngus.net>2014-08-28 10:58:28 +0100
commitaf45b9f4614d7018146e68832de3bccb1c73f7e7 (patch)
treef563cc4f23e453d7d1fa13e6c71ffcb7e8ec7bcd
parent7426441a5bc9c4eaf28a7f64a22df8bdaa71162c (diff)
Use SDL 2 instead of SDL 1.2
-rw-r--r--Makefile10
-rw-r--r--src/client/cl_keys.c10
-rw-r--r--src/renderercommon/qgl.h252
-rw-r--r--src/renderercommon/tr_public.h2
-rw-r--r--src/renderergl1/tr_init.c4
-rw-r--r--src/renderergl1/tr_local.h11
-rw-r--r--src/renderergl2/tr_extensions.c2
-rw-r--r--src/sdl/sdl_gamma.c4
-rw-r--r--src/sdl/sdl_glimp.c411
-rw-r--r--src/sdl/sdl_input.c455
-rw-r--r--src/sdl/sdl_snd.c5
-rw-r--r--src/sys/sys_local.h8
-rw-r--r--src/sys/sys_main.c11
13 files changed, 664 insertions, 521 deletions
diff --git a/Makefile b/Makefile
index d43ead79..d23a27d2 100644
--- a/Makefile
+++ b/Makefile
@@ -258,15 +258,15 @@ ifneq ($(BUILD_CLIENT),0)
CURL_LIBS=$(shell pkg-config --silence-errors --libs libcurl)
OPENAL_CFLAGS=$(shell pkg-config --silence-errors --cflags openal)
OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal)
- SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
- SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl)
+ SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
+ SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl2)
FREETYPE_CFLAGS=$(shell pkg-config --silence-errors --cflags freetype2)
endif
# Use sdl-config if all else fails
ifeq ($(SDL_CFLAGS),)
- ifneq ($(call bin_path, sdl-config),)
- SDL_CFLAGS=$(shell sdl-config --cflags)
- SDL_LIBS=$(shell sdl-config --libs)
+ ifneq ($(call bin_path, sdl2-config),)
+ SDL_CFLAGS=$(shell sdl2-config --cflags)
+ SDL_LIBS=$(shell sdl2-config --libs)
endif
endif
endif
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c
index 0fbddd23..191d7fe4 100644
--- a/src/client/cl_keys.c
+++ b/src/client/cl_keys.c
@@ -438,11 +438,19 @@ void Field_KeyDownEvent( field_t *edit, int key ) {
switch ( key ) {
case K_DEL:
if ( edit->cursor < len ) {
- memmove( edit->buffer + edit->cursor,
+ memmove( edit->buffer + edit->cursor,
edit->buffer + edit->cursor + 1, len - edit->cursor );
}
break;
+ case K_BACKSPACE:
+ if ( edit->cursor > 0 ) {
+ memmove( edit->buffer + edit->cursor - 1,
+ edit->buffer + edit->cursor, len + 1 - edit->cursor );
+ edit->cursor--;
+ }
+ break;
+
case K_RIGHTARROW:
if ( edit->cursor < len ) {
edit->cursor++;
diff --git a/src/renderercommon/qgl.h b/src/renderercommon/qgl.h
index 14d388a4..6562f536 100644
--- a/src/renderercommon/qgl.h
+++ b/src/renderercommon/qgl.h
@@ -40,6 +40,256 @@ extern void (APIENTRYP qglMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat
extern void (APIENTRYP qglLockArraysEXT) (GLint first, GLsizei count);
extern void (APIENTRYP qglUnlockArraysEXT) (void);
+// GL_EXT_draw_range_elements
+extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+
+// GL_EXT_multi_draw_arrays
+extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, const GLint *, const GLsizei *, GLsizei);
+extern void (APIENTRY * qglMultiDrawElementsEXT) (GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei);
+
+// GL_ARB_shading_language_100
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
+#endif
+
+// GL_ARB_vertex_program
+extern void (APIENTRY * qglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+extern void (APIENTRY * qglVertexAttrib4fvARB) (GLuint, const GLfloat *);
+extern void (APIENTRY * qglVertexAttribPointerARB) (GLuint index, GLint size, GLenum type, GLboolean normalized,
+ GLsizei stride, const GLvoid * pointer);
+extern void (APIENTRY * qglEnableVertexAttribArrayARB) (GLuint index);
+extern void (APIENTRY * qglDisableVertexAttribArrayARB) (GLuint index);
+
+// GL_ARB_vertex_buffer_object
+extern void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer);
+extern void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers);
+extern void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers);
+extern GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer);
+extern void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage);
+extern void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data);
+extern void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data);
+extern void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params);
+extern void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params);
+
+// GL_ARB_shader_objects
+extern void (APIENTRY * qglDeleteObjectARB) (GLhandleARB obj);
+extern GLhandleARB(APIENTRY * qglGetHandleARB) (GLenum pname);
+extern void (APIENTRY * qglDetachObjectARB) (GLhandleARB containerObj, GLhandleARB attachedObj);
+extern GLhandleARB(APIENTRY * qglCreateShaderObjectARB) (GLenum shaderType);
+extern void (APIENTRY * qglShaderSourceARB) (GLhandleARB shaderObj, GLsizei count, const GLcharARB * *string,
+ const GLint * length);
+extern void (APIENTRY * qglCompileShaderARB) (GLhandleARB shaderObj);
+extern GLhandleARB(APIENTRY * qglCreateProgramObjectARB) (void);
+extern void (APIENTRY * qglAttachObjectARB) (GLhandleARB containerObj, GLhandleARB obj);
+extern void (APIENTRY * qglLinkProgramARB) (GLhandleARB programObj);
+extern void (APIENTRY * qglUseProgramObjectARB) (GLhandleARB programObj);
+extern void (APIENTRY * qglValidateProgramARB) (GLhandleARB programObj);
+extern void (APIENTRY * qglUniform1fARB) (GLint location, GLfloat v0);
+extern void (APIENTRY * qglUniform2fARB) (GLint location, GLfloat v0, GLfloat v1);
+extern void (APIENTRY * qglUniform3fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+extern void (APIENTRY * qglUniform4fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+extern void (APIENTRY * qglUniform1iARB) (GLint location, GLint v0);
+extern void (APIENTRY * qglUniform2iARB) (GLint location, GLint v0, GLint v1);
+extern void (APIENTRY * qglUniform3iARB) (GLint location, GLint v0, GLint v1, GLint v2);
+extern void (APIENTRY * qglUniform4iARB) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+extern void (APIENTRY * qglUniform1fvARB) (GLint location, GLsizei count, const GLfloat * value);
+extern void (APIENTRY * qglUniform2fvARB) (GLint location, GLsizei count, const GLfloat * value);
+extern void (APIENTRY * qglUniform3fvARB) (GLint location, GLsizei count, const GLfloat * value);
+extern void (APIENTRY * qglUniform4fvARB) (GLint location, GLsizei count, const GLfloat * value);
+extern void (APIENTRY * qglUniform2ivARB) (GLint location, GLsizei count, const GLint * value);
+extern void (APIENTRY * qglUniform3ivARB) (GLint location, GLsizei count, const GLint * value);
+extern void (APIENTRY * qglUniform4ivARB) (GLint location, GLsizei count, const GLint * value);
+extern void (APIENTRY * qglUniformMatrix2fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+extern void (APIENTRY * qglUniformMatrix3fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+extern void (APIENTRY * qglUniformMatrix4fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+extern void (APIENTRY * qglGetObjectParameterfvARB) (GLhandleARB obj, GLenum pname, GLfloat * params);
+extern void (APIENTRY * qglGetObjectParameterivARB) (GLhandleARB obj, GLenum pname, GLint * params);
+extern void (APIENTRY * qglGetInfoLogARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog);
+extern void (APIENTRY * qglGetAttachedObjectsARB) (GLhandleARB containerObj, GLsizei maxCount, GLsizei * count,
+ GLhandleARB * obj);
+extern GLint(APIENTRY * qglGetUniformLocationARB) (GLhandleARB programObj, const GLcharARB * name);
+extern void (APIENTRY * qglGetActiveUniformARB) (GLhandleARB programObj, GLuint index, GLsizei maxIndex, GLsizei * length,
+ GLint * size, GLenum * type, GLcharARB * name);
+extern void (APIENTRY * qglGetUniformfvARB) (GLhandleARB programObj, GLint location, GLfloat * params);
+extern void (APIENTRY * qglGetUniformivARB) (GLhandleARB programObj, GLint location, GLint * params);
+extern void (APIENTRY * qglGetShaderSourceARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source);
+
+// GL_ARB_vertex_shader
+extern void (APIENTRY * qglBindAttribLocationARB) (GLhandleARB programObj, GLuint index, const GLcharARB * name);
+extern void (APIENTRY * qglGetActiveAttribARB) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length,
+ GLint * size, GLenum * type, GLcharARB * name);
+extern GLint(APIENTRY * qglGetAttribLocationARB) (GLhandleARB programObj, const GLcharARB * name);
+
+// GL_ARB_texture_compression
+extern void (APIENTRY * qglCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
+ GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
+ GLint border, GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border,
+ GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format,
+ GLsizei imageSize, const GLvoid *data);
+extern void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod,
+ GLvoid *img);
+
+// GL_NVX_gpu_memory_info
+#ifndef GL_NVX_gpu_memory_info
+#define GL_NVX_gpu_memory_info
+#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
+#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
+#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
+#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
+#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
+#endif
+
+// GL_ATI_meminfo
+#ifndef GL_ATI_meminfo
+#define GL_ATI_meminfo
+#define GL_VBO_FREE_MEMORY_ATI 0x87FB
+#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
+#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
+#endif
+
+// GL_ARB_texture_float
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB 0x140B
+#endif
+
+// GL_EXT_framebuffer_object
+extern GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer);
+extern void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer);
+extern void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers);
+extern void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers);
+extern void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+extern void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params);
+extern GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer);
+extern void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer);
+extern void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
+extern void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers);
+extern GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target);
+extern void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
+ GLint level);
+extern void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
+ GLint level);
+extern void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
+ GLint level, GLint zoffset);
+extern void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget,
+ GLuint renderbuffer);
+extern void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
+extern void (APIENTRY * qglGenerateMipmapEXT)(GLenum target);
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#endif
+
+// GL_EXT_packed_depth_stencil
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_EXT_packed_depth_stencil
+#define GL_DEPTH_STENCIL_EXT 0x84F9
+#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
+#define GL_DEPTH24_STENCIL8_EXT 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
+#endif
+
+// GL_ARB_occlusion_query
+extern void (APIENTRY * qglGenQueriesARB)(GLsizei n, GLuint *ids);
+extern void (APIENTRY * qglDeleteQueriesARB)(GLsizei n, const GLuint *ids);
+extern GLboolean (APIENTRY * qglIsQueryARB)(GLuint id);
+extern void (APIENTRY * qglBeginQueryARB)(GLenum target, GLuint id);
+extern void (APIENTRY * qglEndQueryARB)(GLenum target);
+extern void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params);
+extern void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params);
+extern void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params);
+
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query
+#define GL_SAMPLES_PASSED_ARB 0x8914
+#define GL_QUERY_COUNTER_BITS_ARB 0x8864
+#define GL_CURRENT_QUERY_ARB 0x8865
+#define GL_QUERY_RESULT_ARB 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
+#endif
//===========================================================================
@@ -382,7 +632,7 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
// GL_EXT_multi_draw_arrays
-extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, GLint *, GLsizei *, GLsizei);
+extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, const GLint *, const GLsizei *, GLsizei);
extern void (APIENTRY * qglMultiDrawElementsEXT) (GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei);
// GL_ARB_shading_language_100
diff --git a/src/renderercommon/tr_public.h b/src/renderercommon/tr_public.h
index 59ee014b..af422b31 100644
--- a/src/renderercommon/tr_public.h
+++ b/src/renderercommon/tr_public.h
@@ -169,7 +169,7 @@ typedef struct {
void (*CL_WriteAVIVideoFrame)( const byte *buffer, int size );
// input event handling
- void (*IN_Init)( void );
+ void (*IN_Init)( void *windowData );
void (*IN_Shutdown)( void );
void (*IN_Restart)( void );
diff --git a/src/renderergl1/tr_init.c b/src/renderergl1/tr_init.c
index 8d8b1f5e..fbaa1c37 100644
--- a/src/renderergl1/tr_init.c
+++ b/src/renderergl1/tr_init.c
@@ -46,6 +46,8 @@ cvar_t *r_ignoreFastPath;
cvar_t *r_verbose;
cvar_t *r_ignore;
+cvar_t *r_displayRefresh;
+
cvar_t *r_detailTextures;
cvar_t *r_znear;
@@ -973,6 +975,8 @@ void R_Register( void )
//
// temporary latched variables that can only change over a restart
//
+ r_displayRefresh = ri.Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH );
+ ri.Cvar_CheckRange( r_displayRefresh, 0, 200, qtrue );
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT );
r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH );
r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH );
diff --git a/src/renderergl1/tr_local.h b/src/renderergl1/tr_local.h
index 3eabb7a2..cbca2cb4 100644
--- a/src/renderergl1/tr_local.h
+++ b/src/renderergl1/tr_local.h
@@ -1007,6 +1007,17 @@ extern cvar_t *r_nocurves;
extern cvar_t *r_showcluster;
extern cvar_t *r_gamma;
+extern cvar_t *r_displayRefresh; // optional display refresh option
+extern cvar_t *r_ignorehwgamma; // overrides hardware gamma capabilities
+
+extern cvar_t *r_allowExtensions; // global enable/disable of OpenGL extensions
+extern cvar_t *r_ext_compressed_textures; // these control use of specific extensions
+extern cvar_t *r_ext_multitexture;
+extern cvar_t *r_ext_compiled_vertex_array;
+extern cvar_t *r_ext_texture_env_add;
+
+extern cvar_t *r_ext_texture_filter_anisotropic;
+extern cvar_t *r_ext_max_anisotropy;
extern cvar_t *r_nobind; // turns off binding to appropriate textures
extern cvar_t *r_singleShader; // make most world faces use default shader
diff --git a/src/renderergl2/tr_extensions.c b/src/renderergl2/tr_extensions.c
index 4e73f66f..c7286ac7 100644
--- a/src/renderergl2/tr_extensions.c
+++ b/src/renderergl2/tr_extensions.c
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
// GL_EXT_multi_draw_arrays
-void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
void (APIENTRY * qglMultiDrawElementsEXT) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount);
// GL_ARB_vertex_shader
diff --git a/src/sdl/sdl_gamma.c b/src/sdl/sdl_gamma.c
index 0925a1a2..0029db18 100644
--- a/src/sdl/sdl_gamma.c
+++ b/src/sdl/sdl_gamma.c
@@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../renderercommon/tr_common.h"
#include "../qcommon/qcommon.h"
+extern SDL_Window *SDL_window;
+
/*
=================
GLimp_SetGamma
@@ -87,6 +89,6 @@ void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned
}
}
- SDL_SetGammaRamp(table[0], table[1], table[2]);
+ SDL_SetWindowGammaRamp(SDL_window, table[0], table[1], table[2]);
}
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c
index c5a238a6..da29f704 100644
--- a/src/sdl/sdl_glimp.c
+++ b/src/sdl/sdl_glimp.c
@@ -36,20 +36,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../sys/sys_local.h"
#include "sdl_icon.h"
-/* Just hack it for now. */
-#ifdef MACOS_X
-#include <OpenGL/OpenGL.h>
-typedef CGLContextObj QGLContext;
-#define GLimp_GetCurrentContext() CGLGetCurrentContext()
-#define GLimp_SetCurrentContext(ctx) CGLSetCurrentContext(ctx)
-#else
-typedef void *QGLContext;
-#define GLimp_GetCurrentContext() (NULL)
-#define GLimp_SetCurrentContext(ctx)
-#endif
-
-static QGLContext opengl_context;
-
typedef enum
{
RSERR_OK,
@@ -60,8 +46,8 @@ typedef enum
RSERR_UNKNOWN
} rserr_t;
-static SDL_Surface *screen = NULL;
-static const SDL_VideoInfo *videoInfo = NULL;
+SDL_Window *SDL_window = NULL;
+static SDL_GLContext *SDL_glContext = NULL;
cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obtained
cvar_t *r_allowResize; // make window resizable
@@ -87,7 +73,6 @@ void GLimp_Shutdown( void )
ri.IN_Shutdown();
SDL_QuitSubSystem( SDL_INIT_VIDEO );
- screen = NULL;
glConfig.displayAspect = oldDisplayAspect;
}
@@ -99,9 +84,9 @@ GLimp_Minimize
Minimize the game so that user is back at the desktop
===============
*/
-void GLimp_Minimize(void)
+void GLimp_Minimize( void )
{
- SDL_WM_IconifyWindow();
+ SDL_MinimizeWindow( SDL_window );
}
@@ -122,8 +107,8 @@ GLimp_CompareModes
static int GLimp_CompareModes( const void *a, const void *b )
{
const float ASPECT_EPSILON = 0.001f;
- SDL_Rect *modeA = *(SDL_Rect **)a;
- SDL_Rect *modeB = *(SDL_Rect **)b;
+ SDL_Rect *modeA = (SDL_Rect *)&a;
+ SDL_Rect *modeB = (SDL_Rect *)&b;
float aspectA = (float)modeA->w / (float)modeA->h;
float aspectB = (float)modeB->w / (float)modeB->h;
int areaA = modeA->w * modeA->h;
@@ -148,38 +133,52 @@ GLimp_DetectAvailableModes
*/
static void GLimp_DetectAvailableModes(void)
{
- char buf[ MAX_STRING_CHARS ] = { 0 };
- SDL_Rect **modes;
- int numModes;
int i;
+ char buf[ MAX_STRING_CHARS ] = { 0 };
+ SDL_Rect modes[ 128 ];
+ int numModes = 0;
- modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN );
+ int display = SDL_GetWindowDisplayIndex( SDL_window );
+ SDL_DisplayMode windowMode;
- if( !modes )
+ if( SDL_GetWindowDisplayMode( SDL_window, &windowMode ) < 0 )
{
- ri.Printf( PRINT_WARNING, "Can't get list of available modes\n" );
+ ri.Printf( PRINT_WARNING, "Couldn't get window display mode, no resolutions detected\n" );
return;
}
- if( modes == (SDL_Rect **)-1 )
+ for( i = 0; i < SDL_GetNumDisplayModes( display ); i++ )
{
- ri.Printf( PRINT_ALL, "Display supports any resolution\n" );
- return; // can set any resolution
- }
+ SDL_DisplayMode mode;
- for( numModes = 0; modes[ numModes ]; numModes++ );
+ if( SDL_GetDisplayMode( display, i, &mode ) < 0 )
+ continue;
+
+ if( !mode.w || !mode.h )
+ {
+ ri.Printf( PRINT_ALL, "Display supports any resolution\n" );
+ return;
+ }
+
+ if( windowMode.format != mode.format )
+ continue;
+
+ modes[ numModes ].w = mode.w;
+ modes[ numModes ].h = mode.h;
+ numModes++;
+ }
if( numModes > 1 )
- qsort( modes, numModes, sizeof( SDL_Rect* ), GLimp_CompareModes );
+ qsort( modes, numModes, sizeof( SDL_Rect ), GLimp_CompareModes );
for( i = 0; i < numModes; i++ )
{
- const char *newModeString = va( "%ux%u ", modes[ i ]->w, modes[ i ]->h );
+ const char *newModeString = va( "%ux%u ", modes[ i ].w, modes[ i ].h );
if( strlen( newModeString ) < (int)sizeof( buf ) - strlen( buf ) )
Q_strcat( buf, sizeof( buf ), newModeString );
else
- ri.Printf( PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[i]->w, modes[i]->h );
+ ri.Printf( PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[ i ].w, modes[ i ].h );
}
if( *buf )
@@ -200,56 +199,71 @@ GLimp_SetMode
*/
static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen, qboolean noborder )
{
- const char* glstring;
- int sdlcolorbits;
- int colorbits, depthbits, stencilbits;
- int tcolorbits, tdepthbits, tstencilbits;
+ const char *glstring;
+ int perChannelColorBits;
+ int colorBits, depthBits, stencilBits;
int samples;
int i = 0;
- SDL_Surface *vidscreen = NULL;
- Uint32 flags = SDL_OPENGL;
+ SDL_Surface *icon = NULL;
+ Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
+ SDL_DisplayMode desktopMode;
+ int display = 0;
+ int x = 0, y = 0;
ri.Printf( PRINT_ALL, "Initializing OpenGL display\n");
if ( r_allowResize->integer )
- flags |= SDL_RESIZABLE;
+ flags |= SDL_WINDOW_RESIZABLE;
+
+ icon = SDL_CreateRGBSurfaceFrom(
+ (void *)CLIENT_WINDOW_ICON.pixel_data,
+ CLIENT_WINDOW_ICON.width,
+ CLIENT_WINDOW_ICON.height,
+ CLIENT_WINDOW_ICON.bytes_per_pixel * 8,
+ CLIENT_WINDOW_ICON.bytes_per_pixel * CLIENT_WINDOW_ICON.width,
+#ifdef Q3_LITTLE_ENDIAN
+ 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
+#else
+ 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
+#endif
+ );
+
+ // If a window exists, note its display index
+ if( SDL_window != NULL )
+ display = SDL_GetWindowDisplayIndex( SDL_window );
- if( videoInfo == NULL )
+ if( SDL_GetDesktopDisplayMode( display, &desktopMode ) == 0 )
{
- static SDL_VideoInfo sVideoInfo;
- static SDL_PixelFormat sPixelFormat;
+ glConfig.displayAspect = (float)desktopMode.w / (float)desktopMode.h;
- videoInfo = SDL_GetVideoInfo( );
+ ri.Printf( PRINT_ALL, "Display aspect: %.3f\n", glConfig.displayAspect );
+ }
+ else
+ {
+ Com_Memset( &desktopMode, 0, sizeof( SDL_DisplayMode ) );
- // Take a copy of the videoInfo
- Com_Memcpy( &sPixelFormat, videoInfo->vfmt, sizeof( SDL_PixelFormat ) );
- sPixelFormat.palette = NULL; // Should already be the case
- Com_Memcpy( &sVideoInfo, videoInfo, sizeof( SDL_VideoInfo ) );
- sVideoInfo.vfmt = &sPixelFormat;
- videoInfo = &sVideoInfo;
+ ri.Printf( PRINT_ALL,
+ "Cannot determine display aspect, assuming 1.333\n" );
+ }
- if( videoInfo->current_h > 0 )
+ if( !failSafe )
+ {
+ // use desktop video resolution
+ if( desktopMode.h > 0 )
{
- // Guess the display aspect ratio through the desktop resolution
- // by assuming (relatively safely) that it is set at or close to
- // the display's native aspect ratio
- glConfig.displayAspect = (float)videoInfo->current_w / (float)videoInfo->current_h;
-
- ri.Printf( PRINT_ALL, "Estimated display aspect: %.3f\n", glConfig.displayAspect );
+ glConfig.vidWidth = desktopMode.w;
+ glConfig.vidHeight = desktopMode.h;
}
else
{
+ glConfig.vidWidth = 640;
+ glConfig.vidHeight = 480;
ri.Printf( PRINT_ALL,
- "Cannot estimate display aspect, assuming 1.333\n" );
+ "Cannot determine display resolution, assuming 640x480\n" );
}
- }
- if( !failSafe )
- {
- glConfig.vidWidth = r_width->integer;
- glConfig.vidHeight = r_height->integer;
- glConfig.windowAspect = r_width->value /
- ( r_height->value * r_pixelAspect->value );
+ glConfig.windowAspect = (float)glConfig.vidWidth /
+ ( (float)glConfig.vidHeight * r_pixelAspect->value );
}
else if( glConfig.vidWidth != R_FAILSAFE_WIDTH &&
glConfig.vidHeight != R_FAILSAFE_HEIGHT )
@@ -266,35 +280,60 @@ static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen, qboolean nobor
ri.Printf (PRINT_ALL, "...setting mode %dx%d\n", glConfig.vidWidth, glConfig.vidHeight);
- if (fullscreen)
+ // Center window
+ if( r_centerWindow->integer && !fullscreen )
+ {
+ x = ( desktopMode.w / 2 ) - ( glConfig.vidWidth / 2 );
+ y = ( desktopMode.h / 2 ) - ( glConfig.vidHeight / 2 );
+ }
+
+ // Destroy existing state if it exists
+ if( SDL_glContext != NULL )
+ {
+ SDL_GL_DeleteContext( SDL_glContext );
+ SDL_glContext = NULL;
+ }
+
+ if( SDL_window != NULL )
+ {
+ SDL_GetWindowPosition( SDL_window, &x, &y );
+ ri.Printf( PRINT_DEVELOPER, "Existing window at %dx%d before being destroyed\n", x, y );
+ SDL_DestroyWindow( SDL_window );
+ SDL_window = NULL;
+ }
+
+ if( fullscreen )
{
- flags |= SDL_FULLSCREEN;
+ flags |= SDL_WINDOW_FULLSCREEN;
glConfig.isFullscreen = qtrue;
}
else
{
- if (noborder)
- flags |= SDL_NOFRAME;
+ if( noborder )
+ flags |= SDL_WINDOW_BORDERLESS;
glConfig.isFullscreen = qfalse;
}
- colorbits = r_colorbits->value;
- if ((!colorbits) || (colorbits >= 32))
- colorbits = 24;
+ colorBits = r_colorbits->value;
+ if ((!colorBits) || (colorBits >= 32))
+ colorBits = 24;
if (!r_depthbits->value)
- depthbits = 24;
+ depthBits = 24;
else
- depthbits = r_depthbits->value;
- stencilbits = r_stencilbits->value;
+ depthBits = r_depthbits->value;
+
+ stencilBits = r_stencilbits->value;
samples = r_ext_multisample->value;
for (i = 0; i < 16; i++)
{
+ int testColorBits, testDepthBits, testStencilBits;
+
// 0 - default
- // 1 - minus colorbits
- // 2 - minus depthbits
+ // 1 - minus colorBits
+ // 2 - minus depthBits
// 3 - minus stencil
if ((i % 4) == 0 && i)
{
@@ -302,67 +341,68 @@ static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen, qboolean nobor
switch (i / 4)
{
case 2 :
- if (colorbits == 24)
- colorbits = 16;
+ if (colorBits == 24)
+ colorBits = 16;
break;
case 1 :
- if (depthbits == 24)
- depthbits = 16;
- else if (depthbits == 16)
- depthbits = 8;
+ if (depthBits == 24)
+ depthBits = 16;
+ else if (depthBits == 16)
+ depthBits = 8;
case 3 :
- if (stencilbits == 24)
- stencilbits = 16;
- else if (stencilbits == 16)
- stencilbits = 8;
+ if (stencilBits == 24)
+ stencilBits = 16;
+ else if (stencilBits == 16)
+ stencilBits = 8;
}
}
- tcolorbits = colorbits;
- tdepthbits = depthbits;
- tstencilbits = stencilbits;
+ testColorBits = colorBits;
+ testDepthBits = depthBits;
+ testStencilBits = stencilBits;
if ((i % 4) == 3)
- { // reduce colorbits
- if (tcolorbits == 24)
- tcolorbits = 16;
+ { // reduce colorBits
+ if (testColorBits == 24)
+ testColorBits = 16;
}
if ((i % 4) == 2)
- { // reduce depthbits
- if (tdepthbits == 24)
- tdepthbits = 16;
- else if (tdepthbits == 16)
- tdepthbits = 8;
+ { // reduce depthBits
+ if (testDepthBits == 24)
+ testDepthBits = 16;
+ else if (testDepthBits == 16)
+ testDepthBits = 8;
}
if ((i % 4) == 1)
- { // reduce stencilbits
- if (tstencilbits == 24)
- tstencilbits = 16;
- else if (tstencilbits == 16)
- tstencilbits = 8;
+ { // reduce stencilBits
+ if (testStencilBits == 24)
+ testStencilBits = 16;
+ else if (testStencilBits == 16)
+ testStencilBits = 8;
else
- tstencilbits = 0;
+ testStencilBits = 0;
}
- sdlcolorbits = 4;
- if (tcolorbits == 24)
- sdlcolorbits = 8;
+ if (testColorBits == 24)
+ perChannelColorBits = 8;
+ else
+ perChannelColorBits = 4;
#ifdef __sgi /* Fix for SGIs grabbing too many bits of color */
- if (sdlcolorbits == 4)
- sdlcolorbits = 0; /* Use minimum size for 16-bit color */
+ if (perChannelColorBits == 4)
+ perChannelColorBits = 0; /* Use minimum size for 16-bit color */
/* Need alpha or else SGIs choose 36+ bit RGB mode */
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 1);
#endif
- SDL_GL_SetAttribute( SDL_GL_RED_SIZE, sdlcolorbits );
- SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, sdlcolorbits );
- SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, sdlcolorbits );
- SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, tdepthbits );
- SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, tstencilbits );
+ SDL_GL_SetAttribute( SDL_GL_RED_SIZE, perChannelColorBits );
+ SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, perChannelColorBits );
+ SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, perChannelColorBits );
+ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, testDepthBits );
+ SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, testStencilBits );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
@@ -380,70 +420,69 @@ static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen, qboolean nobor
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
-#if 0 // See http://bugzilla.icculus.org/show_bug.cgi?id=3526
// If not allowing software GL, demand accelerated
if( !r_allowSoftwareGL->integer )
+ SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
+
+ if( ( SDL_window = SDL_CreateWindow( CLIENT_WINDOW_TITLE, x, y,
+ glConfig.vidWidth, glConfig.vidHeight, flags ) ) == 0 )
+ {
+ ri.Printf( PRINT_DEVELOPER, "SDL_CreateWindow failed: %s\n", SDL_GetError( ) );
+ continue;
+ }
+
+ if( fullscreen )
{
- if( SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ) < 0 )
+ SDL_DisplayMode mode;
+
+ switch( testColorBits )
{
- ri.Printf( PRINT_ALL, "Unable to guarantee accelerated "
- "visual with libSDL < 1.2.10\n" );
+ case 16: mode.format = SDL_PIXELFORMAT_RGB565; break;
+ case 24: mode.format = SDL_PIXELFORMAT_RGB24; break;
+ default: ri.Printf( PRINT_DEVELOPER, "testColorBits is %d, can't fullscreen\n", testColorBits ); continue;
+ }
+
+ mode.w = glConfig.vidWidth;
+ mode.h = glConfig.vidHeight;
+ mode.refresh_rate = glConfig.displayFrequency = ri.Cvar_VariableIntegerValue( "r_displayRefresh" );
+ mode.driverdata = NULL;
+
+ if( SDL_SetWindowDisplayMode( SDL_window, &mode ) < 0 )
+ {
+ ri.Printf( PRINT_DEVELOPER, "SDL_SetWindowDisplayMode failed: %s\n", SDL_GetError( ) );
+ continue;
}
}
-#endif
- if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval->integer ) < 0 )
- ri.Printf( PRINT_ALL, "r_swapInterval requires libSDL >= 1.2.10\n" );
+ SDL_SetWindowTitle( SDL_window, CLIENT_WINDOW_TITLE );
+ SDL_SetWindowIcon( SDL_window, icon );
-#ifdef USE_ICON
+ if( ( SDL_glContext = SDL_GL_CreateContext( SDL_window ) ) == NULL )
{
- SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
- (void *)CLIENT_WINDOW_ICON.pixel_data,
- CLIENT_WINDOW_ICON.width,
- CLIENT_WINDOW_ICON.height,
- CLIENT_WINDOW_ICON.bytes_per_pixel * 8,
- CLIENT_WINDOW_ICON.bytes_per_pixel * CLIENT_WINDOW_ICON.width,
-#ifdef Q3_LITTLE_ENDIAN
- 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
-#else
- 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
-#endif
- );
-
- SDL_WM_SetIcon( icon, NULL );
- SDL_FreeSurface( icon );
+ ri.Printf( PRINT_DEVELOPER, "SDL_GL_CreateContext failed: %s\n", SDL_GetError( ) );
+ continue;
}
-#endif
-
- SDL_WM_SetCaption(CLIENT_WINDOW_TITLE, CLIENT_WINDOW_MIN_TITLE);
- SDL_ShowCursor(0);
- if (!(vidscreen = SDL_SetVideoMode(glConfig.vidWidth, glConfig.vidHeight, colorbits, flags)))
+ if( SDL_GL_MakeCurrent( SDL_window, SDL_glContext ) < 0 )
{
- ri.Printf( PRINT_DEVELOPER, "SDL_SetVideoMode failed: %s\n", SDL_GetError( ) );
+ ri.Printf( PRINT_DEVELOPER, "SDL_GL_MakeCurrent failed: %s\n", SDL_GetError( ) );
continue;
}
- opengl_context = GLimp_GetCurrentContext();
+ SDL_GL_SetSwapInterval( r_swapInterval->integer );
- ri.Printf( PRINT_ALL, "Using %d/%d/%d Color bits, %d depth, %d stencil display.\n",
- sdlcolorbits, sdlcolorbits, sdlcolorbits, tdepthbits, tstencilbits);
+ glConfig.colorBits = testColorBits;
+ glConfig.depthBits = testDepthBits;
+ glConfig.stencilBits = testStencilBits;
- glConfig.colorBits = tcolorbits;
- glConfig.depthBits = tdepthbits;
- glConfig.stencilBits = tstencilbits;
+ ri.Printf( PRINT_ALL, "Using %d color bits, %d depth, %d stencil display.\n",
+ glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );
break;
}
- GLimp_DetectAvailableModes();
+ SDL_FreeSurface( icon );
- if (!vidscreen)
- {
- ri.Printf( PRINT_ALL, "Couldn't get a visual\n" );
- return RSERR_INVALID_MODE;
- }
-
- screen = vidscreen;
+ GLimp_DetectAvailableModes();
glstring = (char *) qglGetString (GL_RENDERER);
ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glstring );
@@ -462,16 +501,15 @@ static qboolean GLimp_StartDriverAndSetMode( qboolean failSafe, qboolean fullscr
if (!SDL_WasInit(SDL_INIT_VIDEO))
{
- char driverName[ 64 ];
+ const char *driverName;
if (SDL_Init(SDL_INIT_VIDEO) == -1)
{
- ri.Printf( PRINT_ALL, "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n",
- SDL_GetError());
+ ri.Printf( PRINT_ALL, "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n", SDL_GetError());
return qfalse;
}
- SDL_VideoDriverName( driverName, sizeof( driverName ) - 1 );
+ driverName = SDL_GetCurrentVideoDriver( );
ri.Printf( PRINT_ALL, "SDL using driver \"%s\"\n", driverName );
ri.Cvar_Set( "r_sdlDriver", driverName );
}
@@ -688,6 +726,8 @@ of OpenGL
*/
void GLimp_Init( void )
{
+ ri.Printf( PRINT_DEVELOPER, "Glimp_Init( )\n" );
+
r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH );
r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM );
r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE | CVAR_LATCH );
@@ -702,8 +742,6 @@ void GLimp_Init( void )
ri.Cvar_Set( "com_abnormalExit", "0" );
}
- ri.Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" );
-
ri.Sys_GLimpInit( );
// Create the window and set up the context
@@ -727,13 +765,15 @@ success:
// This values force the UI to disable driver selection
glConfig.driverType = GLDRV_ICD;
glConfig.hardwareType = GLHW_GENERIC;
- glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0;
+
+ // FIXME No SDL_SetGamma in SDL2?
+ /*glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0;*/
// Mysteriously, if you use an NVidia graphics card and multiple monitors,
// SDL_SetGamma will incorrectly return false... the first time; ask
// again and you get the correct answer. This is a suspected driver bug, see
// http://bugzilla.icculus.org/show_bug.cgi?id=4316
- glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0;
+ /*glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0;*/
if ( -1 == r_ignorehwgamma->integer)
glConfig.deviceSupportsGamma = 1;
@@ -755,7 +795,7 @@ success:
ri.Cvar_Get( "r_availableModes", "", CVAR_ROM );
// This depends on SDL_INIT_VIDEO, hence having it here
- ri.IN_Init( );
+ ri.IN_Init( SDL_window );
}
@@ -771,37 +811,32 @@ void GLimp_EndFrame( void )
// don't flip if drawing to front buffer
if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
{
- SDL_GL_SwapBuffers();
+ SDL_GL_SwapWindow( SDL_window );
}
if( r_fullscreen->modified )
{
- qboolean fullscreen;
- qboolean needToToggle = qtrue;
+ int fullscreen;
+ qboolean needToToggle;
qboolean sdlToggled = qfalse;
- SDL_Surface *s = SDL_GetVideoSurface( );
- if( s )
- {
- // Find out the current state
- fullscreen = !!( s->flags & SDL_FULLSCREEN );
-
- if( r_fullscreen->integer && ri.Cvar_VariableIntegerValue( "in_nograb" ) )
- {
- ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n");
- ri.Cvar_Set( "r_fullscreen", "0" );
- r_fullscreen->modified = qfalse;
- }
+ // Find out the current state
+ fullscreen = !!( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_FULLSCREEN );
- // Is the state we want different from the current state?
- needToToggle = !!r_fullscreen->integer != fullscreen;
-
- if( needToToggle )
- sdlToggled = SDL_WM_ToggleFullScreen( s );
+ if( r_fullscreen->integer && ri.Cvar_VariableIntegerValue( "in_nograb" ) )
+ {
+ ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n");
+ ri.Cvar_Set( "r_fullscreen", "0" );
+ r_fullscreen->modified = qfalse;
}
+ // Is the state we want different from the current state?
+ needToToggle = !!r_fullscreen->integer != fullscreen;
+
if( needToToggle )
{
+ sdlToggled = SDL_SetWindowFullscreen( SDL_window, r_fullscreen->integer ) >= 0;
+
// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
if( !sdlToggled )
ri.Cmd_ExecuteText(EXEC_APPEND, "vid_restart\n");
diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c
index e47034fd..858b8d6e 100644
--- a/src/sdl/sdl_input.c
+++ b/src/sdl/sdl_input.c
@@ -34,33 +34,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../client/client.h"
#include "../sys/sys_local.h"
-#ifdef MACOS_X
-// Mouse acceleration needs to be disabled
-#define MACOS_X_ACCELERATION_HACK
-// Cursor needs hack to hide
-#define MACOS_X_CURSOR_HACK
-#endif
-
-#ifdef MACOS_X_ACCELERATION_HACK
-#include <IOKit/IOTypes.h>
-#include <IOKit/hidsystem/IOHIDLib.h>
-#include <IOKit/hidsystem/IOHIDParameter.h>
-#include <IOKit/hidsystem/event_status_driver.h>
-#endif
-
static cvar_t *in_keyboardDebug = NULL;
static SDL_Joystick *stick = NULL;
static qboolean mouseAvailable = qfalse;
static qboolean mouseActive = qfalse;
-static qboolean keyRepeatEnabled = qfalse;
static cvar_t *in_mouse = NULL;
-#ifdef MACOS_X_ACCELERATION_HACK
-static cvar_t *in_disablemacosxmouseaccel = NULL;
-static double originalMouseSpeed = -1.0;
-#endif
static cvar_t *in_nograb;
static cvar_t *in_joystick = NULL;
@@ -71,6 +52,8 @@ static cvar_t *in_joystickUseAnalog = NULL;
static int vidRestartTime = 0;
+static SDL_Window *SDL_window = NULL;
+
#define CTRL(a) ((a)-'a'+1)
/*
@@ -78,7 +61,7 @@ static int vidRestartTime = 0;
IN_PrintKey
===============
*/
-static void IN_PrintKey( const SDL_keysym *keysym, keyNum_t key, qboolean down )
+static void IN_PrintKey( const SDL_Keysym *keysym, keyNum_t key, qboolean down )
{
if( down )
Com_Printf( "+ " );
@@ -94,24 +77,14 @@ static void IN_PrintKey( const SDL_keysym *keysym, keyNum_t key, qboolean down )
if( keysym->mod & KMOD_RCTRL ) Com_Printf( " KMOD_RCTRL" );
if( keysym->mod & KMOD_LALT ) Com_Printf( " KMOD_LALT" );
if( keysym->mod & KMOD_RALT ) Com_Printf( " KMOD_RALT" );
- if( keysym->mod & KMOD_LMETA ) Com_Printf( " KMOD_LMETA" );
- if( keysym->mod & KMOD_RMETA ) Com_Printf( " KMOD_RMETA" );
+ if( keysym->mod & KMOD_LGUI ) Com_Printf( " KMOD_LGUI" );
+ if( keysym->mod & KMOD_RGUI ) Com_Printf( " KMOD_RGUI" );
if( keysym->mod & KMOD_NUM ) Com_Printf( " KMOD_NUM" );
if( keysym->mod & KMOD_CAPS ) Com_Printf( " KMOD_CAPS" );
if( keysym->mod & KMOD_MODE ) Com_Printf( " KMOD_MODE" );
if( keysym->mod & KMOD_RESERVED ) Com_Printf( " KMOD_RESERVED" );
- Com_Printf( " Q:0x%02x(%s)", key, Key_KeynumToString( key ) );
-
- if( keysym->unicode )
- {
- Com_Printf( " U:0x%02x", keysym->unicode );
-
- if( keysym->unicode > ' ' && keysym->unicode < '~' )
- Com_Printf( "(%c)", (char)keysym->unicode );
- }
-
- Com_Printf( "\n" );
+ Com_Printf( " Q:0x%02x(%s)\n", key, Key_KeynumToString( key ) );
}
#define MAX_CONSOLE_KEYS 16
@@ -119,6 +92,7 @@ static void IN_PrintKey( const SDL_keysym *keysym, keyNum_t key, qboolean down )
/*
===============
IN_IsConsoleKey
+//FIXME: SDL 1.3 allow scancode based console key selection
===============
*/
static qboolean IN_IsConsoleKey( keyNum_t key, const unsigned char character )
@@ -212,183 +186,107 @@ static qboolean IN_IsConsoleKey( keyNum_t key, const unsigned char character )
IN_TranslateSDLToQ3Key
===============
*/
-static const char *IN_TranslateSDLToQ3Key( SDL_keysym *keysym,
- keyNum_t *key, qboolean down )
+static keyNum_t IN_TranslateSDLToQ3Key( SDL_Keysym *keysym, qboolean down )
{
- static unsigned char buf[ 2 ] = { '\0', '\0' };
-
- *buf = '\0';
- *key = 0;
+ keyNum_t key = 0;
if( keysym->sym >= SDLK_SPACE && keysym->sym < SDLK_DELETE )
{
// These happen to match the ASCII chars
- *key = (int)keysym->sym;
+ key = (int)keysym->sym;
}
else
{
switch( keysym->sym )
{
- case SDLK_PAGEUP: *key = K_PGUP; break;
- case SDLK_KP9: *key = K_KP_PGUP; break;
- case SDLK_PAGEDOWN: *key = K_PGDN; break;
- case SDLK_KP3: *key = K_KP_PGDN; break;
- case SDLK_KP7: *key = K_KP_HOME; break;
- case SDLK_HOME: *key = K_HOME; break;
- case SDLK_KP1: *key = K_KP_END; break;
- case SDLK_END: *key = K_END; break;
- case SDLK_KP4: *key = K_KP_LEFTARROW; break;
- case SDLK_LEFT: *key = K_LEFTARROW; break;
- case SDLK_KP6: *key = K_KP_RIGHTARROW; break;
- case SDLK_RIGHT: *key = K_RIGHTARROW; break;
- case SDLK_KP2: *key = K_KP_DOWNARROW; break;
- case SDLK_DOWN: *key = K_DOWNARROW; break;
- case SDLK_KP8: *key = K_KP_UPARROW; break;
- case SDLK_UP: *key = K_UPARROW; break;
- case SDLK_ESCAPE: *key = K_ESCAPE; break;
- case SDLK_KP_ENTER: *key = K_KP_ENTER; break;
- case SDLK_RETURN: *key = K_ENTER; break;
- case SDLK_TAB: *key = K_TAB; break;
- case SDLK_F1: *key = K_F1; break;
- case SDLK_F2: *key = K_F2; break;
- case SDLK_F3: *key = K_F3; break;
- case SDLK_F4: *key = K_F4; break;
- case SDLK_F5: *key = K_F5; break;
- case SDLK_F6: *key = K_F6; break;
- case SDLK_F7: *key = K_F7; break;
- case SDLK_F8: *key = K_F8; break;
- case SDLK_F9: *key = K_F9; break;
- case SDLK_F10: *key = K_F10; break;
- case SDLK_F11: *key = K_F11; break;
- case SDLK_F12: *key = K_F12; break;
- case SDLK_F13: *key = K_F13; break;
- case SDLK_F14: *key = K_F14; break;
- case SDLK_F15: *key = K_F15; break;
-
- case SDLK_BACKSPACE: *key = K_BACKSPACE; break;
- case SDLK_KP_PERIOD: *key = K_KP_DEL; break;
- case SDLK_DELETE: *key = K_DEL; break;
- case SDLK_PAUSE: *key = K_PAUSE; break;
+ case SDLK_PAGEUP: key = K_PGUP; break;
+ case SDLK_KP_9: key = K_KP_PGUP; break;
+ case SDLK_PAGEDOWN: key = K_PGDN; break;
+ case SDLK_KP_3: key = K_KP_PGDN; break;
+ case SDLK_KP_7: key = K_KP_HOME; break;
+ case SDLK_HOME: key = K_HOME; break;
+ case SDLK_KP_1: key = K_KP_END; break;
+ case SDLK_END: key = K_END; break;
+ case SDLK_KP_4: key = K_KP_LEFTARROW; break;
+ case SDLK_LEFT: key = K_LEFTARROW; break;
+ case SDLK_KP_6: key = K_KP_RIGHTARROW; break;
+ case SDLK_RIGHT: key = K_RIGHTARROW; break;
+ case SDLK_KP_2: key = K_KP_DOWNARROW; break;
+ case SDLK_DOWN: key = K_DOWNARROW; break;
+ case SDLK_KP_8: key = K_KP_UPARROW; break;
+ case SDLK_UP: key = K_UPARROW; break;
+ case SDLK_ESCAPE: key = K_ESCAPE; break;
+ case SDLK_KP_ENTER: key = K_KP_ENTER; break;
+ case SDLK_RETURN: key = K_ENTER; break;
+ case SDLK_TAB: key = K_TAB; break;
+ case SDLK_F1: key = K_F1; break;
+ case SDLK_F2: key = K_F2; break;
+ case SDLK_F3: key = K_F3; break;
+ case SDLK_F4: key = K_F4; break;
+ case SDLK_F5: key = K_F5; break;
+ case SDLK_F6: key = K_F6; break;
+ case SDLK_F7: key = K_F7; break;
+ case SDLK_F8: key = K_F8; break;
+ case SDLK_F9: key = K_F9; break;
+ case SDLK_F10: key = K_F10; break;
+ case SDLK_F11: key = K_F11; break;
+ case SDLK_F12: key = K_F12; break;
+ case SDLK_F13: key = K_F13; break;
+ case SDLK_F14: key = K_F14; break;
+ case SDLK_F15: key = K_F15; break;
+
+ case SDLK_BACKSPACE: key = K_BACKSPACE; break;
+ case SDLK_KP_PERIOD: key = K_KP_DEL; break;
+ case SDLK_DELETE: key = K_DEL; break;
+ case SDLK_PAUSE: key = K_PAUSE; break;
case SDLK_LSHIFT:
- case SDLK_RSHIFT: *key = K_SHIFT; break;
+ case SDLK_RSHIFT: key = K_SHIFT; break;
case SDLK_LCTRL:
- case SDLK_RCTRL: *key = K_CTRL; break;
+ case SDLK_RCTRL: key = K_CTRL; break;
- case SDLK_RMETA:
- case SDLK_LMETA: *key = K_COMMAND; break;
+ case SDLK_RGUI:
+ case SDLK_LGUI: key = K_COMMAND; break;
case SDLK_RALT:
- case SDLK_LALT: *key = K_ALT; break;
-
- case SDLK_LSUPER:
- case SDLK_RSUPER: *key = K_SUPER; break;
-
- case SDLK_KP5: *key = K_KP_5; break;
- case SDLK_INSERT: *key = K_INS; break;
- case SDLK_KP0: *key = K_KP_INS; break;
- case SDLK_KP_MULTIPLY: *key = K_KP_STAR; break;
- case SDLK_KP_PLUS: *key = K_KP_PLUS; break;
- case SDLK_KP_MINUS: *key = K_KP_MINUS; break;
- case SDLK_KP_DIVIDE: *key = K_KP_SLASH; break;
-
- case SDLK_MODE: *key = K_MODE; break;
- case SDLK_COMPOSE: *key = K_COMPOSE; break;
- case SDLK_HELP: *key = K_HELP; break;
- case SDLK_PRINT: *key = K_PRINT; break;
- case SDLK_SYSREQ: *key = K_SYSREQ; break;
- case SDLK_BREAK: *key = K_BREAK; break;
- case SDLK_MENU: *key = K_MENU; break;
- case SDLK_POWER: *key = K_POWER; break;
- case SDLK_EURO: *key = K_EURO; break;
- case SDLK_UNDO: *key = K_UNDO; break;
- case SDLK_SCROLLOCK: *key = K_SCROLLOCK; break;
- case SDLK_NUMLOCK: *key = K_KP_NUMLOCK; break;
- case SDLK_CAPSLOCK: *key = K_CAPSLOCK; break;
+ case SDLK_LALT: key = K_ALT; break;
+
+ case SDLK_KP_5: key = K_KP_5; break;
+ case SDLK_INSERT: key = K_INS; break;
+ case SDLK_KP_0: key = K_KP_INS; break;
+ case SDLK_KP_MULTIPLY: key = K_KP_STAR; break;
+ case SDLK_KP_PLUS: key = K_KP_PLUS; break;
+ case SDLK_KP_MINUS: key = K_KP_MINUS; break;
+ case SDLK_KP_DIVIDE: key = K_KP_SLASH; break;
+
+ case SDLK_MODE: key = K_MODE; break;
+ case SDLK_HELP: key = K_HELP; break;
+ case SDLK_PRINTSCREEN: key = K_PRINT; break;
+ case SDLK_SYSREQ: key = K_SYSREQ; break;
+ case SDLK_MENU: key = K_MENU; break;
+ case SDLK_POWER: key = K_POWER; break;
+ case SDLK_UNDO: key = K_UNDO; break;
+ case SDLK_SCROLLLOCK: key = K_SCROLLOCK; break;
+ case SDLK_CAPSLOCK: key = K_CAPSLOCK; break;
default:
- if( keysym->sym >= SDLK_WORLD_0 && keysym->sym <= SDLK_WORLD_95 )
- *key = ( keysym->sym - SDLK_WORLD_0 ) + K_WORLD_0;
break;
}
}
- if( down && keysym->unicode && !( keysym->unicode & 0xFF00 ) )
- {
- unsigned char ch = (unsigned char)keysym->unicode & 0xFF;
-
- switch( ch )
- {
- case 127: // ASCII delete
- if( *key != K_DEL )
- {
- // ctrl-h
- *buf = CTRL('h');
- break;
- }
- // fallthrough
-
- default: *buf = ch; break;
- }
- }
-
if( in_keyboardDebug->integer )
- IN_PrintKey( keysym, *key, down );
+ IN_PrintKey( keysym, key, down );
- // Keys that have ASCII names but produce no character are probably
- // dead keys -- ignore them
- if( down && strlen( Key_KeynumToString( *key ) ) == 1 &&
- keysym->unicode == 0 )
- {
- if( in_keyboardDebug->integer )
- Com_Printf( " Ignored dead key '%c'\n", *key );
-
- *key = 0;
- }
-
- if( IN_IsConsoleKey( *key, *buf ) )
+ if( IN_IsConsoleKey( key, '\0' ) )
{
// Console keys can't be bound or generate characters
- *key = K_CONSOLE;
- *buf = '\0';
+ key = K_CONSOLE;
}
- // Don't allow extended ASCII to generate characters
- if( *buf & 0x80 )
- *buf = '\0';
-
- return (char *)buf;
+ return key;
}
-#ifdef MACOS_X_ACCELERATION_HACK
-/*
-===============
-IN_GetIOHandle
-===============
-*/
-static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
-{
- io_connect_t iohandle = MACH_PORT_NULL;
- kern_return_t status;
- io_service_t iohidsystem = MACH_PORT_NULL;
- mach_port_t masterport;
-
- status = IOMasterPort(MACH_PORT_NULL, &masterport);
- if(status != KERN_SUCCESS)
- return 0;
-
- iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem");
- if(!iohidsystem)
- return 0;
-
- status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle);
- IOObjectRelease(iohidsystem);
-
- return iohandle;
-}
-#endif
-
/*
===============
IN_GobbleMotionEvents
@@ -401,7 +299,7 @@ static void IN_GobbleMotionEvents( void )
// Gobble any mouse motion events
SDL_PumpEvents( );
while( SDL_PeepEvents( dummy, 1, SDL_GETEVENT,
- SDL_EVENTMASK( SDL_MOUSEMOTION ) ) ) { }
+ SDL_MOUSEMOTION, SDL_MOUSEMOTION ) ) { }
}
/*
@@ -452,51 +350,10 @@ static void IN_ActivateMouse( void )
if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
return;
-#ifdef MACOS_X_ACCELERATION_HACK
- if (!mouseActive) // mac os x mouse accel hack
- {
- // Save the status of mouse acceleration
- originalMouseSpeed = -1.0; // in case of error
- if(in_disablemacosxmouseaccel->integer)
- {
- io_connect_t mouseDev = IN_GetIOHandle();
- if(mouseDev != 0)
- {
- if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
- {
- Com_Printf("previous mouse acceleration: %f\n", originalMouseSpeed);
- if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
- {
- Com_Printf("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
- Cvar_Set ("in_disablemacosxmouseaccel", 0);
- }
- }
- else
- {
- Com_Printf("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
- Cvar_Set ("in_disablemacosxmouseaccel", 0);
- }
- IOServiceClose(mouseDev);
- }
- else
- {
- Com_Printf("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
- Cvar_Set ("in_disablemacosxmouseaccel", 0);
- }
- }
- }
-#endif
-
if( !mouseActive )
{
- SDL_ShowCursor( 0 );
-#ifdef MACOS_X_CURSOR_HACK
- // This is a bug in the current SDL/macosx...have to toggle it a few
- // times to get the cursor to hide.
- SDL_ShowCursor( 1 );
- SDL_ShowCursor( 0 );
-#endif
- SDL_WM_GrabInput( SDL_GRAB_ON );
+ SDL_SetRelativeMouseMode( SDL_TRUE );
+ SDL_SetWindowGrab( SDL_window, 1 );
IN_GobbleMotionEvents( );
}
@@ -507,9 +364,9 @@ static void IN_ActivateMouse( void )
if( in_nograb->modified || !mouseActive )
{
if( in_nograb->integer )
- SDL_WM_GrabInput( SDL_GRAB_OFF );
+ SDL_SetWindowGrab( SDL_window, 0 );
else
- SDL_WM_GrabInput( SDL_GRAB_ON );
+ SDL_SetWindowGrab( SDL_window, 1 );
in_nograb->modified = qfalse;
}
@@ -533,7 +390,7 @@ static void IN_DeactivateMouse( void )
if( !cls.glconfig.isFullscreen )
{
if( ( Key_GetCatcher( ) == KEYCATCH_UI ) &&
- ( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS ) )
+ SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS )
SDL_ShowCursor( 0 );
else
SDL_ShowCursor( 1 );
@@ -542,38 +399,20 @@ static void IN_DeactivateMouse( void )
if( !mouseAvailable )
return;
-#ifdef MACOS_X_ACCELERATION_HACK
- if (mouseActive) // mac os x mouse accel hack
- {
- if(originalMouseSpeed != -1.0)
- {
- io_connect_t mouseDev = IN_GetIOHandle();
- if(mouseDev != 0)
- {
- Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
- if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
- Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
- IOServiceClose(mouseDev);
- }
- else
- Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
- }
- }
-#endif
-
if( mouseActive )
{
IN_GobbleMotionEvents( );
- SDL_WM_GrabInput( SDL_GRAB_OFF );
+ SDL_SetWindowGrab( SDL_window, 0 );
+ SDL_SetRelativeMouseMode( SDL_FALSE );
// Don't warp the mouse unless the cursor is within the window
- if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
- {
+ if( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS )
+ {
int x, y;
IN_GetUIMousePosition( &x, &y );
- SDL_WarpMouse( x, y );
- }
+ SDL_WarpMouseInWindow( SDL_window, x, y );
+ }
mouseActive = qfalse;
}
@@ -648,7 +487,7 @@ static void IN_InitJoystick( void )
// Print list and build cvar to allow ui to select joystick.
for (i = 0; i < total; i++)
{
- Q_strcat(buf, sizeof(buf), SDL_JoystickName(i));
+ Q_strcat(buf, sizeof(buf), SDL_JoystickNameForIndex(i));
Q_strcat(buf, sizeof(buf), "\n");
}
@@ -674,7 +513,7 @@ static void IN_InitJoystick( void )
}
Com_DPrintf( "Joystick %d opened\n", in_joystickNo->integer );
- Com_DPrintf( "Name: %s\n", SDL_JoystickName(in_joystickNo->integer) );
+ Com_DPrintf( "Name: %s\n", SDL_JoystickNameForIndex(in_joystickNo->integer) );
Com_DPrintf( "Axes: %d\n", SDL_JoystickNumAxes(stick) );
Com_DPrintf( "Hats: %d\n", SDL_JoystickNumHats(stick) );
Com_DPrintf( "Buttons: %d\n", SDL_JoystickNumButtons(stick) );
@@ -915,44 +754,43 @@ IN_ProcessEvents
static void IN_ProcessEvents( void )
{
SDL_Event e;
- const char *character = NULL;
keyNum_t key = 0;
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
return;
- if( Key_GetCatcher( ) == 0 && keyRepeatEnabled )
- {
- SDL_EnableKeyRepeat( 0, 0 );
- keyRepeatEnabled = qfalse;
- }
- else if( !keyRepeatEnabled )
- {
- SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY,
- SDL_DEFAULT_REPEAT_INTERVAL );
- keyRepeatEnabled = qtrue;
- }
-
while( SDL_PollEvent( &e ) )
{
switch( e.type )
{
case SDL_KEYDOWN:
- character = IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qtrue );
+ key = IN_TranslateSDLToQ3Key( &e.key.keysym, qtrue );
if( key )
Com_QueueEvent( 0, SE_KEY, key, qtrue, 0, NULL );
-
- if( character )
- Com_QueueEvent( 0, SE_CHAR, *character, 0, 0, NULL );
break;
case SDL_KEYUP:
- IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qfalse );
+ key = IN_TranslateSDLToQ3Key( &e.key.keysym, qfalse );
if( key )
Com_QueueEvent( 0, SE_KEY, key, qfalse, 0, NULL );
break;
+ case SDL_TEXTINPUT:
+ {
+ int i;
+ int numChars = strlen( e.text.text );
+
+ for( i = 0; i < numChars; i++ )
+ {
+ char c = e.text.text[ i ];
+
+ if( !IN_IsConsoleKey( 0, c ) )
+ Com_QueueEvent( 0, SE_CHAR, c, 0, 0, NULL );
+ }
+ }
+ break;
+
case SDL_MOUSEMOTION:
if( mouseActive )
Com_QueueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
@@ -967,8 +805,6 @@ static void IN_ProcessEvents( void )
case SDL_BUTTON_LEFT: b = K_MOUSE1; break;
case SDL_BUTTON_MIDDLE: b = K_MOUSE3; break;
case SDL_BUTTON_RIGHT: b = K_MOUSE2; break;
- case SDL_BUTTON_WHEELUP: b = K_MWHEELUP; break;
- case SDL_BUTTON_WHEELDOWN: b = K_MWHEELDOWN; break;
case SDL_BUTTON_X1: b = K_MOUSE4; break;
case SDL_BUTTON_X2: b = K_MOUSE5; break;
default: b = K_AUX1 + ( e.button.button - SDL_BUTTON_X2 + 1 ) % 16; break;
@@ -982,25 +818,28 @@ static void IN_ProcessEvents( void )
Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n");
break;
- case SDL_VIDEORESIZE:
- {
- char width[32], height[32];
- Com_sprintf( width, sizeof(width), "%d", e.resize.w );
- Com_sprintf( height, sizeof(height), "%d", e.resize.h );
- Cvar_Set( "r_width", width );
- Cvar_Set( "r_height", height );
- /* wait until user stops dragging for 1 second, so
- we aren't constantly recreating the GL context while
- he tries to drag...*/
- vidRestartTime = Sys_Milliseconds() + 1000;
- }
- break;
- case SDL_ACTIVEEVENT:
- if (e.active.state & SDL_APPINPUTFOCUS) {
- Cvar_SetValue( "com_unfocused", !e.active.gain);
- }
- if (e.active.state & SDL_APPACTIVE) {
- Cvar_SetValue( "com_minimized", !e.active.gain);
+ case SDL_WINDOWEVENT:
+ switch( e.window.event )
+ {
+ case SDL_WINDOWEVENT_RESIZED:
+ {
+ char width[32], height[32];
+ Com_sprintf( width, sizeof( width ), "%d", e.window.data1 );
+ Com_sprintf( height, sizeof( height ), "%d", e.window.data2 );
+ Cvar_Set( "r_width", width );
+ Cvar_Set( "r_height", height );
+
+ // Wait until user stops dragging for 1 second, so
+ // we aren't constantly recreating the GL context while
+ // he tries to drag...
+ vidRestartTime = Sys_Milliseconds( ) + 1000;
+ }
+ break;
+
+ case SDL_WINDOWEVENT_MINIMIZED: Cvar_SetValue( "com_minimized", 1 ); break;
+ case SDL_WINDOWEVENT_MAXIMIZED: Cvar_SetValue( "com_minimized", 0 ); break;
+ case SDL_WINDOWEVENT_FOCUS_LOST: Cvar_SetValue( "com_unfocused", 1 ); break;
+ case SDL_WINDOWEVENT_FOCUS_GAINED: Cvar_SetValue( "com_unfocused", 0 ); break;
}
break;
@@ -1043,7 +882,7 @@ void IN_Frame( void )
// Use WM cursor when not fullscreen
IN_DeactivateMouse( );
}
- else if( !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
+ else if( !( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_INPUT_FOCUS ) )
{
// Window not got focus
IN_DeactivateMouse( );
@@ -1072,11 +911,11 @@ IN_InitKeyLockStates
*/
void IN_InitKeyLockStates( void )
{
- unsigned char *keystate = SDL_GetKeyState(NULL);
+ unsigned char *keystate = SDL_GetKeyboardState(NULL);
- keys[K_SCROLLOCK].down = keystate[SDLK_SCROLLOCK];
- keys[K_KP_NUMLOCK].down = keystate[SDLK_NUMLOCK];
- keys[K_CAPSLOCK].down = keystate[SDLK_CAPSLOCK];
+ keys[K_SCROLLOCK].down = keystate[SDL_SCANCODE_SCROLLLOCK];
+ keys[K_KP_NUMLOCK].down = keystate[SDL_SCANCODE_NUMLOCKCLEAR];
+ keys[K_CAPSLOCK].down = keystate[SDL_SCANCODE_CAPSLOCK];
}
/*
@@ -1084,7 +923,7 @@ void IN_InitKeyLockStates( void )
IN_Init
===============
*/
-void IN_Init( void )
+void IN_Init( void *windowData )
{
int appState;
@@ -1094,6 +933,8 @@ void IN_Init( void )
return;
}
+ SDL_window = (SDL_Window *)windowData;
+
Com_DPrintf( "\n------- Input Initialization -------\n" );
in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE );
@@ -1106,20 +947,14 @@ void IN_Init( void )
in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP );
in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE );
-#ifdef MACOS_X_ACCELERATION_HACK
- in_disablemacosxmouseaccel = Cvar_Get( "in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE );
-#endif
-
- SDL_EnableUNICODE( 1 );
- SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
- keyRepeatEnabled = qtrue;
+ SDL_StartTextInput( );
mouseAvailable = ( in_mouse->value != 0 );
IN_DeactivateMouse( );
- appState = SDL_GetAppState( );
- Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) );
- Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );
+ appState = SDL_GetWindowFlags( SDL_window );
+ Cvar_SetValue( "com_unfocused", !( appState & SDL_WINDOW_INPUT_FOCUS ) );
+ Cvar_SetValue( "com_minimized", appState & SDL_WINDOW_MINIMIZED );
IN_InitKeyLockStates( );
@@ -1134,10 +969,14 @@ IN_Shutdown
*/
void IN_Shutdown( void )
{
+ SDL_StopTextInput( );
+
IN_DeactivateMouse( );
mouseAvailable = qfalse;
IN_ShutdownJoystick( );
+
+ SDL_window = NULL;
}
/*
@@ -1148,5 +987,5 @@ IN_Restart
void IN_Restart( void )
{
IN_ShutdownJoystick( );
- IN_Init( );
+ IN_Init( SDL_window );
}
diff --git a/src/sdl/sdl_snd.c b/src/sdl/sdl_snd.c
index 6a1bf3a0..a087c486 100644
--- a/src/sdl/sdl_snd.c
+++ b/src/sdl/sdl_snd.c
@@ -138,7 +138,6 @@ SNDDMA_Init
*/
qboolean SNDDMA_Init(void)
{
- char drivername[128];
SDL_AudioSpec desired;
SDL_AudioSpec obtained;
int tmp;
@@ -167,9 +166,7 @@ qboolean SNDDMA_Init(void)
Com_Printf( "OK\n" );
- if (SDL_AudioDriverName(drivername, sizeof (drivername)) == NULL)
- strcpy(drivername, "(UNKNOWN)");
- Com_Printf("SDL audio driver is \"%s\".\n", drivername);
+ Com_Printf( "SDL audio driver is \"%s\".\n", SDL_GetCurrentAudioDriver( ) );
memset(&desired, '\0', sizeof (desired));
memset(&obtained, '\0', sizeof (obtained));
diff --git a/src/sys/sys_local.h b/src/sys/sys_local.h
index a0812fa5..3c16876d 100644
--- a/src/sys/sys_local.h
+++ b/src/sys/sys_local.h
@@ -25,12 +25,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/qcommon.h"
// Require a minimum version of SDL
-#define MINSDL_MAJOR 1
-#define MINSDL_MINOR 2
-#define MINSDL_PATCH 10
+#define MINSDL_MAJOR 2
+#define MINSDL_MINOR 0
+#define MINSDL_PATCH 0
// Input subsystem
-void IN_Init( void );
+void IN_Init( void *windowData );
void IN_Frame( void );
void IN_Shutdown( void );
void IN_Restart( void );
diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c
index 9ccd6d2e..4e1c2141 100644
--- a/src/sys/sys_main.c
+++ b/src/sys/sys_main.c
@@ -248,12 +248,8 @@ cpuFeatures_t Sys_GetProcessorFeatures( void )
#ifndef DEDICATED
if( SDL_HasRDTSC( ) ) features |= CF_RDTSC;
if( SDL_HasMMX( ) ) features |= CF_MMX;
- if( SDL_HasMMXExt( ) ) features |= CF_MMX_EXT;
- if( SDL_Has3DNow( ) ) features |= CF_3DNOW;
- if( SDL_Has3DNowExt( ) ) features |= CF_3DNOW_EXT;
if( SDL_HasSSE( ) ) features |= CF_SSE;
if( SDL_HasSSE2( ) ) features |= CF_SSE2;
- if( SDL_HasAltiVec( ) ) features |= CF_ALTIVEC;
#endif
return features;
@@ -596,19 +592,20 @@ int main( int argc, char **argv )
# endif
// Run time
- const SDL_version *ver = SDL_Linked_Version( );
+ SDL_version ver;
+ SDL_VERSION( &ver );
#define MINSDL_VERSION \
XSTRING(MINSDL_MAJOR) "." \
XSTRING(MINSDL_MINOR) "." \
XSTRING(MINSDL_PATCH)
- if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) <
+ if( SDL_VERSIONNUM( ver.major, ver.minor, ver.patch ) <
SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) )
{
Sys_Dialog( DT_ERROR, va( "SDL version " MINSDL_VERSION " or greater is required, "
"but only version %d.%d.%d was found. You may be able to obtain a more recent copy "
- "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch ), "SDL Library Too Old" );
+ "from http://www.libsdl.org/.", ver.major, ver.minor, ver.patch ), "SDL Library Too Old" );
Sys_Exit( 1 );
}