Changeset 245 for trunk/src/gl/gl_window.cc
- Timestamp:
- 05/27/14 16:26:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_window.cc
r243 r245 34 34 int capslock = !!(ke.keysym.mod & KMOD_CAPS); 35 35 if ((shifted ^ capslock) != 0) { 36 kevent.key.ascii = SDL_toupper(ucode);36 kevent.key.ascii = (char8)SDL_toupper(ucode); 37 37 } 38 38 } … … 204 204 205 205 gl_window::gl_window( device* dev, uint16 width, uint16 height, bool fullscreen ) 206 : m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_handle( nullptr ) 207 { 206 : m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_handle( nullptr ), m_adopted( false ) 207 { 208 // bpp = m_info->vfmt->BitsPerPixel; 209 210 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); 211 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); 212 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); 213 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); 214 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 215 216 // SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); 217 // SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); 218 219 #if NV_SDL_VERSION == NV_SDL_20 220 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); 221 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); 222 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 223 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); 224 #endif 225 226 208 227 #if NV_SDL_VERSION == NV_SDL_12 209 228 uint32 flags = SDL_OPENGL; … … 233 252 234 253 235 m_context = new gl_context( m_device, m_handle );254 m_context = new sdl_gl_context( m_device, m_handle ); 236 255 m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) ); 237 256 } … … 254 273 void gl_window::set_title( const string& title ) 255 274 { 275 if ( m_adopted ) return; 256 276 #if NV_SDL_VERSION == NV_SDL_20 257 277 SDL_SetWindowTitle( static_cast<SDL_Window*>( m_handle ), title.c_str() ); … … 276 296 void gl_window::swap_buffers() 277 297 { 298 if ( m_adopted ) return; // NOT SURE 278 299 #if NV_SDL_VERSION == NV_SDL_20 279 300 SDL_GL_SwapWindow( static_cast<SDL_Window*>( m_handle ) ); … … 287 308 delete m_context; 288 309 #if NV_SDL_VERSION == NV_SDL_20 289 SDL_DestroyWindow( static_cast<SDL_Window*>( m_handle ) ); 290 #endif 291 } 310 if ( !m_adopted ) SDL_DestroyWindow( static_cast<SDL_Window*>( m_handle ) ); 311 #endif 312 } 313 314 nv::gl_window::gl_window( device* dev, void* handle, void* dc ) 315 : m_device( dev ), m_width( 0 ), m_height( 0 ), m_title(), m_handle( nullptr ), m_adopted( true ) 316 { 317 #if NV_PLATFORM == NV_WINDOWS 318 #if NV_SDL_VERSION == NV_SDL_20 319 nv::load_gl_no_context(); 320 m_context = new native_gl_context( m_device, dc ); 321 SDL_Window* window = SDL_CreateWindowFrom( handle ); 322 // Doesn't work :/ 323 // RECT rect; 324 // GetClientRect( (HWND)handle, &rect ); 325 // m_width = (uint16)rect.right; 326 // m_height = (uint16)rect.bottom; 327 m_handle = window; 328 m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) ); 329 #else 330 NV_ASSERT( false, "Native GL context only working with SDL 2.0!" ); 331 #endif 332 #else 333 NV_ASSERT( false, "Native GL context adoption not implemented for this platform!" ); 334 #endif 335 }
Note: See TracChangeset
for help on using the changeset viewer.