|
@@ -27,6 +27,7 @@ slop::GLSelectRectangle::~GLSelectRectangle() {
|
27
|
27
|
if ( m_window == None ) {
|
28
|
28
|
return;
|
29
|
29
|
}
|
|
30
|
+ xengine->freeCRTCS( m_monitors );
|
30
|
31
|
delete m_framebuffer;
|
31
|
32
|
// Try to erase the window before destroying it.
|
32
|
33
|
glClearColor( 0, 0, 0, 0 );
|
|
@@ -229,7 +230,7 @@ void slop::GLSelectRectangle::generateMagnifyingGlass() {
|
229
|
230
|
}
|
230
|
231
|
|
231
|
232
|
void slop::GLSelectRectangle::setTheme( bool on, std::string name ) {
|
232
|
|
- if ( !on ) {
|
|
233
|
+ if ( !on || name == "none" ) {
|
233
|
234
|
return;
|
234
|
235
|
}
|
235
|
236
|
std::string root = resource->getRealPath( name );
|
|
@@ -248,29 +249,99 @@ void slop::GLSelectRectangle::setTheme( bool on, std::string name ) {
|
248
|
249
|
return;
|
249
|
250
|
}
|
250
|
251
|
// Otherwise we load each one :)
|
251
|
|
- ilInit();
|
252
|
|
- ilutInit();
|
253
|
|
- ilutRenderer(ILUT_OPENGL);
|
254
|
|
- ILuint corner;
|
255
|
|
- ilGenImages( 1, &corner );
|
256
|
|
- ilBindImage( corner );
|
257
|
|
- ilLoadImage( tl.c_str() );
|
258
|
|
- m_cornerids[0] = ilutGLBindMipmaps();
|
259
|
|
- ilLoadImage( tr.c_str() );
|
260
|
|
- m_cornerids[1] = ilutGLBindMipmaps();
|
261
|
|
- ilLoadImage( bl.c_str() );
|
262
|
|
- m_cornerids[2] = ilutGLBindMipmaps();
|
263
|
|
- ilLoadImage( br.c_str() );
|
264
|
|
- m_cornerids[3] = ilutGLBindMipmaps();
|
265
|
|
- ilLoadImage( straight.c_str() );
|
266
|
|
- m_straightwidth = ilGetInteger( IL_IMAGE_WIDTH );
|
267
|
|
- m_straightheight = ilGetInteger( IL_IMAGE_HEIGHT );
|
268
|
|
- m_straightid = ilutGLBindMipmaps();
|
269
|
|
- // And clean up after.
|
270
|
|
- ilDeleteImages( 1, &corner );
|
|
252
|
+ loadImage( &(m_cornerids[0]), tl );
|
|
253
|
+ loadImage( &(m_cornerids[1]), tr );
|
|
254
|
+ loadImage( &(m_cornerids[2]), bl );
|
|
255
|
+ loadImage( &(m_cornerids[3]), br );
|
|
256
|
+ loadImage( &(m_straightid), straight );
|
|
257
|
+ glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &m_straightwidth );
|
|
258
|
+ glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &m_straightheight );
|
271
|
259
|
m_themed = on;
|
272
|
260
|
}
|
273
|
261
|
|
|
262
|
+unsigned int slop::GLSelectRectangle::loadImage( unsigned int* texture, std::string path ) {
|
|
263
|
+ glActiveTexture(GL_TEXTURE0);
|
|
264
|
+ glEnable(GL_TEXTURE_2D);
|
|
265
|
+ glGenTextures( 1, texture );
|
|
266
|
+ glBindTexture( GL_TEXTURE_2D, *texture );
|
|
267
|
+ Imlib_Load_Error err;
|
|
268
|
+ Imlib_Image image = imlib_load_image_with_error_return( path.c_str(), &err );
|
|
269
|
+ if ( err != IMLIB_LOAD_ERROR_NONE ) {
|
|
270
|
+ std::string message = "Failed to load image: ";
|
|
271
|
+ message += path;
|
|
272
|
+ message += "\n\t";
|
|
273
|
+ switch( err ) {
|
|
274
|
+ default: {
|
|
275
|
+ message += "unknown error ";
|
|
276
|
+ message += (int)err;
|
|
277
|
+ message += "\n";
|
|
278
|
+ break;
|
|
279
|
+ }
|
|
280
|
+ case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS:
|
|
281
|
+ message += "out of file descriptors\n";
|
|
282
|
+ break;
|
|
283
|
+ case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
|
|
284
|
+ message += "out of memory\n";
|
|
285
|
+ break;
|
|
286
|
+ case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
|
|
287
|
+ message += "path contains too many symbolic links\n";
|
|
288
|
+ break;
|
|
289
|
+ case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
|
|
290
|
+ message += "path points outside address space\n";
|
|
291
|
+ break;
|
|
292
|
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
|
|
293
|
+ message += "path component is not a directory\n";
|
|
294
|
+ break;
|
|
295
|
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
|
|
296
|
+ message += "path component is non-existant (~ isn't expanded inside quotes!)\n";
|
|
297
|
+ break;
|
|
298
|
+ case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
|
|
299
|
+ message += "path is too long\n";
|
|
300
|
+ break;
|
|
301
|
+ case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
|
|
302
|
+ message += "no loader for file format (unsupported format)\n";
|
|
303
|
+ break;
|
|
304
|
+ case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: {
|
|
305
|
+ message += "not enough disk space\n";
|
|
306
|
+ break;
|
|
307
|
+ }
|
|
308
|
+ case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: {
|
|
309
|
+ message += "file does not exist\n";
|
|
310
|
+ break;
|
|
311
|
+ }
|
|
312
|
+ case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: {
|
|
313
|
+ message += "file is a directory\n";
|
|
314
|
+ break;
|
|
315
|
+ }
|
|
316
|
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
|
|
317
|
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: {
|
|
318
|
+ message += "permission denied\n";
|
|
319
|
+ break;
|
|
320
|
+ }
|
|
321
|
+ }
|
|
322
|
+ throw std::runtime_error( message.c_str() );
|
|
323
|
+ return *texture;
|
|
324
|
+ }
|
|
325
|
+ imlib_context_set_image( image );
|
|
326
|
+ DATA32* data = imlib_image_get_data_for_reading_only();
|
|
327
|
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, imlib_image_get_width(), imlib_image_get_height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)data );
|
|
328
|
+ if ( GLEW_VERSION_3_0 ) {
|
|
329
|
+ glHint( GL_GENERATE_MIPMAP_HINT, GL_NICEST );
|
|
330
|
+ glGenerateMipmap( GL_TEXTURE_2D );
|
|
331
|
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
332
|
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
333
|
+ } else {
|
|
334
|
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
|
335
|
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
336
|
+ }
|
|
337
|
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
338
|
+ imlib_free_image();
|
|
339
|
+ glDisable(GL_TEXTURE_2D);
|
|
340
|
+ return *texture;
|
|
341
|
+}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
274
|
345
|
slop::GLSelectRectangle::GLSelectRectangle( int sx, int sy, int ex, int ey, int border, bool highlight, float r, float g, float b, float a ) {
|
275
|
346
|
m_x = std::min( sx, ex );
|
276
|
347
|
m_y = std::min( sy, ey );
|
|
@@ -475,57 +546,57 @@ void slop::GLSelectRectangle::update( double dt ) {
|
475
|
546
|
//float ratio = ((float)m_straightwidth/(float)m_straightheight);
|
476
|
547
|
glBegin( GL_QUADS );
|
477
|
548
|
// straight top
|
478
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y-m_border );
|
479
|
|
- glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y-m_border );
|
480
|
|
- glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y );
|
481
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y );
|
|
549
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y-m_border );
|
|
550
|
+ glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y-m_border );
|
|
551
|
+ glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y );
|
|
552
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y );
|
482
|
553
|
// straight bot
|
483
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y+m_height );
|
484
|
|
- glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height );
|
485
|
|
- glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height+m_border );
|
486
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y+m_height+m_border );
|
|
554
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y+m_height );
|
|
555
|
+ glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height );
|
|
556
|
+ glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height+m_border );
|
|
557
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y+m_height+m_border );
|
487
|
558
|
// straight left
|
488
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border/2 );
|
489
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x, m_y-m_border/2 );
|
490
|
|
- glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x, m_y+m_height+m_border/2 );
|
491
|
|
- glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x-m_border, m_y+m_height+m_border/2 );
|
|
559
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y-m_border/2 );
|
|
560
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x, m_y-m_border/2 );
|
|
561
|
+ glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x, m_y+m_height+m_border/2 );
|
|
562
|
+ glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border/2 );
|
492
|
563
|
// straight right
|
493
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y-m_border/2 );
|
494
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y-m_border/2 );
|
495
|
|
- glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border/2 );
|
496
|
|
- glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x+m_width, m_y+m_height+m_border/2 );
|
|
564
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y-m_border/2 );
|
|
565
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border/2 );
|
|
566
|
+ glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border/2 );
|
|
567
|
+ glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border/2 );
|
497
|
568
|
glEnd();
|
498
|
569
|
// top left corner
|
499
|
570
|
glBindTexture( GL_TEXTURE_2D, m_cornerids[0] );
|
500
|
571
|
glBegin( GL_QUADS );
|
501
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y-m_border );
|
502
|
|
- glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y-m_border );
|
503
|
|
- glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y );
|
504
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y );
|
|
572
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border );
|
|
573
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y-m_border );
|
|
574
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y );
|
|
575
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y );
|
505
|
576
|
glEnd();
|
506
|
577
|
// top right
|
507
|
578
|
glBindTexture( GL_TEXTURE_2D, m_cornerids[1] );
|
508
|
579
|
glBegin( GL_QUADS );
|
509
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y-m_border );
|
510
|
|
- glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
|
511
|
|
- glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y );
|
512
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y );
|
|
580
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y-m_border );
|
|
581
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
|
|
582
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y );
|
|
583
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y );
|
513
|
584
|
glEnd();
|
514
|
585
|
// bottom left
|
515
|
586
|
glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
|
516
|
587
|
glBegin( GL_QUADS );
|
517
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_height );
|
518
|
|
- glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y+m_height );
|
519
|
|
- glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y+m_height+m_border );
|
520
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y+m_height+m_border );
|
|
588
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y+m_height );
|
|
589
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y+m_height );
|
|
590
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y+m_height+m_border );
|
|
591
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border );
|
521
|
592
|
glEnd();
|
522
|
593
|
// bottom right
|
523
|
594
|
glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
|
524
|
595
|
glBegin( GL_QUADS );
|
525
|
|
- glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y+m_height );
|
526
|
|
- glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height );
|
527
|
|
- glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border );
|
528
|
|
- glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y+m_height+m_border );
|
|
596
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y+m_height );
|
|
597
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height );
|
|
598
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border );
|
|
599
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border );
|
529
|
600
|
glEnd();
|
530
|
601
|
}
|
531
|
602
|
|