Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 27, 2011, 10:09 PM   #1
ccjimmy
macrumors newbie
 
Join Date: Mar 2011
TITLE problem about the application created using glut

hi, all
When my application switched between fullscreeen/windowed, looks like the title will disappeared.
This problem occured only on MAC and it works will on Windows.

I've write a sample code below, it will works both on MAC and Windows, i don't know why the title dissappeared on MAC but works well on Windows

USING number-key "1" to switch between windows/fullscreen.

Code:
#include <stdio.h>
#include "GLUT.h"
#include <stdlib.h>
static int fullScr = 0;
static bool windowed = true;

void Update(int para)
{
glutPostRedisplay();
glutTimerFunc(17,Update,0);
}

void exitfunc(int para)
{
exit(0);
}
void key_process(unsigned char key,int x,int y)
{

if(key == '\033')
{    
exit(0);
}
if(key == 49/*num key 1*/)
{
windowed = windowed?false:true;
}
if(!windowed)
{
glutFullScreen();
}
else
{    
glutReshapeWindow(1024,768);
glutPositionWindow(100,100);
}
}

void display()  
{ 
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}

int main(int argc, char ** argv)  
{  
    glutInit(&argc, argv);  
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
if(!fullScr)
{
windowed = true;
glutInitWindowSize(1024,768);    
}
    glutCreateWindow("Xcode Glut Demo");    
glutTimerFunc(17, Update,0);
glutDisplayFunc(display);
glutKeyboardFunc(key_process);
if(fullScr)
{
windowed = false;
glutFullScreen();
}    

    glutMainLoop();  
}

Last edited by kainjow; Apr 27, 2011 at 11:01 PM. Reason: code tags
ccjimmy is offline   0 Reply With Quote
Old Apr 27, 2011, 10:52 PM   #2
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
What you describe is correct behavior on Mac OS.

Actually the title is set it's just that in full-screen mode window decorations such as the title bar are not drawn.

Perhaps I misunderstand the question being asked?

Last edited by lloyddean; Apr 27, 2011 at 11:01 PM.
lloyddean is offline   0 Reply With Quote
Old Apr 28, 2011, 12:56 AM   #3
ccjimmy
Thread Starter
macrumors newbie
 
Join Date: Mar 2011
In Windows XP, when I create a windows using this code, the titile of the window shows "Xcode Glut Demo",I switch the window mode to FULLSCREEN, and then switch back to WINDOWED mode, the title always there.

but In MAC OS, I create the window and it shows the window-title "Xcode Glut Demo", then I switch to FULLSCREEN mode, after that, I switch th FULLSCREEN mode back tu WINDOWED mode, the Title disappeared....


My English is poor, I wish I could express myself clearly to you...

thanks so much!
ccjimmy is offline   0 Reply With Quote
Old Apr 28, 2011, 01:37 AM   #4
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
It seems that GLUT creates a new window when you exit full-screen and you need to reset the window title. But more so, you need let Mac OS X process the window creation events before you do this otherwise there is no actual window for glutSetWindowTitle to operate on.

I was able to fix your code with this:
Code:
void reset_window_title(int para)
{
    glutSetWindowTitle("XCode Glut Demo");
}

void key_process(unsigned char key,int x,int y)
{
    
    if(key == '\033')
    {    
        exit(0);
    }
    if(key == 49/*num key 1*/)
    {
        windowed = windowed?false:true;
        if(!windowed)
        {
            glutFullScreen();
        }
        else
        {    
            glutReshapeWindow(1024,768);
            glutPositionWindow(100,100);
            glutTimerFunc(0, reset_window_title, 0);
        }
    }
}
Using a 0 millisecond timer, the timer fires immediately. But all that does is append an event to the event queue. The important thing is that the event is appended after the window creation events.
jiminaus is offline   0 Reply With Quote
Old Apr 28, 2011, 02:40 AM   #5
ccjimmy
Thread Starter
macrumors newbie
 
Join Date: Mar 2011
jiminaus
thanks
it really works!
Thank u Very much!!
ccjimmy is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Problem saving bookmarks/links on Safari title bar Lightning Bolt iPad Tips, Help and Troubleshooting 5 Feb 12, 2014 06:43 PM
Waiting Application Problem artblue iPod touch 1 Nov 1, 2012 08:10 PM
Annoying photo syncing problem: can't sort by title, help brinycbri iPhone 1 Oct 22, 2012 08:21 PM
Anyone know how to find out which application created this folder? Glassed Silver OS X 4 Aug 2, 2012 03:09 PM

Forum Jump

All times are GMT -5. The time now is 03:16 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC