void mainloop() { while (!done) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else if (keys[VK_ESCAPE]) done=true; else { memcpy(tooltip,defaulttooltip,256); glClear(0x4100); switchto2d(); /*glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); glColor4d( 40.0/255.0, 75.0/255.0, 128.0/255.0,1.0); glVertex2i(0,0); glVertex2i(800,0); glColor4f(backgroundcol); glVertex2i(800,600); glVertex2i(0,600); glEnd(); glPopAttrib();*/ glBindTexture(GL_TEXTURE_2D,cubetex); /*glEnable(GL_TEXTURE_2D); //145*32 addict logo glColor4f(1,1,1,1); glBegin(GL_QUADS); glTexCoord2d(0,(255.0-31.0)/256.0); glVertex2i(800-144,0); glTexCoord2d(144.0/256.0,(255.0-31.0)/256.0); glVertex2i(800,0); glTexCoord2d(144.0/256.0,1.0); glVertex2i(800,31); glTexCoord2d(0,1.0); glVertex2i(800-144,31); glEnd(); glDisable(GL_TEXTURE_2D);*/ menu(DD_Check); if (keys[46] && (mainmenu==2)) { delete_selected(); keys[46]=false; } if (keys[65] && (mainmenu==2)) { { o=actualscene->objects; while (o!=NULL) { if (!o->effect) o->selected=true; o=o->next; } } keys[65]=false; } if (keys[78] && (mainmenu==2)) { { o=actualscene->objects; while (o!=NULL) { o->selected=false; o=o->next; } } keys[78]=false; } if (keys[73] && (mainmenu==2)) { { o=actualscene->objects; while (o!=NULL) { if (!o->effect) o->selected=!o->selected; o=o->next; } } keys[73]=false; } if (keys[77] && (mainmenu==2)) { for (int x=0; x<4; x++) modellviews[x].transformation=1; keys[77]=false; } if (keys[82] && (mainmenu==2)) { for (int x=0; x<4; x++) modellviews[x].transformation=2; keys[82]=false; } if (keys[83] && (mainmenu==2)) { for (int x=0; x<4; x++) modellviews[x].transformation=3; keys[83]=false; } if (keys[79] && (mainmenu==2)) { for (int x=0; x<4; x++) modellviews[x].centertransform=!modellviews[x].centertransform; keys[79]=false; } //if (keys[79] && (mainmenu==2)) { sprintf(s2s,"eye: %.3f %.3f %.3f\n dest: %.3f %.3f %.3f",modellviews[3].cam2.eye.b.x,modellviews[3].cam2.eye.b.y,modellviews[3].cam2.eye.b.z,modellviews[3].cam2.target.b.x,modellviews[3].cam2.target.b.y,modellviews[3].cam2.target.b.z); MessageBox( 0, s2s, "HelloWorld", MB_OK ); keys[79]=false; } menu(DD_Draw); if ((strlen(cursorstring)!=0)) //&& (leftbutton || rightbutton)) { glColor4f(1,1,1,1); if (leftbutton) { line(lx-5,ly,lx+5,ly); line(lx,ly-5,lx,ly+5); } glDisable(GL_DEPTH_TEST); glRasterPos2i(mx+15,my+15); glPrint(cursorstring,base2); glEnable(GL_DEPTH_TEST); memset(cursorstring,0,256); } glColor4f(buttontextlit); /*glRasterPos2i(495,14); glPrint(tooltip,base);*/ glColor4f(1,1,1,1); SwapBuffers(hDC); menu(DD_AfterCheck); if (waitleftbutton) {waitforleftbuttonrelease(); waitleftbutton=false;} if (waitrightbutton) {waitforrightbuttonrelease(); waitrightbutton=false;} if (keys[VK_ESCAPE]) {done=false; keys[VK_ESCAPE]=false;} if (leftbutton || rightbutton || middlebutton) SetCapture(hWnd); else ReleaseCapture(); wheel=0; Sleep(10); } } }
void drawevent(event *e, float t) { glPushAttrib(GL_ALL_ATTRIB_BITS); float x1,y1,x2,y2; x1=(float)floor(linear((float)e->startrectx1,(float)e->endrectx1,t)); y1=(float)floor(linear((float)e->startrecty1,(float)e->endrecty1,t)); if (xres==320) y1+=0.5; if (xres==1024) y1+=1; x2=(float)floor(linear((float)e->startrectx2,(float)e->endrectx2,t))+1; y2=(float)floor(linear((float)e->startrecty2,(float)e->endrecty2,t))+1; if (e->eventtype==layer2d) { glDepthMask(false); glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); if (e->textured) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,e->mattexture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(x1,y1-1); glTexCoord2f(0,1); glVertex2f(x2,y1-1); glTexCoord2f(1,1); glVertex2f(x2,y2+1); glTexCoord2f(1,0); glVertex2f(x1,y2+1); glEnd(); } else { glDisable(GL_TEXTURE_2D); quad(x1,y1,x2,y2); } } if (e->eventtype==layer3d) { float animtimer=linear((float)e->animstart,(float)e->animend,t); scene *pf = e->iscene; camera *cam=e->icam; if (calculatehierarchy[pf->number]) { getscenestate(pf,animtimer,e->ianim); calculateobjhierarchy(pf,-1,NULL); } float f=linear((float)e->camstart,(float)e->camend,t); cam->eye.x=cam->eyex->GetKey(f); cam->eye.y=cam->eyey->GetKey(f); cam->eye.z=cam->eyez->GetKey(f); cam->target.x=cam->trgx->GetKey(f); cam->target.y=cam->trgy->GetKey(f); cam->target.z=cam->trgz->GetKey(f); cam->fov=cam->fovt->GetKey(f); cam->roll=cam->rollt->GetKey(f); glLoadIdentity(); if (!cam->eyex || (cam->eyex && cam->eyex->numkey==0) ) cam=lastcam; setcameraview(*cam,(float)(x2-x1)/(float)(y2-y1)); lastcam=cam; glViewport((int)(x1*(float)xres/640.0),(int)(yres-y2*(float)yres/480.0),(int)((x2-x1)*(float)xres/640.0),(int)((y2-y1)*(float)yres/480.0)); glEnable(GL_BLEND); glEnable(GL_LIGHTING); renderscene(pf); //switchto2d(); } if (e->eventtype==cleargl) { if (e->clearzbuffer && !e->clearscreen) glClear(0x100); if (!e->clearzbuffer && e->clearscreen) glClear(0x4000); if (e->clearzbuffer && e->clearscreen) glClear(0x4100); } if (e->eventtype==rendertotext) { glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,(int)(x1*(float)xres/640.0),(int)(yres-y2*(float)yres/480.0), 1024, 1024,0); shots[e->texture].x1=0; shots[e->texture].y1=(y2-y1)*(float)xres/640.0f/1024.0f; shots[e->texture].x2=(x2-x1)*(float)yres/480.0f/1024.0f; shots[e->texture].y2=0; } if (e->eventtype==feedback) { glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); glBegin(GL_QUADS); float xc,yc,xs,ys; xc=(shots[e->texture].x1+shots[e->texture].x2)/2.0f; yc=(shots[e->texture].y1+shots[e->texture].y2)/2.0f; xs=(shots[e->texture].x2-shots[e->texture].x1)/2.0f; ys=(shots[e->texture].y2-shots[e->texture].y1)/2.0f; for (int x=0; x<e->param1; x++) { float zoom=1.0f+(float)x/e->param1/e->param4; glColor4f(linear(e->startcol[0],e->endcol[0],t)*(float)(20-x)/20.0f,linear(e->startcol[1],e->endcol[1],t)*(float)(20-x)/20.0f,linear(e->startcol[2],e->endcol[2],t)*(float)(20-x)/20.0f,linear(e->startcol[3],e->endcol[3],t)*(float)(20-x)/20.0f); glTexCoord2f(xc-xs/zoom,yc-ys/zoom); glVertex2f(x1,y1); glTexCoord2f(xc+xs/zoom,yc-ys/zoom); glVertex2f(x2,y1); glTexCoord2f(xc+xs/zoom,yc+ys/zoom); glVertex2f(x2,y2); glTexCoord2f(xc-xs/zoom,yc+ys/zoom); glVertex2f(x1,y2); } glEnd(); } if (e->eventtype==grideffect) { glDepthMask(false); float time=linear(e->gridstart,e->gridend,t); glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); MakeEffect(e->effect,time,x1,y1,x2,y2, shots[e->texture].x1, shots[e->texture].y1, shots[e->texture].x2, shots[e->texture].y2, 0, 0, 0, 0, 0, 0, 0, 0); } switchto2d(); glPopAttrib(); }