void init(int argc, char* argv[]) { setupGLUT(argc, argv); setupGLEW(); setupOpenGL(); setupCallbacks(); }
void window_init(struct window_t* w, const char* title, const unsigned int width, const unsigned int height, struct window_t* parent) { glfwWindowHint(GLFW_RESIZABLE, false); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); GLFWwindow* sharedContext = (parent == NULL) ? NULL : parent->handle; w->handle = glfwCreateWindow(width, height, title, NULL, sharedContext); w->width = width; w->height = height; if (w->handle == NULL) { ZF_LOGF("Could not create GLFW window."); } setupOpenGL(w, width, height); }
bool Engine::init() { if (!app) { Log::print("App not informed"); return false; } if (!initSDL()) { return false; } setupOpenGL(); if (!initSDLWindow()) { return false; } if (!initSDLGLContext()) { return false; } if (!initGLEW()) { return false; } printVersions(); if (!app->init()) { return false; } reshape(); return true; }
bool CDotWars::onInit() { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) return false; if((pScreenSurf = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) return false; //if we got here all is well setupOpenGL(); return true; }
void agg_renderer<T>::start_map_processing(Map const& map) { if(!setupOpenGLDone){ setupOpenGL(map); setupOpenGLDone = true; } MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Start map processing bbox=" << map.get_current_extent(); ras_ptr->clip_box(0,0,width_,height_); glEnable(GL_MULTISAMPLE); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); }
int main(int argc, char **argv) { setupOpenGL(&argc, argv, "Kinematics", 512, 512); // initialization code Init(); // registration of callbacks glutDisplayFunc(displayFunction); glutIdleFunc(idleFunction); glutKeyboardFunc(keyboardFunction); glutReshapeFunc(reshapeFunction); // entering the main loop glutMainLoop(); return 0; }
// this uses strings and vectors heavily so it is OK to use 'using' void WindowManager::setWinParams(TInt winId, const std::string ¶ms) { TuringWindow* win = getWin(winId); std::vector<std::string> items; WindowManager::split(items, params, ","); std::vector<std::string>::const_iterator item = items.begin(); for (; item != items.end(); ++item) { std::vector<std::string> parts; split(parts,*item, ":;"); // split by either if (parts.size() == 0) TuringCommon::runtimeError("Malformed window format specifier component."); std::string tagname = parts[0]; if ((tagname.compare("graphics") == 0 || tagname.compare("screen") == 0) && parts.size() == 3) { // graphics:x;y int x = atoi(parts[1].c_str()); int y = atoi(parts[2].c_str()); if (x < 1 || y < 1) { TuringCommon::runtimeError("Tried to create a window with negative or zero size"); } win->Width = x; win->Height = y; win->Win.SetSize(x,y); } else if (tagname.compare("title") == 0 && parts.size() == 2) { // title:name win->Title = parts[1]; } else if (tagname.compare("offscreenonly") == 0) { win->OffScreenOnly = true; } else if (tagname.compare("nooffscreenonly") == 0) { win->OffScreenOnly = false; } else { TuringCommon::runtimeError("Don't recognize window option. Might just not be implemented.",true); // true = warn } } win->Win.Create(sf::VideoMode(win->Width,win->Height), win->Title,sf::Style::Close,Settings); //set up OpenGL setupOpenGL(win); // clearWin(winId); }
void Win32RenderWindow::SetupRenderWindow() { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left = (long)0; // Set Left Value To 0 WindowRect.right = (long)mWidth; // Set Right Value To Requested Width WindowRect.top = (long)0; // Set Top Value To 0 WindowRect.bottom = (long) mHeight; // Set Bottom Value To Requested Height //fullscreen=fullscreenflag; // Set The Global Fullscreen Flag hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window. //wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages wc.lpfnWndProc = (WNDPROC) Win32RenderWindow::WindowsCallback; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "OpenGL"; // Set The Class Name if (!RegisterClass(&wc)) // Attempt To Register The Window Class { MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); } /*if (fullscreen) // Attempt Fullscreen Mode? { DEVMODE dmScreenSettings; // Device Mode memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode. if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE } else { // Pop Up A Message Box Letting User Know The Program Is Closing. MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); return FALSE; // Return FALSE } } }*/ //if (fullscreen) // Are We Still In Fullscreen Mode? //{ // dwExStyle=WS_EX_APPWINDOW; // Window Extended Style // dwStyle=WS_POPUP; // Windows Style // ShowCursor(FALSE); // Hide Mouse Pointer //} //else //{ dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style //} AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size // Create The Window hWnd = CreateWindowEx( dwExStyle, // Extended Style For The Window "OpenGL", // Class Name "GLEngine", // Window Title dwStyle | // Defined Window Style WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN, // Required Window Style 0, 0, // Window Position mWidth, // Calculate Window Width mHeight, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL); // Dont Pass Anything To WM_CREATE //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; hDC = GetDC(hWnd); // Did We Get A Device Context? //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} PixelFormat = ChoosePixelFormat(hDC,&pfd); // Did Windows Find A Matching Pixel Format? //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} SetPixelFormat(hDC,PixelFormat,&pfd); // Are We Able To Set The Pixel Format? //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} hRC = wglCreateContext(hDC); // Are We Able To Get A Rendering Context? //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} wglMakeCurrent(hDC,hRC); // Try To Activate The Rendering Context //{ // KillGLWindow(); // Reset The Display // MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); //} ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window //ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen mProcessMessageDelegate = new ProcessMessageDelegate<Win32RenderWindow>(this, &Win32RenderWindow::ProcessMessage); GLenum err = glewInit(); setupOpenGL(); }
/** * this method is used to initialize the gl window */ void GLWindow::init(){ setupOpenGL(); fpsTimer.restart(); }