• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SuperVGA

Vsync with GLee

3 posts in this topic

Hi Guys,

 

I've again stuck with something I shouldn't and spent way too much time staring myself blind on something what I thought was simple. I got it to work some time ago, but lost my code for it. I even did a small app to demonstrate my issue.

 

I can't for the world make my windowed gl context start up with vsync enabled (The vsync state is decided by the driver) - once I enter glutGameMode and go back to windowed mode, vsync is now enabled. I have vsync set as the first thing after these two very important lines:

// Initialize glut
glutInit(&argc, argv);
// Initialize glee
GLeeInit();

Followed by:

glutInitWindowSize(gl_current_width, gl_current_height);
glut_window_hWnd = glutCreateWindow(window_title.c_str());
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_STENCIL);

// Set swap interval
#ifdef _WIN32
 char *extensions = (char*)glGetString( GL_EXTENSIONS );
 if( strstr( extensions, "WGL_EXT_swap_control\0" ) == 0 )
 {
  return; // Error: WGL_EXT_swap_control extension not supported on your computer.");
 }
 else
 {
  wglSwapIntervalEXT = (GLEEPFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress( "wglSwapIntervalEXT\0" );
  if( wglSwapIntervalEXT )
  {
   wglSwapIntervalEXT(1);
  }
 }
#endif
#ifdef __linux__
 glXSwapIntervalSGI(1);    // Nix
#endif

I can't make it work without changing display mode. Should I call wglSwapIntervalEXT elsewhere?

I think GLee supplies wglSwapIntervalEXT already, and I've noticed that it ends up targeting the same procedure, but I just wanted to make sure.

Calling wglSwapIntervalEXT(1) should've been sufficient.

 

I've tested on 4 cards; an nVidia GTX 275, an AMD Radeon 6500M, an nVidia Quadro 3000M and Intel HD 4500.

All exhibit the same behaviour (also, all run Win7 64bit. It might have something to do with it, although I can't see why)

 

 

EDIT: Why, thank you for removing half of my post! smile.png

EDIT 2: Sanitized code, removed religious glError checks...

Edited by SuperVGA
0

Share this post


Link to post
Share on other sites

Have you tried enabling VSync after creating the window (on GLUT i think it was called glutCreateWindow(), not sure though), if it was not created before?

 

I've never actually tried to having VSync enabled at startup, i only had it possible to enable it by pressing a key.

1

Share this post


Link to post
Share on other sites

Have you tried enabling VSync after creating the window (on GLUT i think it was called glutCreateWindow(), not sure though), if it was not created before?

 

I've never actually tried to having VSync enabled at startup, i only had it possible to enable it by pressing a key.

Whoops, Thanks! -looks like I accidentally erased that line when I first cleaned tabs and spaces in my post. (I fixed it now) smile.png

I also tested with setting the statement before glutCreateWindow(), that results in the GL error 1282 (Invalid operation) - I guess because the context is not ready at that point.

 

Now here's hoping someone tried starting up with vsync enabled...

 

EDIT: No, it was there all along, and in the wrong place too. I'm just blind...

Edited by SuperVGA
0

Share this post


Link to post
Share on other sites

I managed to fix it! You brought my attention to glutCreateWindow, and then I looked at the order of the other statements.

I also thought it was weird to set glutInitDisplayMode after glutCreateWindow. anyways, this is the order i ended up with, and it works! :)

 

glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_STENCIL);
glutInitWindowSize(gl_current_width, gl_current_height);
glut_window_hWnd = glutCreateWindow(window_title.c_str());
// Set swap interval...

 

(Also, it's incredible what difference a trip to the man pages can do. That and the religious error checking L. Spiro suggested is two of the best pieces of advice I realized/got for OpenGL)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0