void Scene::init() { glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); trackball(curquat, 0.0, 0.0, 0.0, 0.0); trackball(empty, 0.0, 0.0, 0.0, 0.0); trackball(gamequat, 0.0, 0.0, 0.0, 0.0); glutInitWindowSize(W,H); glutCreateWindow("U4"); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glMatrixMode(GL_PROJECTION); gluPerspective( /* field of view in degree */ 40.0, /* aspect ratio */ 1.0, /* Z near */ 1.0, /* Z far */ 40.0); glMatrixMode(GL_MODELVIEW); gluLookAt(0.0, 0.0, 30.0, /* eye is at (0,0,30) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.); /* up is in positive Y direction */ glPushMatrix(); /* dummy push so we can pop on model recalc */ //FIXME: debug info if (game) { initGame(); } if (lighting) { initLight(); } Objects3D::importFromObj("Data/", "untitled.obj", models, materials); }
void init() { float modelMatrix[16], projectionMatrix[16]; glClearColor(0, 0, 0, 1); glMatrixMode(GL_PROJECTION); /* switch matrix mode */ glLoadIdentity(); //load Identity matrix //defines view mode gluPerspective(45, 1, 2, 10); //glRotatef(180,0,1,0); glTranslatef(0, 0, -6); //glTranslatef(0,1,0); //gluLookAt(0,-1,-1,0,-2,-2,1,1,0); //define view direction //gluLookAt(0,-1,-1,0,0,0,1,1,0); //define view direction glEnable(GL_DEPTH_TEST); //define in which order the scene will built /* return to modelview mode */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); rot = 0.01; initLight(); }
void init() { //init shader light.compileShader("./../light.vs", GLSLShader::VERTEX); light.compileShader("./../light.frag", GLSLShader::FRAGMENT); if(!light.link()){ std::cout << "light shader link failed" << std::endl; } std::cout << light.log() << std::endl; depth.compileShader("./../depth.vs", GLSLShader::VERTEX); depth.compileShader("./../depth.frag", GLSLShader::FRAGMENT); if (!depth.link()){ std::cout << "depth shader not linked" << std::endl; } std::cout << depth.log() << std::endl; debugDepthQuad.compileShader("./../debugDepth.vs", GLSLShader::VERTEX); debugDepthQuad.compileShader("./../debugDepth.frag", GLSLShader::FRAGMENT); if (!debugDepthQuad.link()){ std::cout << "debug shader not linked" << std::endl; } std::cout << debugDepthQuad.log() << std::endl; initVBO(); initFBO(); initLight(); initTexture(); }
CityMng::CityMng() { //Init glew int err=glewInit(); if(err!=GLEW_OK) { //exit(); } //m_sceneGraph = new Node(Vector3<float>(0, 0, 0)); m_gui = new GUI(); m_translation = Vector3<float>(0,0,0); m_size = 0; m_parentNode = new Node(); //Light initLight(); //Nodes initNodes(); }
void display(){ float xRotTrad = (rotateX/180 * 3.141592654f); float yRotTrad = (rotateY/180 * 3.141592654f); if (moveForward) { cameraX -= float(sinf(yRotTrad)); cameraY += float(sinf(xRotTrad)); cameraZ += float(cosf(yRotTrad)); } if (moveBack) { cameraX += float(sinf(yRotTrad)); cameraY -= float(sinf(xRotTrad)); cameraZ -= float(cosf(yRotTrad)); } if (moveLeft) { cameraX += float(cosf(yRotTrad)); cameraZ += float(sinf(yRotTrad)); } if (moveRight) { cameraX -= float(cosf(yRotTrad)); cameraZ -= float(sinf(yRotTrad)); } // writeText(); glLoadIdentity(); initLight(); glRotatef(rotateX, 1, 0, 0); glRotatef(rotateY, 0, 1, 0); //chase camera? glTranslatef(cameraX, 0, cameraZ); glClearColor(0, 0, 0, 1); glPushMatrix(); boidsList->renderBoids(); glPopMatrix(); //draw boundary cube if(showCube){ glColor3f(1, 1, 1); glutWireCube(boidsList->getBounds()*2); } //accumulation buffer, for fake motion blur if(pos == 0) glAccum(GL_LOAD, 1.0 / n); else glAccum(GL_ACCUM, 1.0 / n); pos++; if(pos >= n) { pos = 0; glAccum(GL_RETURN, 1.0); glutSwapBuffers(); glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); } }
//------------------------------------------------------------------------------ //! int lightVM( VMState* vm ) { WorldContext* context = getContext(vm); Light* e = new Light( RigidBody::DYNAMIC ); initLight( vm, e, context ); context->_world->addEntity( e ); VM::push( vm, e ); return 1; }
void CascadedShadowMappingRenderer::initRendering() { initCamera( NvCameraXformType::MAIN, nv::vec3f(-15.0f, 5.0f, 15.0f), // position nv::vec3f(0.0f, 0.0f, 0.0f)); // look at point // Setup the light parameters. initLight( nv::vec3f(100.0f, 100.0f, 100.0f), nv::vec3f(0.0f, 0.0f, 0.0f), nv::vec3f(0.0f, 1.0f, 0.0f)); // Load shaders. NvAssetLoaderAddSearchPath("gl4-maxwell/CascadedShadowMapping"); m_cameraProgram = new CameraProgram(); m_cameraProgram->init("shaders/Camera.vert", "shaders/Camera.frag"); m_lightStandardProgram = new LightProgram(); m_lightStandardProgram->init("shaders/Light.vert", "shaders/LightStandard.geom"); m_lightGsCullProgram = new LightProgram(); m_lightGsCullProgram->init("shaders/Light.vert", "shaders/LightGsCull.geom"); m_lightGsMulticastCullProgram = new LightProgram(); m_lightGsMulticastCullProgram->init("shaders/Light.vert", "shaders/LightMulticast.geom"); m_lightFgsMulticastCullProgram = new LightProgram(); m_lightFgsMulticastCullProgram->init("shaders/Light.vert", "shaders/LightFgsMulticast.geom"); m_lightVsOnlyMulticastProgram = new LightVsOnlyProgram(); m_lightVsOnlyMulticastProgram->init("shaders/LightVsOnly.vert"); // Setup geometry. initGeometry(10); // Setup resources for shadow pass. glGenFramebuffers(1, &m_lightFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_lightFBO); glGenTextures(1, &m_lightTex); glBindTexture(GL_TEXTURE_2D_ARRAY, m_lightTex); glTexStorage3D(GL_TEXTURE_2D_ARRAY, LIGHT_TEXUTRE_MIPMAP_LEVELS, GL_DEPTH_COMPONENT32F, LIGHT_TEXTURE_SIZE, LIGHT_TEXTURE_SIZE, MAX_CAMERA_FRUSTUM_SPLIT_COUNT); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_lightTex, 0); glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_FRAMEBUFFER, m_app.getMainFBO()); glGetFloatv(GL_MAX_VIEWPORT_DIMS, m_viewportDims._array); }
void Scene::Initialize() { initOpengl(); initLight(); initSceneObjs(); initShader(); initTexture(); initFBO(); initThisDemo(); }
// Init /////////////////////////////////////////////////// void init(void) { _terrain = loadTerrain("heightmap1.bmp", 20); glClearColor(1.0, 1.0, 1.0, 1.0); initLight(); image1 = loadTexture("reflection__.bmp"); image2 = loadTexture("brick_bump.bmp"); image3 = loadTexture("sand_dn.bmp"); }
bool Mentalism::init() { if(!Layer::init()) { return false; } initData(); initLight(); return true; }
/** * Bei SPIEelbegin wird das SPIEelfeld komplett initialisiert * mit einem Hintergrund, einer Zeichenfarbe, Linienbreite. * Außerdem wird die Datenhaltung initialisiert (siehe initField (), initStones ()). * @return Ob ein Fehler aufgetreten ist. */ int initScene (void) { glEnable (GL_DEPTH_TEST); glCullFace (GL_BACK); glEnable (GL_CULL_FACE); glEnable (GL_NORMALIZE); glEnable (GL_LIGHTING); initLight (); return 1; }
//--------------------------------------------------------------------------- void CLight::add() { // cout << "Adding light" << endl << endl; tLight *new_light = new tLight; initLight (new_light); getLight (new_light); linkLight (new_light); // adds light to linked-list of lights numLights++; }
light_struct* createLight(vect3D pos, int32 intensity) { int i; for(i=0;i<NUMLIGHTS;i++) { if(!lights[i].used) { initLight(&lights[i],pos,intensity); return &lights[i]; } } return NULL; }
int main() { int isNormal; setVariables(); while (1) { calibrateInit(); displayCalibrate(); if(isCalibrated(&gAccRead)) { standbyInit(); countDown(); while(1) { if (resetFlag) break; sendReadySignal(); runTemp(&isNormal); if (isSafe && isNormal && hasEstablished) { initActive(); while(1) { int freq = calculateFreq(); runActive(freq); runTemp(&isNormal); if (resetFlag) break; if(isMayDay) { switchDisplayToMayDay(); break; } if(!isNormal || !isSafe || standbyFlag) { standbyFlag = 0; switchDisplayToStandby(); countDown(); break; } } if(resetFlag) { switchDisplayToCalibrate(); break; } if(isMayDay) { initMayDay(); runMayDay(); initLight(); switchDisplayToStandby(); countDown(); } } } } } }
void init() { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_POINT_SMOOTH); geometryHandler->initGeometries(); //Intializing others glPointSize(6.0); glLineWidth(2.0); initLight(); disableLight(); }
int Engine::init(void) { int i; this->x_res = 1920; this->y_res = 1080; this->fov = 70; this->z_near = 0.01; this->z_far = 100; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return (sdlError(0)); this->window = SDL_CreateWindow("Pouet", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, this->x_res, this->y_res, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); if (this->window == NULL) return (sdlError(0)); if (!(this->context = SDL_GL_CreateContext(this->window))) return (sdlError(0)); this->camera = new Camera(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(this->fov, (double)this->x_res / (double)this->y_res, this->z_near, this->z_far); glEnable(GL_DEPTH_TEST); glPointSize(16); glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND); glShadeModel(GL_SMOOTH); // Vertex reader glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, this->vertex_tab); initLight(); this->moving = false; // Generate and print points makeCube(0.4); makeWTF(PARTY_START, PARTY_SIZE); printArray(0, 336); return (0); }
void init(){ glShadeModel(GL_SMOOTH); glEnable (GL_BLEND); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glBlendFunc (GL_SRC_ALPHA, GL_ONE); glEnable(GL_POLYGON_SMOOTH); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); boidsList = new BoidController(); boidsList->addBoids(500); //get rid of that pesky delay on a mac CGSetLocalEventsSuppressionInterval(0.0); setCamera(); initLight(); }
void menu(int value) { int i; switch (value) { case M_SPHERE: object = M_SPHERE; break; case M_ICO: object = M_ICO; break; case M_LABELS: labelLights = 1 - labelLights; break; case M_LINEAR: case M_QUAD: attenuation = value; for (i = 0; i < numActiveLights; i++) { initLight(i); } break; case M_REPORT_SIG: reportLightSignificance = 1 - reportLightSignificance; break; case M_LAMBERTIAN: brightnessModel = M_LAMBERTIAN; glutSetWindowTitle("multilight (Lambertian-based)"); break; case M_DISTANCE: brightnessModel = M_DISTANCE; glutSetWindowTitle("multilight (Distance-based)"); break; case M_TIME: timeFrames = 1 - timeFrames; break; case 666: exit(0); } glutPostRedisplay(); }
GUI::GUI(int argc, char** argv) { position p = phyEngine->getPositionBody(Body::Trunk); camera.set( p + vector3(0,0.1,0.5), p, vector3(0,1,0)); glutInit(&argc, argv); glutInitWindowSize(800, 800); glutInitWindowPosition(10,90); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutCreateWindow("Bird Simulator"); initCallBack(); initLight(); glutMainLoop(); // you could use Fl::run() instead }
/** Initialize */ void mainInit() { glClearColor(1.0,1.0,1.0,0.0); glColor3f(0.0f,0.0f,0.0f); setWindow(); setViewport(0, windowWidth, 0, windowHeight); //initSound(); TODO Disabled until we got some real sounds. // Enables hidden surfaces removal glFrontFace (GL_CCW); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); initTexture(); initModel(); initLight(); printf("w - acelerar \n"); printf("a - esquerda \n"); printf("d - direita \n"); }
void init(int w, int h) { /* OpenGL setup */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glClearColor(0.0, 0.0, 0.0, 0.0); /* low-level graphics setup */ initCanvas(w,h); /* raytracer setup */ initCamera(w,h); initScene(); initLight(); printf("DEPTH = %d. Computing the scene... ",depth); list = glGenLists(1); glNewList(list, GL_COMPILE); drawScene(); flushCanvas(); glEndList(); printf("Done\n"); }
//#define WEB_CAM int main ( int argc, char** argv ) { initLight(); //opencv cpp style #ifdef WEB_CAM cv::VideoCapture cap ( 1 ); // 0: open the default camera // 1: open the integrated webcam #else cv::VideoCapture cap("Cropped1.avi"); //("VDark.avi");//("VTreeTrunk.avi"); //("VRotatePersp.avi");//("VMouth.avi");// ("VCars.avi"); //("VZoomIn.avi");//("VSelf.avi");//("VFootball.mkv");//( "VRectLight.avi" ); //("VCars.avi"); //("VRotateOrtho.avi"); //("VHand.avi"); //("VPerson.avi");//("VHall.avi");// // ("VZoomOut.avi");// #endif if ( !cap.isOpened() ) return -1; btl::image::semidense::CSemiDenseTrackerOrb cSDTOrb; btl::image::semidense::CSemiDenseTracker cSDTFast; cv::gpu::GpuMat cvgmColorFrame,cvgmGrayFrame,cvgmColorFrameSmall; cv::Mat cvmColorFrame, cvmGrayFrame, cvmTotalFrame; cap >> cvmColorFrame; cvgmColorFrame.upload(cvmColorFrame); //resize const float fScale = .5f; cv::gpu::resize(cvgmColorFrame,cvgmColorFrameSmall,cv::Size(0,0),fScale ,fScale ); //to gray cv::gpu::cvtColor(cvgmColorFrameSmall,cvgmGrayFrame,cv::COLOR_RGB2GRAY); initPyramid(cvgmGrayFrame.rows, cvgmGrayFrame.cols ); buildPyramid(cvgmGrayFrame); cvmTotalFrame.create(cvgmColorFrameSmall.rows*2,cvgmColorFrameSmall.cols*2,CV_8UC3); cv::Mat cvmROI0(cvmTotalFrame, cv::Rect( 0, 0, cvgmColorFrameSmall.cols, cvgmColorFrameSmall.rows)); cv::Mat cvmROI1(cvmTotalFrame, cv::Rect( 0, cvgmColorFrameSmall.rows, cvgmColorFrameSmall.cols, cvgmColorFrameSmall.rows)); cv::Mat cvmROI2(cvmTotalFrame, cv::Rect(cvgmColorFrameSmall.cols, cvgmColorFrameSmall.rows, cvgmColorFrameSmall.cols, cvgmColorFrameSmall.rows)); cv::Mat cvmROI3(cvmTotalFrame, cv::Rect(cvgmColorFrameSmall.cols, 0, cvgmColorFrameSmall.cols, cvgmColorFrameSmall.rows)); //copy to total frame cvgmColorFrameSmall.download(cvmROI0); cvgmColorFrameSmall.download(cvmROI1); cvgmColorFrameSmall.download(cvmROI2); cvgmColorFrameSmall.download(cvmROI3); bool bIsInitSuccessful; bIsInitSuccessful = cSDTFast.init( _acvgmShrPtrPyrBWs ); bIsInitSuccessful = cSDTOrb.init( _acvgmShrPtrPyrBWs ); while(!bIsInitSuccessful){ cap >> cvmColorFrame; cvgmColorFrame.upload(cvmColorFrame); //resize cv::gpu::resize(cvgmColorFrame,cvgmColorFrameSmall,cv::Size(0,0),fScale ,fScale ); //to gray cv::gpu::cvtColor(cvgmColorFrameSmall,cvgmGrayFrame,cv::COLOR_RGB2GRAY); //copy into total frame cvgmColorFrameSmall.download(cvmROI0); cvgmColorFrameSmall.download(cvmROI1); cvgmColorFrameSmall.download(cvmROI2); cvgmColorFrameSmall.download(cvmROI3); bIsInitSuccessful = cSDTOrb.init( _acvgmShrPtrPyrBWs ); bIsInitSuccessful = cSDTFast.init( _acvgmShrPtrPyrBWs ); } cv::namedWindow ( "Tracker", 1 ); bool bStart = false; unsigned int uIdx = 0; for ( ;;uIdx++ ){ double t = (double)cv::getTickCount(); int nKey = cv::waitKey( 0 ) ; if ( nKey == 'a' ){ bStart = true; } else if ( nKey == 'q'){ break; } imshow ( "Tracker", cvmTotalFrame ); if(!bStart) continue; //load a new frame cap >> cvmColorFrame; if (cvmColorFrame.empty()) { cap.set(CV_CAP_PROP_POS_AVI_RATIO,0);//replay at the end of the video cap >> cvmColorFrame; cvgmColorFrame.upload(cvmColorFrame); //resize cv::gpu::resize(cvgmColorFrame,cvgmColorFrameSmall,cv::Size(0,0),fScale ,fScale ); //to gray cv::gpu::cvtColor(cvgmColorFrameSmall,cvgmGrayFrame,cv::COLOR_RGB2GRAY); buildPyramid(cvgmGrayFrame); //copy into total frame cvgmColorFrameSmall.download(cvmROI0); cvgmColorFrameSmall.download(cvmROI1); cvgmColorFrameSmall.download(cvmROI2); cvgmColorFrameSmall.download(cvmROI3); cSDTOrb.init( _acvgmShrPtrPyrBWs ); cSDTFast.init( _acvgmShrPtrPyrBWs ); //get second frame cap >> cvmColorFrame; cvgmColorFrame.upload(cvmColorFrame); //resize cv::gpu::resize(cvgmColorFrame,cvgmColorFrameSmall,cv::Size(0,0),fScale ,fScale ); //to gray cv::gpu::cvtColor(cvgmColorFrameSmall,cvgmGrayFrame,cv::COLOR_RGB2GRAY); //copy into total frame cvgmColorFrameSmall.download(cvmROI0); cvgmColorFrameSmall.download(cvmROI1); cvgmColorFrameSmall.download(cvmROI2); cvgmColorFrameSmall.download(cvmROI3); }else{
void ComplexInliner::unify(){ initLight(dag); vector<vector<bool_node*> > argLists; vector<vector<int> > diffs; map<int, int> locToG; int tot = 0; int N = 0; map<int, vector<int> > nfd; map<int, int> closestMatch; int maxDif = -1; for(int i=0; i<dag.size() ; ++i ){ // Get the code for this node. if(typeid(*dag[i]) == typeid(UFUN_node)){ UFUN_node* ufun = dynamic_cast<UFUN_node*>(dag[i]); const string& name = ufun->get_ufname(); if(checkFunName(name)){ vector<vector<bool_node*> >& v = argLists; int id = v.size(); vector<int> difRow; locToG[id] = i; int lowestDif = 100000; int lowestDifID = -1; for(int j=0; j<v.size(); j++){ int dif = argsCompare(v[j], ufun->multi_mother); maxDif = dif > maxDif ? dif : maxDif; tot += dif; ++N; if(dif < lowestDif){ lowestDif = dif; lowestDifID = j; } // cout<<" ("<<id<<", "<<j<<") "<<dif<<endl; } // cout<<" id = "<<id<<" lowestDif ="<<lowestDif<<"avg dif="<< (id>0 ? tot / id : -1) <<" ldifID = "<<lowestDifID<<endl; closestMatch[id] = lowestDifID; nfd[lowestDif].push_back(id); v.push_back(ufun->multi_mother); } } } int nmerges = 0; if(N == 0){ N = 1; } cout<<" expectedNFuns="<<expectedNFuns<<" average dif = "<< (tot / N) <<endl; int totFuns=0; map<int, int> actualMatch; for(map<int, vector<int> >::reverse_iterator it = nfd.rbegin(); it != nfd.rend(); ++it){ vector<int>& ids = it->second; cout<<" ldiff = "<<it->first<<" size = "<<ids.size()<<endl; if(totFuns >= expectedNFuns || it->first < 300){ //If we are here, we've exhausted our quota of functions, so we'll start merging the remaining ones with their closest match. for(int i=0; i<ids.size(); ++i){ int a = ids[i]; int b = closestMatch[a]; cout<<" merging function "<<a<<"("<< locToG[a] <<") with function "<<b<<"("<< locToG[b]<<")"<<endl; Assert( b < a, "This is an invariant"); int bnew = b; while(actualMatch.count(bnew) > 0){ cout<<"function "<<bnew<<"("<< locToG[bnew]<<") had already been merged into "<<actualMatch[bnew]<<endl; int tmp = bnew; bnew = actualMatch[bnew]; if(b != tmp){ actualMatch[b] = bnew; } } mergeFuncalls( locToG[bnew], locToG[a]); ++nmerges; actualMatch[a] = bnew; } } totFuns += ids.size(); } cout<<" merged "<<nmerges<<" calls"<<endl; cleanup(dag); }
void LightEvent::onTimeEvent() { if(m_update) {//only if new data is available if(m_old_state != m_state) {//if state changed m_light_state = true; turnOn(); m_old_state = m_state; } switch(m_state) { case init: { m_update = false; initLight(); m_state = shine; break; } case shine: { fadeHSB(); m_update = false;//NOT before the switch break; } case blink: {//Update is never cleared here, because it counts the calls and works as timer if(m_blink_counter >= BLINK_DURATION) {//only if time is up NEVER clear update! m_blink_counter = 0; if(m_light_state) m_light_state = false; else m_light_state = true; //fadeHSB(); turnOn(); } else m_blink_counter++; break; } case random: {//Update is never cleared here, because it counts the calls and works as timer if(m_blink_counter >= RANDOM_DURATION) {//only if time is up NEVER clear update! m_blink_counter = 0; //fadeHSB(); fadeHSBRandom(); } else m_blink_counter++; break; } case random_blink: {//Update is never cleared here, because it counts the calls and works as timer if(m_blink_counter >= BLINK_DURATION) {//only if time is up NEVER clear update! m_blink_counter = 0; if(m_light_state) { turnOn(); m_light_state = false; fadeHSBRandom(0xf0); } else { turnOn(); m_light_state = true; } } else m_blink_counter++; break; } default: { //what to do? } } }; }
int main(int nArg, char** pArgs) { int width, height; bool fullscreen; FILE* res = fopen("Config/resolution.txt", "r"); if(!res) { fprintf(stderr, "Fichier resolution.txt introuvable\n"); return -1; } char line[128]; fgets(line, 128, res); width = atoi(line); fgets(line, 128, res); height = atoi(line); fgets(line, 128, res); if(!strnicmp(line, "true", 4)) fullscreen = true; else fullscreen = false; fclose(res); cxt = new invContext(width, height, fullscreen); game.setWindowResolution(width, height); // Init Context if(!cxt->create("Invasion", s_vfs->iconsandcursors("icons/icone.ico"))) { fprintf(stderr, "Could not create the context\n"); return -1; } glewInit(); // extensions if(isExtSupported("GL_ARB_vertex_buffer_object")) { printf("VBO supported\n"); } cxt->setBackground(0.f, 0.f, 0.1f); cxt->setFocus(false); // Cursor // Init Camera cam.init(cxt->width, cxt->height, 55.f); cam.setPos(Vec3f(0.f, 10.f, 10.f)); // Define Flow flow.compensator = 0; // COMPENSATION; flow.setElapsedTime(&elapsedTime); flow.add(&flow.always, "checkEvent", &checkEvent); flow.add(&flow.always, "picking", &picking_system); flow.add(&flow.always, "move", &move); flow.add(&flow.always, "draw", &draw); // Load infos and models game.initScriptEngine(); // init shaders // sh.load("vertex.vsh", "fragment.fsh"); initLight(); // launch timer before = cxt->secs(); // run the main script game.circle = loadTexture(s_vfs->texture("circle.png")); game.runScripts(); // V-Sync glPointSize(4.f); //------------------------------------------------ // Launch the game //------------------------------------------------ flow.loop(); // Release circle texture glDeleteTextures(1, &game.circle); // unload the shaders // sh.unload(); // Destroy the context cxt->destroy(); delete cxt; // finish success return 0; }
int main(int argc, char **argv) { int i; glutInitWindowSize(400, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); glutInit(&argc, argv); for (i = 1; i < argc; i++) { if (!strcmp("-sb", argv[i])) { glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); singleBuffer = 1; } } glutCreateWindow("multilight"); glClearColor(0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); gluPerspective(50.0, 2.0, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); gluLookAt( 0.0, 1.0, -16.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.); numActiveLights = MIN_VALUE(MAX_LIGHTS, 8); for (i = 0; i < numActiveLights; i++) { initLight(i); } glLightModelfv(GL_LIGHT_MODEL_AMBIENT, modelAmb); glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glMaterialfv(GL_FRONT, GL_AMBIENT, matAmb); glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiff); glMaterialfv(GL_FRONT, GL_SPECULAR, matSpec); glMaterialfv(GL_FRONT, GL_EMISSION, matEmission); glMaterialf(GL_FRONT, GL_SHININESS, 10.0); glNewList(DL_LIGHT_SPHERE, GL_COMPILE); glutSolidSphere(0.2, 4, 4); glEndList(); glNewList(DL_BIG_SPHERE, GL_COMPILE); glutSolidSphere(1.5, 20, 20); glEndList(); glNewList(DL_ICO, GL_COMPILE); glutSolidIcosahedron(); glEndList(); glutDisplayFunc(display); glutVisibilityFunc(visible); glutKeyboardFunc(key); glutMouseFunc(mouse); glutMotionFunc(motion); glutCreateMenu(menu); glutAddMenuEntry("Sphere", M_SPHERE); glutAddMenuEntry("Icosahedron", M_ICO); glutAddMenuEntry("Linear attenuation", M_LINEAR); glutAddMenuEntry("Quadratic attenuation", M_QUAD); glutAddMenuEntry("Toggle Light Number Labels", M_LABELS); glutAddMenuEntry("Report Light Significance", M_REPORT_SIG); glutAddMenuEntry("Lambertian-based Significance", M_LAMBERTIAN); glutAddMenuEntry("Distance-based Significance", M_DISTANCE); glutAddMenuEntry("Time Frames", M_TIME); glutAddMenuEntry("Quit", 666); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }