/* * main() * ---- * Start up GLUT and tell it what to do */ int main(int argc,char* argv[]) { initializeGlobals(); /* screencast specific variables */ windowName = "OpenGL screenscasts 14: Textures part 1"; screencastID = 14; dim = 4; fov = 50; th = -25; ph = 15; ecX = -0.4; ecZ = -2.0; distance = 2; glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(windowWidth,windowHeight); glutCreateWindow(windowName); glutDisplayFunc(display); glutReshapeFunc(displayReshape); glutKeyboardFunc(windowKey); glutSpecialFunc(windowSpecial); initializeTextures(); redisplayAll(); glutMainLoop(); return 0; }
void MyGLWidget::initializeGL() { // Enable GL textures glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); setFixedHeight(480); setFixedWidth(640); //glEnable(GL_CULL_FACE); // Draw Front or Back? glClearColor(1.0, 0.0, 0.0, 0.0) ; glClearDepth(1.0) ; glDepthFunc(GL_LESS) ; glEnable(GL_DEPTH_TEST) ; glShadeModel(GL_SMOOTH) ; glEnable(GL_TEXTURE_2D); // Enable texturing glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glDisable(GL_TEXTURE_2D); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear values used by glClear (Color-Buffer) loadModel(); initializeTextures(); initalizeBuffer(); initalizeShader(); }
virtual bool initialize() { //initializeLighting(); if (!initializeTextures()) { return false; } return true; }
/* * main() * ---- * Start up GLUT and tell it what to do */ int main(int argc,char* argv[]) { initializeGlobals(); /* screencast specific variables */ windowName = "OpenGL screenscasts 17: Animation part 2"; screencastID = 17; toggleAxes = 0; toggleAnimation = 0; glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(windowWidth,windowHeight); glutInitWindowPosition(450,350); glutCreateWindow(windowName); glutDisplayFunc(display); glutReshapeFunc(displayReshape); glutKeyboardFunc(windowKey); glutSpecialFunc(windowSpecial); initializeTextures(); initializeObjs(); timer(toggleAnimation); redisplayAll(); glutMainLoop(); return 0; }
void MyGLWidget::initializeGL() { glEnable(GL_DEPTH_TEST); // Activate depth comparisons and update depth buffer glEnable(GL_CULL_FACE); // Draw Front or Back? glDepthFunc(GL_LEQUAL); // Specify the depth buffer //glShadeModel(GL_SMOOTH); // !Deprecated GL_FLAT or GL_SMOOTH (interpolated) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Are there Interpretations? Set hint! glClearDepth(1.0f); // Clear value for depth buffer (used by glClear) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear values used by glClear (Color-Buffer)(); loadModel(); initializeTextures(); initalizeBuffer(); initalizeShader(); initializePlanets(); attrVertices = shaderProgram.attributeLocation("vert"); // #version 130 attrTexCoords = shaderProgram.attributeLocation("texCoord"); // #version 130 // Aktiviere die Verwendung der Attribute-Arrays shaderProgram.enableAttributeArray(attrVertices); shaderProgram.enableAttributeArray(attrTexCoords); // Laden der // Ein paar Hilfsvariablen - die 8 steht für // 4 Eckpunktkoordinaten + 4 Texturkoordinaten int offset = 0 ; size_t stride = 8 * sizeof(GLfloat); shaderProgram.setAttributeBuffer(attrVertices,GL_FLOAT,offset,4,stride); offset += 4*sizeof(GLfloat); shaderProgram.setAttributeBuffer(attrTexCoords,GL_FLOAT,offset,4,stride); // Lokalisiere bzw. definierte die Schnittstelle für die Matritzen // Die Matrix kann direkt übergeben werden, da setUniformValue für diesen Typ überladen ist. unifMatrixPerspective = shaderProgram.uniformLocation("perspectiveMatrix"); Q_ASSERT(unifMatrixPerspective >= 0) ; unifMatrixModel = shaderProgram.uniformLocation("modelMatrix"); Q_ASSERT(unifMatrixModel >= 0) ; unifMatrixView = shaderProgram.uniformLocation("viewlMatrix"); Q_ASSERT(unifMatrixView >= 0) ; //qTex->bind(); }
bool PrismTexturedModel::InitializeVertexModels(ID3D11Device* d3dDevice){ bool result = false; for(int i=0;i<NUMBER_OF_TEXTURES; i++){ result = m_VertexModelArray[i]->Initialize(d3dDevice); if(!result) return false; } result = initializeTextures(d3dDevice); return result; }
void TriangleWindow::initialize() { initializeLighting(); glClearColor(0.0f,0.21f,0.21f,1.0f); glColor3f(1.0f,1.0f,1.0f); glEnable(GL_DEPTH_TEST); //Z-Buffer glDepthFunc(GL_LEQUAL); // Lesser or Equals glEnable(GL_CULL_FACE); glShadeModel(GL_SMOOTH); initializeShaders(); initializeTextures(); initializeVBO(); // glEnable(GL_TEXTURE_2D); }
bool CubeTexturedModel::InitializeVertexModels(ID3D11Device* d3dDevice){ //Initialize the vertex model and textures for the rendering to d3dDevice bool result = false; for(int i=0;i<NUMBER_OF_CUBE_FACES; i++){ result = m_VertexModelArray[i]->Initialize(d3dDevice); if(!result) return false; } result = initializeTextures(d3dDevice); //initialize the textures return result; }
void Tp2Application::initialize() { OpenGlApplication::initialize(); // Separate calculation of the specular contribution after texturing is done glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ); glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE ); glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE ); // Two-side mode in OpenGL glEnable( GL_VERTEX_PROGRAM_TWO_SIDE ); // Two-side mode in GLSL initializeTextures(); // Compile Display List compileQuadGridList(20.0f, 30, 30, TRUE); // The Vertex and Fragment Shaders are initialized in the constructor mShaderProgram = new Tp2ShaderProgram(&mIsPointLightOn, &mIsSpotLightOn, &mIsDirectionalLightOn); mShaderProgram->link(); }
int main(int argc, char *argv[]) { SDL_Window *window; /* main window */ SDL_Renderer *renderer; Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ Uint32 delay; /* time to pause waiting to draw next frame */ int done; /* should we clean up and exit? */ /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { fatalError("Could not initialize SDL"); } /* create main window and renderer */ // int bbp = SDL_VideoModeOK(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_FULLSCREEN); window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, 0, 0); /* print out some info about joysticks and try to open accelerometer for use */ printf("There are %d joysticks available\n", SDL_NumJoysticks()); printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0)); accelerometer = SDL_JoystickOpen(0); if (accelerometer == NULL) { fatalError("Could not open joystick (accelerometer)"); } printf("joystick number of axis = %d\n", SDL_JoystickNumAxes(accelerometer)); printf("joystick number of hats = %d\n", SDL_JoystickNumHats(accelerometer)); printf("joystick number of balls = %d\n", SDL_JoystickNumBalls(accelerometer)); printf("joystick number of buttons = %d\n", SDL_JoystickNumButtons(accelerometer)); /* load graphics */ initializeTextures(renderer); /* setup ship */ shipData.x = (SCREEN_WIDTH - shipData.rect.w) / 2; shipData.y = (SCREEN_HEIGHT - shipData.rect.h) / 2; shipData.vx = 0.0f; shipData.vy = 0.0f; done = 0; /* enter main loop */ while (!done) { startFrame = SDL_GetTicks(); SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { done = 1; } } render(renderer); endFrame = SDL_GetTicks(); /* figure out how much time we have left, and then sleep */ delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame); if (delay < 0) { delay = 0; } else if (delay > MILLESECONDS_PER_FRAME) { delay = MILLESECONDS_PER_FRAME; } SDL_Delay(delay); } /* delete textures */ SDL_DestroyTexture(ship); SDL_DestroyTexture(space); /* shutdown SDL */ SDL_Quit(); return 0; }
int main(int argc, char **argv) { InitSD(); FILE * file = fopen("sd:/hello.txt", "w"); if (file == NULL) exit(0); fprintf(file, "hello, there!\n"); fclose(file); // initialize the sound system. //ASND_Init(); // Initialise the Graphics & Video subsystem GRRLIB_Init(); GRRLIB_Settings.antialias = true; tex_Calibri = GRRLIB_LoadTexture(Calibri_18); GRRLIB_InitTileSet(tex_Calibri, 27, 37, 32); // Initialize the Wiimotes WPAD_Init(); mainMenu(); Ship *ship; ship = (Ship*) malloc(NUM_SHIPS * sizeof(Ship)); ship = initializeShips(NUM_SHIPS, ship); Planet* planet; planet = (Planet*) malloc(NUM_PLANETS * sizeof(Planet)); planet[0].x = 200; planet[0].y = 200; planet[0].m = 700; planet[0].r = 60; planet[0].color = 0xFFFFFFFF; planet[0].owner = NO_OWNER; planet[0].health = PLANET_HEALTH; planet[0].currentUpgrade = 0; planet[1].x = 400; planet[1].y = 400; planet[1].m = 300; planet[1].r = 30; planet[1].color = 0x00FFFFFF; planet[1].owner = NO_OWNER; planet[1].health = PLANET_HEALTH; planet[1].currentUpgrade = 0; planet[2].x = 1000; planet[2].y = 400; planet[2].m = 1000; planet[2].r = 200; planet[2].color = 0xFF2200FF; planet[2].owner = NO_OWNER; planet[2].health = PLANET_HEALTH; planet[2].currentUpgrade = 0; planet[3].x = 1400; planet[3].y = 1200; planet[3].m = 700; planet[3].r = 51; planet[3].color = 0x29AF1BFF; planet[3].owner = NO_OWNER; planet[3].health = PLANET_HEALTH; planet[3].currentUpgrade = 0; planet[4].x = 1850; planet[4].y = 1850; planet[4].m = 100; planet[4].r = 20; planet[4].color = 0xFF7777FF; planet[4].owner = NO_OWNER; planet[4].health = PLANET_HEALTH; planet[4].currentUpgrade = 0; // initialize planet's bullet arrays int i = 0; for (i = 0; i < NUM_PLANETS; i++) { planet[i].bullets = (struct Bullet *) malloc(sizeof(Bullet) * PLANET_BULLET_NUM); if (planet[i].bullets == NULL) { exit(0); } planet[i].numBullets = 0; } ship = initializeShips(NUM_SHIPS, ship); u8 frame_rate; initializeTextures(); int buttons; initializeGrid(); //ASND_Init(); //ASND_SetVoice(5,VOICE_STEREO_16BIT,8000, 0, &betamaster_raw, betamaster_raw_size, 255, 255, NULL); /* MODPlay_Init(&play); MODPlay_SetMOD(&play, paradox_mod); MODPlay_SetVolume(&play, 63, 63); MODPlay_Start(&play); */ while (1) { profiler(1); WPAD_ScanPads(); // Scan the Wiimotes buttons = WPAD_ButtonsDown(0); // If [HOME] was pressed on the first Wiimote, break out of the loop if (buttons & WPAD_BUTTON_HOME) break; update(ship, planet); doMechanics(ship, planet); render(ship, planet); frame_rate = calculateFPS(); GRRLIB_Printf(20, 20, tex_Calibri, 0xFFFFFFFF, .5, "FPS: %d", frame_rate); GRRLIB_Printf(20, 40, tex_Calibri, 0xFFFFFFFF, .5, "%d", ship[0].bullets[0].exploded); //int endProfile = profiler(0); GRRLIB_Render(); frameCount++; } GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB for (i = 0; i < NUM_SHIPS; i++) { free(ship[i].bullets); } free(ship); GRRLIB_FreeTexture(tex_Calibri); freeStarMemory(); exit(0); // Use exit() to exit a program, do not use 'return' from main() }