Пример #1
0
bool Window::Create(){
   logger << ( "[LOG] CREATING WINDOW:" );
   if( SDL_WasInit( SDL_INIT_VIDEO ) == 0 ){
      if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ){
         logger << ( "[ERROR] SDL_Init: " + string( SDL_GetError() ) );
         this->Init = false;
         return false;
      }
      else{
         logger << ( "[LOG] SDL_Init: SUCCESS" );
      }
   }

   this->Id = SDL_CreateWindow( this->Title.c_str(), this->PositionX, this->PositionY, this->Width, this->Height, this->Flag );
   if( this->Id == NULL ){
      logger << ( "[ERROR] SDL_CreateWindow: " + string( SDL_GetError() ) );
      this->Init = false;
      return false;
   }
   else{
      logger << ( "[LOG] SDL_CreateWindow: SUCCESS" );
   }

   SDL_Surface *surface = NULL;
   Uint16 pixels[16*16] = {
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000,
      0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000
   };
   surface = SDL_CreateRGBSurfaceFrom( pixels, 16, 16, 16, 16*2, 0x0f00, 0x00f0, 0x000f, 0xf000 );
   if( surface == NULL ){
      logger << ( "[ERROR] SDL_SetWindowIcon: " + string( SDL_GetError() ) );
      this->Init = false;
      return false;
   }
   else{
      logger << ( "[LOG] SDL_SetWindowIcon: SUCCESS" );
      SDL_SetWindowIcon( this->Id, surface );
      SDL_FreeSurface( surface );
   }

   this->GLContext = SDL_GL_CreateContext( this->Id );
   if( this->GLContext == NULL ){
      logger << ( "[ERROR] SDL_GL_CreateContext: " + string( SDL_GetError() ) );
      this->Init = false;
      return false;
   }
   else{
      logger << ( "[LOG] SDL_GL_CreateContext: SUCCESS" );
   }


   logger << ( "[LOG] SDL_GetWindowDisplayIndex: " + to_string( SDL_GetWindowDisplayIndex( this->Id ) ) );
   logger << ( "[LOG] SDL_GetWindowID: " + to_string( SDL_GetWindowID( this->Id ) ) );
   logger << ( "[LOG] SDL_GetWindowBrightness: " + to_string( SDL_GetWindowBrightness( this->Id ) ) );

   SDL_SetWindowMinimumSize( this->Id, this->WidthMin, this->HeightMin );
   SDL_SetWindowMaximumSize( this->Id, this->WidthMax, this->HeightMax );
   Window::SetMaxMinResolution( this->Id, this->WidthMin, this->HeightMin, this->WidthMax, this->HeightMax );

   logger << ( "[LOG] CREATED WINDOW" );
   this->Init = true;
   return this->Init;
}
Пример #2
0
double video_get_brightness( )
{
	return SDL_GetWindowBrightness( video_window );
}
Пример #3
0
float ZWindow::GetBrightness()
{
	return SDL_GetWindowBrightness(m_win);
}
Пример #4
0
 float brightness() const noexcept {
     return SDL_GetWindowBrightness(ptr.get());
 }
Пример #5
0
	int inline Window::getWindowBrightness(State & state, SDL_Window  * window){
		Stack * stack = state.stack;
		stack->push<LUA_NUMBER>(SDL_GetWindowBrightness(window));
		return 1;
	}