int main(int argc, char *argv[]) { chdir("/Users/tjgreen/Documents/OpenGL/Sol"); GLFWwindow *window = setupGLFW(); GLuint skyboxTexture = initCubemap(); //GLFWwindow* window2 = glfwCreateWindow(500, 500, "SolarSystem", NULL, NULL); //glfwMakeContextCurrent(window2); /*Cross platform compatibility stuff uncomment if not on mac GLenum err = glewInit(); if (GLEW_OK != err) { printf(stderr, "Error: %s\n", glewGetErrorString(err)); }*/ sunTexture = loadTexture("include/textures/Planets/sun2.jpg"); sunNormal = loadTexture("include/textures/Planets/sunNormal.png"); planetBuilder(); init(); createPerspectiveMatrix(); initializePlanetButtons(); glEnable(GL_CULL_FACE); glEnable(GL_MULTISAMPLE); glCullFace(GL_BACK); attachGUIShaders(); float fpsFrames= 0; float lastTime = 0; while(!glfwWindowShouldClose(window)) { GLfloat currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; fpsFrames++; if(currentFrame - lastTime >= 1.0) { //printf("%f\n", 1000/fpsFrames); fpsFrames = 0; lastTime += 1.0; } glfwPollEvents(); doMovement(); glfwPollEvents(); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, WIDTH, HEIGHT); drawSkybox(skyboxTexture); drawSun(); drawPlanet(); //glFrontFace(GL_CW); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); drawAtmosphere(); glDisable(GL_BLEND); //glFrontFace(GL_CCW); drawObj(); drawMoon(); //drawButton(button1); //drawPlanetButtons(); if(stopRotation == 0){ for(int i = 0; i < 11; i++) { orbitSpeedArray[i] += 0.1/planetInstanceArray[i].orbit; } for(int i = 0; i < 11; i++) { rotationSpeedArray[i] += 0.1/planetInstanceArray[i].day; } thetaY += 0.1; } glfwSwapBuffers(window); } glDeleteVertexArrays(1, &planetVAO); glDeleteBuffers(1, &planetVBO); glfwTerminate(); return 0; }
/** * Updates our system palette variables to make sure they match * the current state of the actual system palette. This method * is called during AwtPalette creation and after palette changes. * Return whether there were any palette changes from the previous * system palette. */ BOOL AwtPalette::Update() { PALETTEENTRY pe[256]; int numEntries = 0; int bitsPerPixel; int i; HDC hDC; hDC = device->GetDC(); if (!hDC) { return FALSE; } bitsPerPixel = ::GetDeviceCaps(hDC, BITSPIXEL); device->ReleaseDC(hDC); if (8 != bitsPerPixel) { return FALSE; } hDC = device->GetDC(); numEntries = FetchPaletteEntries(hDC, pe); device->ReleaseDC(hDC); if ((numEntries == numSystemEntries) && (0 == memcmp(pe, systemEntriesWin32, numEntries * sizeof(PALETTEENTRY)))) { return FALSE; } // make this system palette the new cached win32 palette numEntries = (numEntries > 256)? 256: numEntries; memcpy(systemEntriesWin32, pe, numEntries * sizeof(PALETTEENTRY)); numSystemEntries = numEntries; // Create jdk-style system palette int startIndex = 0, endIndex = numEntries-1; int staticGrayType = GetGSType(systemEntriesWin32); if (staticGrayType == LINEAR_STATIC_GRAY) { device->SetGrayness(GS_STATICGRAY); } else if (staticGrayType == NON_LINEAR_STATIC_GRAY) { device->SetGrayness(GS_NONLINGRAY); } else if (getenv("FORCEGRAY")) { J2dTraceLn(J2D_TRACE_INFO, "Gray Palette Forced via FORCEGRAY"); // Need to zero first and last ten // palette entries. Otherwise in UpdateDynamicColorModel // we could set non-gray values to the palette. for (i = 0; i < 10; i++) { systemEntries[i] = 0x00000000; systemEntries[i+246] = 0x00000000; } numEntries -= 20; startIndex = 10; endIndex -= 10; device->SetGrayness(GS_INDEXGRAY); } else { device->SetGrayness(GS_NOTGRAY); } for (i = startIndex; i <= endIndex; i++) { systemEntries[i] = 0xff000000 | (pe[i].peRed << 16) | (pe[i].peGreen << 8) | (pe[i].peBlue); } systemInverseLUT = initCubemap((int *)systemEntries, numEntries, 32); ColorData *cData = device->GetColorData(); if ((device->GetGrayness() == GS_NONLINGRAY || device->GetGrayness() == GS_INDEXGRAY) && cData != NULL) { if (cData->pGrayInverseLutData != NULL) { free(cData->pGrayInverseLutData); cData->pGrayInverseLutData = NULL; } initInverseGrayLut((int*)systemEntries, 256, device->GetColorData()); } return TRUE; }