Ejemplo n.º 1
0
//------------------------------------------------------------
void ofAppGLFWWindow::listVideoModes(){
	GLFWvidmode vidModes[100];
	int numModes = glfwGetVideoModes( vidModes, 100 );
	for(int i=0; i<numModes; i++){
		printf("%i x %i %ibits",vidModes[i].Width,vidModes[i].Height,vidModes[i].RedBits+vidModes[i].GreenBits+vidModes[i].BlueBits);
	}
}
Ejemplo n.º 2
0
int main( void )
{
    GLFWvidmode dtmode, modes[ MAX_NUM_MODES ];
    int     modecount, i;

    // Initialize GLFW
    if( !glfwInit() )
    {
        return 0;
    }

    // Show desktop video mode
    glfwGetDesktopMode( &dtmode );
    printf( "Desktop mode: %d x %d x %d\n\n",
            dtmode.Width, dtmode.Height, dtmode.RedBits +
            dtmode.GreenBits + dtmode.BlueBits );

    // List available video modes
    modecount = glfwGetVideoModes( modes, MAX_NUM_MODES );
    printf( "Available modes:\n" );
    for( i = 0; i < modecount; i ++ )
    {
        printf( "%3d: %d x %d x %d\n", i,
                modes[i].Width, modes[i].Height, modes[i].RedBits +
                modes[i].GreenBits + modes[i].BlueBits );
    }

    // Terminate GLFW
    glfwTerminate();

    return 0;
}
Ejemplo n.º 3
0
//api
static Array<Array<int > > GetAvailableScreenModesNative() {
	// --- get available screen resolutions ---
	int modeCount,index,depth;
	
	//create array for modes
	GLFWvidmode glfwModes[MAX_NUM_MODES];
	
	//get the video modes from glfw
	modeCount = glfwGetVideoModes(glfwModes,MAX_NUM_MODES);

	//create monkey return array please :D
	Array<Array<int > > modes=Array<Array<int > >(modeCount);

	//iterate over all glfw modes
	for(index=0;index<modeCount;index++) {
		//create new array in array for this mode
		gc_assign(modes.At(index),Array<int >(3));
		
		//get depth
		//fix 24bits for potential later cross compatability (faking alpha bits)
		depth = glfwModes[index].RedBits + glfwModes[index].GreenBits + glfwModes[index].BlueBits;
		if (depth == 24) { depth = 32; }
		
		//save values
		modes.At(index).At(0) = glfwModes[index].Width;
		modes.At(index).At(1) = glfwModes[index].Height;
		modes.At(index).At(2) = depth;
	}

	//return result please :D
	return modes;
}
Ejemplo n.º 4
0
static void list_modes(GLFWmonitor* monitor)
{
    int count, x, y, widthMM, heightMM, dpi, i;
    GLFWvidmode mode = glfwGetVideoMode(monitor);
    const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);

    glfwGetMonitorPos(monitor, &x, &y);
    glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);

    printf("Name: %s (%s)\n",
           glfwGetMonitorName(monitor),
           glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
    printf("Current mode: %s\n", format_mode(&mode));
    printf("Virtual position: %i %i\n", x, y);

    dpi = (int) ((float) mode.width * 25.4f / (float) widthMM);
    printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi);

    printf("Modes:\n");

    for (i = 0;  i < count;  i++)
    {
        printf("%3u: %s", (unsigned int) i, format_mode(modes + i));

        if (memcmp(&mode, modes + i, sizeof(GLFWvidmode)) == 0)
            printf(" (current mode)");

        putchar('\n');
    }
}
/// Dump a list of monitor info to Log and stdout.
/// http://www.glfw.org/docs/3.0/monitor.html
void PrintMonitorInfo()
{
    int count;
    GLFWmonitor** monitors = glfwGetMonitors(&count);
    printf("Found %d monitors:\n", count);
    LOG_INFO("Found %d monitors:", count);
    for (int i=0; i<count; ++i)
    {
        GLFWmonitor* pMonitor = monitors[i];
        if (pMonitor == NULL)
            continue;
        printf("  Monitor %d:\n", i);
        LOG_INFO("  Monitor %d:", i);

        /// Monitor name
        const char* pName = glfwGetMonitorName(pMonitor);
        printf("    Name: %s\n", pName);
        LOG_INFO("    Name: %s", pName);

        /// Monitor Physical Size
        int widthMM, heightMM;
        glfwGetMonitorPhysicalSize(pMonitor, &widthMM, &heightMM);
        //const double dpi = mode->width / (widthMM / 25.4);
        printf("    physical size: %d x %d mm\n");
        LOG_INFO("    physical size: %d x %d mm");

        /// Modes
        const GLFWvidmode* mode = glfwGetVideoMode(pMonitor);
        printf("    Current mode:  %dx%d @ %dHz (RGB %d %d %d bits)\n",
                mode->width,
                mode->height,
                mode->refreshRate,
                mode->redBits,
                mode->greenBits, 
                mode->blueBits);
        LOG_INFO("    Current mode:  %dx%d @ %dHz (RGB %d %d %d bits)",
                mode->width,
                mode->height,
                mode->refreshRate,
                mode->redBits,
                mode->greenBits, 
                mode->blueBits);

#if 0
        int modeCount;
        const GLFWvidmode* modes = glfwGetVideoModes(pMonitor, &modeCount);
        printf("    %d Modes:\n", modeCount);
        LOG_INFO("    %d Modes:", modeCount);
        for (int j=0; j<modeCount; ++j)
        {
            const GLFWvidmode& m = modes[j];
            printf("      %dx%d @ %dHz (RGB %d %d %d bits)\n",
                m.width, m.height, m.refreshRate, m.redBits, m.greenBits, m.blueBits);
            LOG_INFO("      %dx%d @ %dHz (RGB %d %d %d bits)",
                m.width, m.height, m.refreshRate, m.redBits, m.greenBits, m.blueBits);
        }
#endif
    }
}
Ejemplo n.º 6
0
char* app_display_querymodes()
{
    glfwSetErrorCallback(glfw_error_callback);

    if (!glfwInit())
        return NULL;

    uint adapter_id = 0;
    size_t outsz;

    /* start json data (adapter array) */
    json_t jroot = json_create_arr();

    /* read adapters */
    while (adapter_id == 0)  {
        json_t jadapter = json_create_obj();
        json_additem_toarr(jroot, jadapter);

        json_additem_toobj(jadapter, "name", json_create_str("Graphics Card #1"));
        json_additem_toobj(jadapter, "id", json_create_num(0));

        /* enumerate monitors */
        json_t joutputs = json_create_arr();
        json_additem_toobj(jadapter, "monitors", joutputs);
        int output_cnt = 0;
        GLFWmonitor** monitors = glfwGetMonitors(&output_cnt);
        for (int i = 0; i < output_cnt; i++)    {
            json_t joutput = json_create_obj();
            json_additem_toarr(joutputs, joutput);

            json_additem_toobj(joutput, "id", json_create_num((fl64)i));
            json_additem_toobj(joutput, "name", json_create_str(glfwGetMonitorName(monitors[i])));

            /* enumerate modes */
            json_t jmodes = json_create_arr();
            json_additem_toobj(joutput, "modes", jmodes);

            int mode_cnt;
            const GLFWvidmode* modes = glfwGetVideoModes(monitors[i], &mode_cnt);
            for (int i = 0; i < mode_cnt; i++)   {
                json_t jmode = json_create_obj();
                json_additem_toobj(jmode, "width", json_create_num((fl64)modes[i].width));
                json_additem_toobj(jmode, "height", json_create_num((fl64)modes[i].height));
                json_additem_toobj(jmode, "refresh-rate",
                    json_create_num((fl64)modes[i].refreshRate));
                json_additem_toarr(jmodes, jmode);
            }
        }

        adapter_id ++;
    }

    char* r = json_savetobuffer(jroot, &outsz, FALSE);
    json_destroy(jroot);

    return r;
}
Ejemplo n.º 7
0
void printVideoModes()
{
	GLFWvidmode *modes = new GLFWvidmode[1000];
	int modesCount = glfwGetVideoModes(modes,1000);
	printf("found video modes: \n");
	for (int i = 0; i < modesCount; i++)
	{
		printf("  %dx%d: %dx%dx%d\n",modes[i].Width,modes[i].Height,
			modes[i].RedBits,modes[i].GreenBits, modes[i].BlueBits);
	}
	delete[] modes;
}
Ejemplo n.º 8
0
	std::vector<Monitor::VideoMode> Monitor::getVideoModes() const
	{
		std::vector<VideoMode> videoModes;

		int total = 0;
		const GLFWvidmode* vms = glfwGetVideoModes(monitor, &total);

		for(int i = 0; i < total; ++i)
			videoModes.emplace_back(vms[i]);

		return videoModes;
	}
Ejemplo n.º 9
0
void create_window() {
    int width = 1024;
    int height = 768;
    GLFWmonitor *monitor = NULL;
    if (FULLSCREEN) {
        int mode_count;
        monitor = glfwGetPrimaryMonitor();
        const GLFWvidmode *modes = glfwGetVideoModes(monitor, &mode_count);
        width = modes[mode_count - 1].width;
        height = modes[mode_count - 1].height;
    }
    window = glfwCreateWindow(width, height, "Craft", monitor, NULL);
}
Ejemplo n.º 10
0
static void ShellMenuVideoUpdateResolutionList(void)
{
	shellmenuvideoresolutioncount = 0;
#if defined(USE_SDL)
	// SDL returns modes sorted by decreasing resolution (!)
	SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
	int modecount = 0;
	for (SDL_Rect **mode = modes; *mode != NULL; ++mode)
		++modecount;
	for (int i = 0; i < modecount; ++i)
	{
		shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].w = modes[modecount-1-i]->w;
		shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].h = modes[modecount-1-i]->h;
		++shellmenuvideoresolutioncount;
	}
#elif defined(USE_SFML)
	int modecount = sf::VideoMode::GetModesCount();
	int depth = SCREEN_DEPTH ? SCREEN_DEPTH : 32
	for (int i = 0; i < modecount; ++i)
	{
		sf::VideoMode mode(sf::VideoMode::GetMode(i));
		if (mode.BitsPerPixel == depth)
		{
			shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].w = modes[i].Width;
			shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].h = modes[i].Height;
			++shellmenuvideoresolutioncount;
		}
	}
#elif defined(USE_GLFW)
	// get the primary monitor
	GLFWmonitor *monitor = glfwGetPrimaryMonitor();

	// GLFW returns modes sorted by increasing depth, then by increasing resolution
	int modecount;
	const GLFWvidmode* modes = glfwGetVideoModes(monitor, &modecount);

	int depth = SCREEN_DEPTH ? std::min(SCREEN_DEPTH, 24) : 24;		// HACK
	for (int i = 0; i < modecount; ++i)
	{
		if (modes[i].redBits + modes[i].greenBits + modes[i].blueBits == depth)
		{
			shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].w = static_cast<unsigned short>(modes[i].width);
			shellmenuvideoresolutionlist[shellmenuvideoresolutioncount].h = static_cast<unsigned short>(modes[i].height);
			++shellmenuvideoresolutioncount;
		}
	}
#endif
}
Ejemplo n.º 11
0
static inline jint wrapped_Java_com_badlogic_jglfw_Glfw_glfwGetVideoModesJni
(JNIEnv* env, jclass clazz, jlong monitor, jintArray obj_modes, int* modes) {

//@line:646

		int numModes = 0;
		const GLFWvidmode* vidModes = glfwGetVideoModes((GLFWmonitor*)monitor, &numModes);
		for(int i = 0, j = 0; i < numModes; i++) {
			modes[j++] = vidModes[i].width;
			modes[j++] = vidModes[i].height;
			modes[j++] = vidModes[i].redBits;
			modes[j++] = vidModes[i].greenBits;
			modes[j++] = vidModes[i].blueBits;
		}
		return numModes;
	
}
Ejemplo n.º 12
0
	util::Array<SVideoMode> CMonitor::getAllVideoModes() noexcept
	{
		std::size_t count = 0;
		const GLFWvidmode* pvm = glfwGetVideoModes(m_monitor, reinterpret_cast<int*>(&count));

		try
		{
			util::Array<SVideoMode> modes(count);
			while(count--)
				modes[count] = copyVideoMode(pvm[count]);
			return modes;
		}
		catch(...)
		{
			return {};
		}
	}
Ejemplo n.º 13
0
 Monitor::Monitor(GLFWmonitor *monitor) {
     if(0 != monitor) {
         const char *nm = glfwGetMonitorName(monitor);
         name = nm;
         int width;
         int height;
         glfwGetMonitorPhysicalSize(monitor, &width, &height);
         size = glm::vec2(width, height);
         current = Mode(glfwGetVideoMode(monitor));
         int modeCount;
         const GLFWvidmode *vidmods = glfwGetVideoModes(monitor, &modeCount);
         for(int i = 0; i < modeCount; ++i) {
             modes.push_back(Mode(vidmods + i));
         }
     }
     descriptor = monitor;
 }
Ejemplo n.º 14
0
std::string display_modes() {
	if(glfw_state == 0)
		graphics();
	
	std::ostringstream s;
	std::string l;
	int i, c;
	
	const GLFWvidmode * m = glfwGetVideoModes(glfwGetPrimaryMonitor(), &c);
	
	for(i = 0; i < c; i++) {
		if(i > 0) s << " ";
		s << m[i].width << "x" << m[i].height;
	}
	
	l = s.str();
	return l;
}
Ejemplo n.º 15
0
void create_window() {
    #ifdef __APPLE__
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    #endif
    int width = 1024;
    int height = 768;
    GLFWmonitor *monitor = NULL;
    if (FULLSCREEN) {
        int mode_count;
        monitor = glfwGetPrimaryMonitor();
        const GLFWvidmode *modes = glfwGetVideoModes(monitor, &mode_count);
        width = modes[mode_count - 1].width;
        height = modes[mode_count - 1].height;
    }
    window = glfwCreateWindow(width, height, "Craft", monitor, NULL);
}
Ejemplo n.º 16
0
static bool ScreenModeExistsNative(int width,int height, int depth) {
	// --- return true if particular screen mode exists ---
	GLFWvidmode glfwModes[MAX_NUM_MODES];
	int modeCount,index;

	//fix 32 graphics mode so it matches glfw color bits
	if (depth == 32) { depth = 24; }

	//look for matching graphics mode
	modeCount = glfwGetVideoModes(glfwModes,MAX_NUM_MODES);
	for(index=0;index<modeCount;index++) {
		if (glfwModes[index].Width == width && glfwModes[index].Height == height && glfwModes[index].RedBits + glfwModes[index].GreenBits + glfwModes[index].BlueBits == depth) {
			return true;
		}
	}

	//nope!
	return false;
}
Ejemplo n.º 17
0
std::vector<Vec3ui> World::GetVideoModes()
{
	std::vector<Vec3ui> forReturn;
	#if !ANGEL_MOBILE
		int numModes = 0;
		const GLFWvidmode* vidModes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &numModes);

		for (int i=0; i < numModes; i++)
		{
			Vec3ui avm;
			avm.X = vidModes[i].width;
			avm.Y = vidModes[i].height;
			avm.Z = vidModes[i].redBits + vidModes[i].greenBits + vidModes[i].blueBits;
			forReturn.push_back(avm);
		}
	#else
		//TODO: return the device's native resolution?
	#endif

	return forReturn;
}
Ejemplo n.º 18
0
static void list_modes(void)
{
    int count, i;
    GLFWvidmode desktop_mode;
    GLFWvidmode* modes = glfwGetVideoModes(&count);

    glfwGetDesktopMode(&desktop_mode);
    printf("Desktop mode: %s\n", format_mode(&desktop_mode));

    printf("Available modes:\n");

    for (i = 0;  i < count;  i++)
    {
        printf("%3u: %s", (unsigned int) i, format_mode(modes + i));

        if (memcmp(&desktop_mode, modes + i, sizeof(GLFWvidmode)) == 0)
            printf(" (desktop mode)");

        putchar('\n');
    }
}
Ejemplo n.º 19
0
static Array<graphicsModeNative* > GetGraphicsModesNative() {
	// --- get the available graphics resolutions ---
	GLFWvidmode glfwModes[MAX_NUM_MODES];
	int modeCount,index;

	//get the video modes from glfw
	modeCount = glfwGetVideoModes(glfwModes,MAX_NUM_MODES);

	//convert into a format monkey can understand
	Array<graphicsModeNative* > modes=Array<graphicsModeNative* >(modeCount);

	//create all instance of native and assign to garbage collector
	for(index=0;index<modeCount;index++) {
		gc_assign(modes[index],new graphicsModeNative(glfwModes[index].Width,glfwModes[index].Height,glfwModes[index].RedBits + glfwModes[index].GreenBits + glfwModes[index].BlueBits));

		//fix 24bits for potential later cross compatability (faking alpha bits)
		if (modes[index]->depth == 24) { modes[index]->depth = 32; }
	}

	//return result
	return modes;
}
Ejemplo n.º 20
0
GLFWwindow *toggleFullScreenWindow(GLFWwindow *window, int key) {
    if (glfwGetKey(window, key)) {
        LOCAL_PERSIST bool isFullScreen = false;
        isFullScreen = !isFullScreen;

        GLFWwindow *newWindow;
        if (isFullScreen) {
            int count;
            const GLFWvidmode *modes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);
            int monitorHeight = modes[count - 1].height;
            int monitorWidth = modes[count - 1].width;
            newWindow = glfwCreateWindow(monitorWidth, monitorHeight, g_gameTitle, glfwGetPrimaryMonitor(), window);
        } else {
            newWindow = glfwCreateWindow(g_windowWidth, g_windowHeight, g_gameTitle, nullptr, window);
        }
        glfwDestroyWindow(window);
        glfwMakeContextCurrent(newWindow);
        return newWindow;


    }
}
Ejemplo n.º 21
0
        static const VideoModeList & GetSupportedModes()
        {
            static VideoModeList vml;
            if ( vml.empty() )
            {
                GLFWvidmode modes[256];
                int count =  glfwGetVideoModes(modes, 256);
                vml.reserve(count);

                for (int i = 0; i < count; ++i)
                {
                    VideoMode vm;
                    vm.width            = modes[i].Width;
                    vm.height           = modes[i].Height;
                    vm.red_bits         = modes[i].RedBits;
                    vm.green_bits       = modes[i].GreenBits;
                    vm.blue_bits        = modes[i].BlueBits;
                    vml.push_back(vm);
                }
            }
            return vml;
        }
Ejemplo n.º 22
0
std::vector<Vec3ui> World::GetVideoModes()
{
	std::vector<Vec3ui> forReturn;
	#if !ANGEL_MOBILE
		GLFWvidmode vidModes[64];

		int modesDetected = glfwGetVideoModes(vidModes, 64);

		for (int i=0; i < modesDetected; i++)
		{
			Vec3ui avm;
			avm.X = vidModes[i].Width;
			avm.Y = vidModes[i].Height;
			avm.Z = vidModes[i].RedBits + vidModes[i].GreenBits + vidModes[i].BlueBits;
			forReturn.push_back(avm);
		}
	#else
		//TODO: return the device's native resolution?
	#endif

	return forReturn;
}
Ejemplo n.º 23
0
std::vector<IntVector3> Graphics::GetResolutions(int monitor) const
{
    std::vector<IntVector3> ret;
    int monitor_count=0;
    GLFWmonitor** known_monitors = glfwGetMonitors(&monitor_count);
    if (monitor >= monitor_count || monitor < 0)
        monitor = 0; // this monitor is not present, use first monitor
    GLFWmonitor* selected_monitor = known_monitors[monitor];
    int numModes=0;
    const GLFWvidmode * modes = glfwGetVideoModes(selected_monitor,&numModes);
    if(!modes)
        return ret;

    for (int i = 0; i < numModes; ++i)
    {
        const GLFWvidmode &mode(modes[i]);
        int width = mode.width;
        int height  = mode.height;
        int rate = mode.refreshRate;

        // Store mode if unique
        bool unique = true;
        for (unsigned j = 0; j < ret.size(); ++j)
        {
            if (ret[j].x_ == width && ret[j].y_ == height && ret[j].z_ == rate)
            {
                unique = false;
                break;
            }
        }

        if (unique)
            ret.emplace_back(width, height, rate);
    }

    return ret;
}
Ejemplo n.º 24
0
void GameMenu::create_menus(void)
{
  m_menusystem = MenuSystem();

  int current_w=0,current_h=0;
  glfwGetWindowSize(&current_w,&current_h);

  GLFWvidmode *vidmodes = new GLFWvidmode[256];
  int nummodes = glfwGetVideoModes(vidmodes,256);

  // get resolutions
  menuoptions_t resolutions;
  int selected_resolution=0;
  for(int i=0,x=0;i<nummodes;++i) {
    if ((vidmodes[i].RedBits + vidmodes[i].GreenBits + vidmodes[i].BlueBits) < 24) continue;
    if (vidmodes[i].Width < 1024) continue;
   
    string s = to_string<int>(vidmodes[i].Width) + "x" + to_string<int>(vidmodes[i].Height);
    string s2 = to_string<int>(vidmodes[i].Width) + " " + to_string<int>(vidmodes[i].Height);
    resolutions.push_back(MenuitemOption(s,s2));
    if (vidmodes[i].Width == current_w && vidmodes[i].Height == current_h)
      selected_resolution = x;

    x++;
  }
  delete[] vidmodes;

//  resolutions.push_back(MenuitemOption("1280x720","1280 720"));

  // construct menus

  menuitems_t items;

  // main
  items.push_back(Menuitem("","New Game",  "",          "newgame"));
  items.push_back(Menuitem("","Settings", "",          "settings"));
  items.push_back(Menuitem("","Hiscore",   "scores",   ""));
  items.push_back(Menuitem("","Credits",   "credits",   ""));
  items.push_back(Menuitem("","Exit",         "exit",      ""));
  Menu *m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("main",m_menu); m_menus.push_back(m_menu);

  // main in game
  items.push_front(Menuitem("","Resume Game", "resumegame", ""));
  m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("main_ingame",m_menu); m_menus.push_back(m_menu);

  // settings
  items.clear();
  items.push_back(Menuitem("","Video Settings","","videosettings"));
  items.push_back(Menuitem("","Input Settings","","inputsettings"));
  items.push_back(Menuitem("","Back","",":up_level"));
  m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("settings",m_menu); m_menus.push_back(m_menu);

  // video settings
  menuoptions_t boolean;
  boolean.push_back(MenuitemOption("No","0"));
  boolean.push_back(MenuitemOption("Yes","1"));

  //menuoptions_t fsaa;
  //fsaa.push_back(MenuitemOption("No","0"));
  //fsaa.push_back(MenuitemOption("2x","2"));
  //fsaa.push_back(MenuitemOption("4x","4"));
  ////  fsaa.push_back(MenuitemOption("6x","6"));
  ////  fsaa.push_back(MenuitemOption("8x","8"));

  items.clear();
  items.push_back(Menuitem("resolution","Resolution","","",resolutions,selected_resolution));
  items.push_back(Menuitem("fullscreen","Fullscreen","","",boolean,g_settings->m_fullscreen));
  //items.push_back(Menuitem("fsaa","Multisampling","","",fsaa,g_settings->m_fsaa/2));
  items.push_back(Menuitem("vsync","V-sync","","",boolean,g_settings->m_vsync));
  items.push_back(Menuitem("","Apply settings","apply_video_settings",""));
  items.push_back(Menuitem("","Back","",":up_level"));
  m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("videosettings",m_menu); m_menus.push_back(m_menu);

  menuoptions_t sensitivity;
  for(int i=1;i<=10;++i)
    sensitivity.push_back(MenuitemOption(to_string<int>(i),to_string<int>(i)));

  items.clear();
  items.push_back(Menuitem("mouse_sensitivity","Mouse Sensitivity","mouse_sensitivity_change","",sensitivity,(g_settings->m_mouse_sensitivity)-1));
  items.push_back(Menuitem("","Back","",":up_level"));
  m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("inputsettings",m_menu); m_menus.push_back(m_menu);


  // start menu

  menuoptions_t layouts;
  vector<string> names = g_layouts->get_names();
  FOR_EACH_CONST(vector<string>,names,it)
    layouts.push_back(MenuitemOption(*it,*it));

  menuoptions_t difficulty;
  difficulty.push_back(MenuitemOption("Easy","0"));
  difficulty.push_back(MenuitemOption("Normal","1"));
  difficulty.push_back(MenuitemOption("Hard","2"));

  menuoptions_t waves;
  waves.push_back(MenuitemOption("1","1"));
  waves.push_back(MenuitemOption("5","5"));
  waves.push_back(MenuitemOption("10","10"));
  waves.push_back(MenuitemOption("25","25"));
  waves.push_back(MenuitemOption("50","50"));

  items.clear();
  items.push_back(Menuitem("","Start","start_game",""));
  items.push_back(Menuitem("difficulty","Difficulty","","",difficulty,1));
  items.push_back(Menuitem("startingwave","Starting wave","","",waves,0));
  items.push_back(Menuitem("layout","Theme","layout_change","",layouts,0));
  items.push_back(Menuitem("","Back","",":up_level"));
  m_menu = new GraphicMenu(items,g_resources.font,1.0);
  m_menusystem.add_menu("newgame",m_menu); m_menus.push_back(m_menu);
}
Ejemplo n.º 25
0
 const GLFWvidmode* call(GLFWmonitor* monitor, int* count) {
   return glfwGetVideoModes(monitor, count);
 }
Ejemplo n.º 26
0
Archivo: monitors.c Proyecto: kypp/glfw
static void test_modes(GLFWmonitor* monitor)
{
    int i, count;
    GLFWwindow* window;
    const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);

    for (i = 0;  i < count;  i++)
    {
        const GLFWvidmode* mode = modes + i;
        GLFWvidmode current;

        glfwWindowHint(GLFW_RED_BITS, mode->redBits);
        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);

        printf("Testing mode %u on monitor %s: %s\n",
               (unsigned int) i,
               glfwGetMonitorName(monitor),
               format_mode(mode));

        window = glfwCreateWindow(mode->width, mode->height,
                                  "Video Mode Test",
                                  glfwGetPrimaryMonitor(),
                                  NULL);
        if (!window)
        {
            printf("Failed to enter mode %u: %s\n",
                   (unsigned int) i,
                   format_mode(mode));
            continue;
        }

        glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
        glfwSetKeyCallback(window, key_callback);

        glfwMakeContextCurrent(window);
        gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
        glfwSwapInterval(1);

        glfwSetTime(0.0);

        while (glfwGetTime() < 5.0)
        {
            glClear(GL_COLOR_BUFFER_BIT);
            glfwSwapBuffers(window);
            glfwPollEvents();

            if (glfwWindowShouldClose(window))
            {
                printf("User terminated program\n");

                glfwTerminate();
                exit(EXIT_SUCCESS);
            }
        }

        glGetIntegerv(GL_RED_BITS, &current.redBits);
        glGetIntegerv(GL_GREEN_BITS, &current.greenBits);
        glGetIntegerv(GL_BLUE_BITS, &current.blueBits);

        glfwGetWindowSize(window, &current.width, &current.height);

        if (current.redBits != mode->redBits ||
                current.greenBits != mode->greenBits ||
                current.blueBits != mode->blueBits)
        {
            printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
                   current.redBits, current.greenBits, current.blueBits,
                   mode->redBits, mode->greenBits, mode->blueBits);
        }

        if (current.width != mode->width || current.height != mode->height)
        {
            printf("*** Size mismatch: %ix%i instead of %ix%i\n",
                   current.width, current.height,
                   mode->width, mode->height);
        }

        printf("Closing window\n");

        glfwDestroyWindow(window);
        window = NULL;

        glfwPollEvents();
    }
}
Ejemplo n.º 27
0
static void test_modes(void)
{
    int i, count;
    GLFWvidmode* modes = glfwGetVideoModes(&count);

    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    glfwSetKeyCallback(key_callback);

    for (i = 0;  i < count;  i++)
    {
        GLFWvidmode* mode = modes + i;
        GLFWvidmode current;

        glfwWindowHint(GLFW_RED_BITS, mode->redBits);
        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);

        printf("Testing mode %u: %s", (unsigned int) i, format_mode(mode));

        window = glfwCreateWindow(mode->width, mode->height,
                                  GLFW_FULLSCREEN, "Video Mode Test",
                                  NULL);
        if (!window)
        {
            printf("Failed to enter mode %u: %s\n",
                   (unsigned int) i,
                   format_mode(mode));
            continue;
        }

        glfwMakeContextCurrent(window);
        glfwSwapInterval(1);

        glfwSetTime(0.0);

        while (glfwGetTime() < 5.0)
        {
            glClear(GL_COLOR_BUFFER_BIT);
            glfwSwapBuffers(window);
            glfwPollEvents();

            if (!window)
            {
                printf("User terminated program\n");
                exit(EXIT_SUCCESS);
            }
        }

        glGetIntegerv(GL_RED_BITS, &current.redBits);
        glGetIntegerv(GL_GREEN_BITS, &current.greenBits);
        glGetIntegerv(GL_BLUE_BITS, &current.blueBits);

        glfwGetWindowSize(window, &current.width, &current.height);

        if (current.redBits != mode->redBits ||
            current.greenBits != mode->greenBits ||
            current.blueBits != mode->blueBits)
        {
            printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
                   current.redBits, current.greenBits, current.blueBits,
                   mode->redBits, mode->greenBits, mode->blueBits);
        }

        if (current.width != mode->width || current.height != mode->height)
        {
            printf("*** Size mismatch: %ix%i instead of %ix%i\n",
                   current.width, current.height,
                   mode->width, mode->height);
        }

        printf("Closing window\n");

        glfwDestroyWindow(window);
        glfwPollEvents();
        window = NULL;
    }
}