OpenGLVersion GetGlVersion() override { assert(this->_window != NULL); OpenGLVersion ret; ret.major = glfwGetWindowAttrib(this->_window, GLFW_CONTEXT_VERSION_MAJOR); ret.minor = glfwGetWindowAttrib(this->_window, GLFW_CONTEXT_VERSION_MINOR); ret.revision = glfwGetWindowAttrib(this->_window, GLFW_CONTEXT_REVISION); ret.glslVersion = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); ret.glewVersion = (const char*) glewGetString(GLEW_VERSION); ret.fullGLVersion = (const char*) glGetString(GL_VERSION); ret.glVendor = (const char*) glGetString(GL_VENDOR); ret.glRenderer = (const char*) glGetString(GL_RENDERER); return ret; }
void initExtLibs() { // glew GLenum err = glewInit(); ASSERT(GLEW_OK == err ); TRACE( "Using GLEW %s\n", glewGetString(GLEW_VERSION)); // devil ilInit(); iluInit(); // force same origin for all image files (pngs can be flipped on Y, etc) ilOriginFunc(IL_ORIGIN_UPPER_LEFT); ilEnable(IL_ORIGIN_SET); }
int main(int argc, char* argv[]) { printf("GLEW CMake test, %s build\n", S(GLEW_CMAKE_TEST_CONFIG)); printf("-- linked to %s which is %s\n", S(GLEW_CMAKE_TEST_TARGET_FILE_NAME), S(GLEW_CMAKE_TEST_TARGET_TYPE)); const GLubyte* v = glewGetString(GLEW_VERSION); if(v) { printf("-- glewGetString(GLEW_VERSION) returns %s\n-- test passed.\n", v); return EXIT_SUCCESS; } else { printf("-- glewGetString(GLEW_VERSION) returns NULL\n-- test failed.\n"); return EXIT_FAILURE; } }
void Canvas::Render() { if(m_context) { int width, height; GetClientSize(&width, &height); SetCurrent(*m_context); // because calling SetCurrent() at the wrong time causes a messed up gdk error in X. The following works but it's pretty ugly. if(!m_lazy_init) { // must be initialized for this GL context GLenum err = glewInit(); if(err != GLEW_OK) { fprintf(stderr, "glewInit error: %s\n", glewGetErrorString(err)); } printf("Using GLEW %s\n", glewGetString(GLEW_VERSION)); m_lazy_init = true; } // lazy-init (enter) canvas controllers since some of them rely on glew being initialized. if(m_last_controller != m_controller) { if(m_last_controller) { m_last_controller->Exit(); } if(m_controller) { m_controller->Enter(); } m_last_controller = m_controller; } glEnable(GL_LINE_SMOOTH); if(m_controller) { m_controller->SetCameraSize(width, height); m_controller->Render(width, height); } else { glViewport(0,0,width,height); glClearColor(0.2f,0.1f,0.1f,1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); } SwapBuffers(); } }
void sreBackendGLFW::Initialize(int *argc, char ***argv, int requested_width, int requested_height, int& actual_width, int& actual_height, unsigned int backend_flags) { glfwInit(); // Require OpenGL >= 3.0. // glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 0); // Because we use glBindAttribute for compability with OpenGL ES 2.0, we do not have forward compability. // glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if (backend_flags & SRE_BACKEND_INIT_FLAG_MULTI_SAMPLE) // Enable multi-sample anti-aliasing glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); int r; if (backend_flags & SRE_BACKEND_INIT_FLAG_STENCIL_BUFFER) r = glfwOpenWindow(requested_width, requested_height, 8, 8, 8, 8, 24, 8, GLFW_WINDOW); else r = glfwOpenWindow(requested_width, requested_height, 8, 8, 8, 8, 24, 0, GLFW_WINDOW); if (!r) { printf("Failed to open GLFW window.\n"); glfwTerminate(); exit(1); } glfwGetWindowSize(&actual_width, &actual_height); glfwSetWindowTitle("SRE demo -- OpenGL rendering demo using GLFW"); int stencil_bits = glfwGetWindowParam(GLFW_STENCIL_BITS); int depth_bits = glfwGetWindowParam(GLFW_DEPTH_BITS); printf("Opened GLFW context of size %d x %d with 32-bit pixels, %d-bit depthbuffer and %d-bit stencil.\n", actual_width, actual_height, depth_bits, stencil_bits); glfwSetWindowSizeCallback(WindowResizeCallback); glfwSetKeyCallback(KeyCallback); glfwSetMousePosCallback(MousePosCallback); glfwSetMouseButtonCallback(MouseButtonCallback); // Don't poll events during glfwSwapBuffers but require explicit calls to glfwPollEvents(). glfwDisable(GLFW_AUTO_POLL_EVENTS); // Generate multiple keypress events when a key is held down. // glfwEnable(GLFW_KEY_REPEAT); // if (fullscreen_mode) // glfwSetMousePos(window_width / 2, window_height / 2); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); exit(1); } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); initialized = true; }
// ------------------------------------------------------------------- main --- int main( int argc, char **argv ) { glutInit( &argc, argv ); glutInitWindowSize( 800, 400 ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); glutCreateWindow( argv[0] ); glutReshapeFunc( reshape ); glutDisplayFunc( display ); glutKeyboardFunc( keyboard ); #ifndef __APPLE__ glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf( stderr, "Error: %s\n", glewGetErrorString(err) ); exit( EXIT_FAILURE ); } fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) ); #endif size_t i; texture_font_t *font = 0; texture_atlas_t *atlas = texture_atlas_new( 512, 512, 1 ); const char * filename = "fonts/Vera.ttf"; wchar_t *text = L"A Quick Brown Fox Jumps Over The Lazy Dog 0123456789"; buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" ); vec2 pen = {{5,400}}; vec4 black = {{0,0,0,1}}; for( i=7; i < 27; ++i) { font = texture_font_new_from_file( atlas, i, filename ); pen.x = 5; pen.y -= font->height; texture_font_load_glyphs( font, text ); add_text( buffer, font, text, &black, &pen ); texture_font_delete( font ); } glBindTexture( GL_TEXTURE_2D, atlas->id ); shader = shader_load("shaders/v3f-t2f-c4f.vert", "shaders/v3f-t2f-c4f.frag"); mat4_set_identity( &projection ); mat4_set_identity( &model ); mat4_set_identity( &view ); glutMainLoop( ); return 0; }
int main (int argc, char ** argv) { exitCounter = 0; GLenum type; glutInit(&argc, argv); glutInitWindowSize(CurrentWidth,CurrentHeight); type = GLUT_RGB; type |= GLUT_DOUBLE; type |= GLUT_DEPTH; type |= GLUT_MULTISAMPLE; glutInitDisplayMode(type); glutCreateWindow(""); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); glClearColor(0.0, 0.0, 0.0, 0.0); // Z-Buffer i aciyoruz glEnable(GL_DEPTH_TEST); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); const GLubyte* glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); printf("GLSL Version: %s\n",glslVersion); const GLubyte* glVersion = glGetString(GL_VERSION); printf("GL Version: %s\n",glVersion); setupScene(); timerCallback(0); glutReshapeFunc(ResizeFunction); glutDisplayFunc(Draw); glutKeyboardFunc(Key); glutIdleFunc(IdleFunction); glutMainLoop(); return 0; }
//init the GL void InitGL(void) { cout <<"OpenGL ver." << glGetString(GL_VERSION) << endl; GLenum err = glewInit(); if(err == GLEW_OK){ cout<<"GLEW OK : GLew ver. "<< glewGetString(GLEW_VERSION)<<endl; } else{ cout << "GLEW Error :"<<glewGetErrorString(err) << endl; } //multisample GLint buf,sbuf; glGetIntegerv(GL_SAMPLER_BUFFER,&buf); cout<<"number of sample buffers is "<<buf<<endl; glGetIntegerv(GL_SAMPLES,&sbuf); cout<<"number of samples is " <<sbuf << endl; glClearColor((GLfloat)g_fBGColor[0],(GLfloat)g_fBGColor[1],(GLfloat)g_fBGColor[2],1.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glEnable(GL_MULTISAMPLE); //nomalize the polygon glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); //set up the light static const GLfloat lpos[] = {0.0f,0.0f,1.0f,1.0f};//position of the light static const GLfloat difw[] = {0.7f,0.7f,0.7f,1.0f};//diffuse static const GLfloat spec[] = {0.2f,0.2f,0.2f,1.0f};//specular static const GLfloat ambi[] = {0.1f,0.1f,0.1f,1.0f};//ambient glLightfv(GL_LIGHT0,GL_POSITION,lpos); glLightfv(GL_LIGHT0,GL_DIFFUSE,difw); glLightfv(GL_LIGHT0,GL_SPECULAR,spec); glLightfv(GL_LIGHT0,GL_AMBIENT,ambi); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); //init the trackball g_tbView.SetScaling(-5.0f); }
int main (int argc, char **argv) { glutInit(&argc, argv); // Done TODO: activate stencil buffer // glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL); glutInitContextVersion(3,3); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); windowWidth = 512; windowHeight = 512; glutInitWindowSize(windowWidth, windowHeight); glutInitWindowPosition(100, 100); glutCreateWindow("Exercise 10 - Shadow Volumes"); glutDisplayFunc(updateGL); glutIdleFunc(idle); glutKeyboardFunc(keyboardEvent); glutMouseFunc(mouseEvent); glutMotionFunc(mouseMoveEvent); glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { std::cout << "(glewInit) - Error: " << glewGetErrorString(err) << std::endl; } std::cout << "(glewInit) - Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; // init stuff // initGL(); // init matrix stacks with identity // glm_ProjectionMatrix.push(glm::mat4(1)); glm_ModelViewMatrix.push(glm::mat4(1)); initShader(); initScene(); // start render loop // if (enableShader()) { glutMainLoop(); disableShader(); // clean up allocated data // deleteShader(); } return 0; }
static void initializeGL() { //Initialize GLEW glewExperimental = GL_TRUE; GLenum err = glewInit(); if( GLEW_OK != err ) LOG( error, "[GLEW] " << glewGetErrorString(err) ); LOG( info, "[GLEW] using version " << glewGetString( GLEW_VERSION ) ); //Initialize OpenGL context glcheck(glClearColor(0.8f,0.8f,0.8f,1.0f)); glcheck(glEnable(GL_DEPTH_TEST)); glcheck(glDepthFunc(GL_LESS)); glcheck(glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); glcheck(glEnable(GL_TEXTURE_2D)); }
int main(int argc, char **argv) { glutInitWindowSize(1000, 1000); glutCreateWindow("simple"); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ printf("Error: %s\n", glewGetErrorString(err)); } printf("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); init(); glutDisplayFunc(display); glutSpecialFunc(Special); glutMainLoop(); }
int main(void) { myApplication* pApp = new myApplication; myWindow* myWin = new myWindow(); GLenum err = glewInit(); if (GLEW_OK != err) { std::cout << "Failed to initialize GLEW!" << std::endl; } std::cout << "Using GLEW Version: " << glewGetString(GLEW_VERSION) << std::endl; pApp->run(); delete pApp; return 0; }
bool init() { GLenum err = glewInit(); if (err != GLEW_OK) { std::cerr << "Error: " << glewGetErrorString(err) << "\n"; exit(err); } std::cout << "GLEW " << glewGetString(GLEW_VERSION) << " loaded.\n"; std::cout << "Using OpenGL " << glGetString(GL_VERSION) << ".\n"; p = new Program(); Shader vert("Vert", Shader::type::vertex); Shader frag("Frag", Shader::type::fragment); p->attach(vert); p->attach(frag); p->link(); return true; }
GlutWindow::GlutWindow ( const char* label, int x, int y, int w, int h ) { // Check if this is the only instance if ( Singleton ) std::cout<<"WARNING: The support code has not been tested with multiple GLUT Windows!\n"; // First store this instance in our singleton pointer Singleton = this; // Set window position (from top corner), and size (width and height) glutInitWindowPosition ( x, y ); glutInitWindowSize ( w, h ); glutCreateWindow ( label ); // Init glew library (after a glut window is created!): glewExperimental = GL_TRUE; GLenum res = glewInit(); if ( res!=GLEW_OK ) std::cout<<glewGetString(GLEW_VERSION)<<", Error: "<<glewGetErrorString(res)<<"\n"; glPrintInfo(); // Initialize OpenGL settings as we want glEnable ( GL_DEPTH_TEST ); glEnable ( GL_POINT_SMOOTH ); glEnable ( GL_LINE_SMOOTH ); glHint ( GL_LINE_SMOOTH_HINT, GL_NICEST ); glHint ( GL_POINT_SMOOTH_HINT, GL_NICEST ); glPointSize ( 4 ); glLineWidth ( 2 ); // Set up GLUT callback functions to receive events: ::glutKeyboardFunc ( glutKeyboardCB ); ::glutSpecialFunc ( glutSpecialCB ); ::glutMouseFunc ( glutMouseCB ); ::glutMotionFunc ( glutMotionCB ); // Set up idle callback for background processing if needed: ::glutIdleFunc ( glutIdleCB ); // Set up GLUT callback function for resizing window: ::glutReshapeFunc ( glutReshapeCB ); // Set up GLUT callback for drawing the scene: ::glutDisplayFunc ( glutDisplayCB ); // GLUT also supports a simple menu system, you may try this: int id = ::glutCreateMenu ( glutMenuCB ); // the returned id could be used for adding submenus if needed glutAttachMenu ( GLUT_RIGHT_BUTTON ); }
void glut_setup() { //redimensionnement glutReshapeFunc(glut_ReshapeWin); //affichage glutDisplayFunc(glut_render); //inactivité graphique glutIdleFunc(glut_program); //souris glutMouseFunc(glut_mouseClic); glutMotionFunc(glut_mouseClicMove); glutPassiveMotionFunc(glut_mouseMove); //clavier glutKeyboardFunc(glut_keyboard); glutKeyboardUpFunc(glut_keyboardUp); glutSpecialFunc(glut_keyboardSpecial); glutSpecialUpFunc(glut_keyboardSpecialUp); //initialisation de GLEW GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "Error GLEW : %s\n", glewGetErrorString(err)); } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); #ifdef GL_TIMER_QUERY_PERFORMANCE_MEASURE glGenQueries(1, &query); #endif testInstancing = new TestInstancing(); const float randMaxF = (float)RAND_MAX; for(int i=0;i<TEST_INSTANCING_MAX_INSTANCE;++i) { trianglePosition[i*3 ] = (float)(rand())/randMaxF; trianglePosition[i*3+1] = (float)(rand())/randMaxF; trianglePosition[i*3+2] = (float)(rand())/randMaxF; } glutSetCursor(GLUT_CURSOR_NONE); lastMX=400.0f; lastMY=300.0f; glutWarpPointer(400,300); }
int main( int argc, char **argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); glutCreateWindow( argv[0] ); glutReshapeFunc( on_reshape ); glutDisplayFunc( on_display ); glutKeyboardFunc( on_key_press ); glutSpecialFunc( on_special_key_press ); glutReshapeWindow( 600,400 ); #ifndef __APPLE__ glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf( stderr, "Error: %s\n", glewGetErrorString(err) ); exit( EXIT_FAILURE ); } fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) ); #endif console = console_new(); console_print( console, L"OpenGL Freetype console\n" L"Copyright 2011 Nicolas P. Rougier. All rights reserved.\n \n" ); console_connect( console, "activate", console_activate ); console_connect( console, "complete", console_complete ); console_connect( console, "history-prev", console_history_prev ); console_connect( console, "history-next", console_history_next ); glClearColor( 1.00, 1.00, 1.00, 1.00 ); glDisable( GL_DEPTH_TEST ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_TEXTURE_2D ); glEnable( GL_BLEND ); shader = shader_load("shaders/v3f-t2f-c4f.vert", "shaders/v3f-t2f-c4f.frag"); mat4_set_identity( &projection ); mat4_set_identity( &model ); mat4_set_identity( &view ); glutMainLoop(); return 0; }
void initialize_glew(void) { GLenum error; glewExperimental = GL_TRUE; error = glewInit(); if (error != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(error)); exit(-1); } fprintf(stdout, "*********************************************************\n"); fprintf(stdout, " - GLEW version supported: %s\n", glewGetString(GLEW_VERSION)); fprintf(stdout, " - OpenGL renderer: %s\n", glGetString(GL_RENDERER)); fprintf(stdout, " - OpenGL version supported: %s\n", glGetString(GL_VERSION)); fprintf(stdout, "*********************************************************\n\n"); }
/* Initialize the graphics state */ void graphicsInit() { // glew will help us use GL functions, so set it up here glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); exit(1); } printf("Using GLEW %s\n", glewGetString(GLEW_VERSION)); //Setup shaders char const * vertPath = "Shaders/simple.vert"; char const * fragPath = "Shaders/simple.frag"; shaderProg = ShaderManager::shaderFromFile(&vertPath, &fragPath, 1, 1); }
void initGlew() { glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err){ std::cerr<<"Error: "<<glewGetErrorString(err)<<std::endl; } else { if (GLEW_VERSION_3_3) { std::cout<<"Driver supports OpenGL 3.3\nDetails:"<<std::endl; } } std::cout<<"\tUsing glew "<<glewGetString(GLEW_VERSION)<<std::endl; std::cout<<"\tVendor: "<<glGetString (GL_VENDOR)<<std::endl; std::cout<<"\tRenderer: "<<glGetString (GL_RENDERER)<<std::endl; std::cout<<"\tVersion: "<<glGetString (GL_VERSION)<<std::endl; std::cout<<"\tGLSL:"<<glGetString(GL_SHADING_LANGUAGE_VERSION)<<std::endl; }
static struct once { once() { // Initialize GLEW glewExperimental= GL_TRUE; GLenum err = glewInit (); if (GLEW_OK != err) { // Problem: glewInit failed, something is seriously wrong. std::cerr << "<gate/render/window.cpp> says: Error: " << glewGetErrorString (err) << std::endl; std::exit(1); } // Print some infos about user's OpenGL implementation if(0) { std::cout << "OpenGL Version String: " << glGetString (GL_VERSION) << std::endl; std::cout << "GLU Version String: " << gluGetString (GLU_VERSION) << std::endl; std::cout << "GLEW Version String: " << glewGetString (GLEW_VERSION) <<std::endl; } }} _2;
SCISHARE int sci_glew_init() { static int glew_init = 0; if(!glew_init) { GLenum err = glewInit(); glewExperimental = GL_TRUE; if (GLEW_OK != err ) { /* problem: glewInit failed, something is seriously wrong */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); return 1; } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); glew_init = 1; } return 0; }
/* * Initializes GLEW. */ void InitializeGLEW() { glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err != GLEW_OK) { std::ostringstream errmess; errmess << "GlfwWindow::Initialize(): " << "GLEW failed to initialize: " << glewGetErrorString(err) << ", (" << err << ") \n" << "Status, Using GLEW version: " << glewGetString(GLEW_VERSION) << std::endl; throw std::runtime_error(errmess.str()); std::cout << errmess.str(); } // Clear any system errors if any ErrorClear("Right after glewInit()"); }
void OpenGLWidget::initializeGL() { GLenum err = glewInit(); if (GLEW_OK != err) { cout << "Failed to init GLEW: " << glewGetErrorString(err) << endl; } std::cout << "Using GLEW Version: " << glewGetString(GLEW_VERSION) << endl; m_glContext->init(); // Set the clear color qglClearColor(m_clearColor); // Set up the rest of the rendering glEnable(GL_CULL_FACE); glShadeModel(GL_SMOOTH); }
void Enable_shader(void){ GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "Error %s\n", glewGetErrorString(err)); exit(1); } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); if (GLEW_ARB_vertex_program) fprintf(stdout, "Status: ARB vertex programs available.\n"); if (glewGetExtension("GL_ARB_fragment_program")) fprintf(stdout, "Status: ARB fragment programs available.\n"); if (glewIsSupported("GL_VERSION_1_4 GL_ARB_point_sprite")) fprintf(stdout, "Status: ARB point sprites available.\n"); }
int main (int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitContextVersion(3,3); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutInitWindowSize (512, 512); glutInitWindowPosition (100, 100); glutCreateWindow("Exercise 03 - More Bunnies!"); glutDisplayFunc(updateGL); glutIdleFunc(idle); glutKeyboardFunc(keyboardEvent); glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { std::cout << "(glewInit) - Error: " << glewGetErrorString(err) << std::endl; } std::cout << "(glewInit) - Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; // init stuff // initGL(); // init matrix stacks // glm_ProjectionMatrix.push(glm::mat4(2.414214, 0.000000, 0.000000, 0.000000, 0.000000, 2.414214, 0.000000, 0.000000, 0.000000, 0.000000, -1.002002, -1.000000, 0.000000, 0.000000, -0.020020, 0.000000)); glm_ModelViewMatrix.push(glm::mat4(0.707107, -0.408248, 0.577350, 0.000000, 0.000000, 0.816497, 0.577350, 0.000000, -0.707107, -0.408248, 0.577350, 0.000000, 0.000000, 0.000000, -1.732051, 1.000000)); initShader(); initScene(); // start render loop // if (enableShader()) { glutMainLoop(); disableShader(); // clean up allocated data // deleteScene(); deleteShader(); } return 0; }
int main(int argc, char **argv) { glutInit(&argc, argv); int display_mode = GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE; #ifdef OSX_CORE3 display_mode |= GLUT_3_2_CORE_PROFILE; #endif glutInitDisplayMode(display_mode); glutInitWindowSize(width, height); glutInitWindowPosition(0, 0); window_id = glutCreateWindow("Assignment"); #ifdef __GLEW_H__ GLenum err = glewInit(); if (GLEW_OK != err) { cerr << "Error: " << glewGetErrorString(err) << endl; exit(1); } cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << endl; #endif cout << "Status: Using OpenGL " << glGetString(GL_VERSION) << endl; cout << "Status: Using GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl; working_directory = string(argv[0]).substr(0, string(argv[0]).find_last_of("/\\")) + "/"; init(); create_menu(); glutReshapeFunc(reshapefunc); glutDisplayFunc(displayfunc); glutIdleFunc(idlefunc); glutPassiveMotionFunc(pmotionfunc); glutMotionFunc(motionfunc); glutMouseFunc(mousefunc); glutKeyboardFunc(keydownfunc); glutKeyboardUpFunc(keyupfunc); glutMainLoop(); }
Window::Window(Simulation *sim) : sim(sim) { std::cout << "GLFW version: " << glfwGetVersionString() << std::endl; glfwSetErrorCallback(window_error_callback); // Initialize GLFW if (!glfwInit()) { std::cerr << "GLFW error!" << std::endl; error = true; return; } // Create GLFW window window = glfwCreateWindow(640, 480, "CellSim", NULL, NULL); if (!window) { std::cerr << "Could not create GLFW window!" << std::endl; error = true; return; } glfwMakeContextCurrent(window); // Initialize GLEW GLenum glew_init = glewInit(); if (glew_init != GLEW_OK) { std::cerr << glewGetErrorString(glew_init) << std::endl; error = true; return; } std::cout << "GLEW version: " << glewGetString(GLEW_VERSION) << std::endl; // Set GLFW options glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GL_TRUE); glClearColor(0.0, 0.0, 0.2, 0.0); //glfwSetCursorPosCallback(window, cursor_callback); }
int main(int argc, char**argv) { glutInit(&argc, argv); glutInitWindowPosition(100,100); glutInitWindowSize(500,500); glutCreateWindow("Hello World"); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "Error: %s\n", glewGetErrorString(err));/* Problem: glewInit failed, something is seriously wrong. */ return 1; } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); // checking for extensions if ( !GLEW_ARB_shading_language_100 ) { printf ( "GL_ARB_shading_language_100 NOT supported.\n" ); return 2; } printf ( "GL_ARB_shading_language_100 is supported.\n" ); if ( !GLEW_ARB_shader_objects ) { printf ( "GL_ARB_shader_objects NOT supported\n" ); return 3; } printf ( "GL_ARB_shader_objects is supported\n" ); if (!GLEW_ARB_vertex_shader || !GLEW_ARB_fragment_shader) { printf("No GLSL support\n"); exit(4); } printf(" GLSL is supported\n"); glutDisplayFunc(display); glutMainLoop(); }
bool Renderer::initGLEW() { gLog.info("initializing GLEW...\n"); glewExperimental = GL_TRUE; GLenum error = glewInit(); // ignore any errors from inside GLEW glGetError(); if (error != GLEW_OK) { gLog.err("glewInit failed: %s\n", glewGetErrorString(error)); return false; } else { gLog.info("using GLEW %s\n", glewGetString(GLEW_VERSION)); } utils::checkGLAvailability(); return true; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("Image Processing"); glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } std::cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; std::cout << "OpenGL version " << glGetString(GL_VERSION) << " supported" << std::endl; initVAO(); initTextures(); passthroughProgram = initShader("passthroughVS.glsl", "passthroughFS.glsl"); boxBlurProgram = initShader("passthroughVS.glsl", "boxBlurFS.glsl"); //=========================================================================== imageNegativeProgram = initShader("passthroughVS.glsl", "hy_imageNegative.glsl"); gaussianBlurProgram = initShader("passthroughVS.glsl", "hy_gaussianBlur.glsl"); grayScaleFSProgram = initShader("passthroughVS.glsl", "hy_grayScale.glsl"); edgeDetectionProgram = initShader("passthroughVS.glsl", "hy_edgeDetection.glsl"); toonShadingProgram = initShader("passthroughVS.glsl", "hy_toonShading.glsl"); pixelateProgram = initShader("passthroughVS.glsl", "hy_pixelate.glsl"); brightnessProgram = initShader("passthroughVS.glsl", "hy_brightness.glsl"); nightVisionProgram = initShader("passthroughVS.glsl", "hy_nightVision.glsl"); constractProgram = initShader("passthroughVS.glsl", "hy_contrast.glsl"); //=========================================================================== glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); glutMainLoop(); return 0; }