void draw_surface_part_ext(int id, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, int color, gs_scalar alpha) { get_surface(surf,id); texture_use(surf->tex); glPushAttrib(GL_CURRENT_BIT); glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255)); const gs_scalar tbw = surf->width, tbh = surf->height; glBegin(GL_QUADS); glTexCoord2f(left/tbw,top/tbh); glVertex2f(x,y); glTexCoord2f((left+width)/tbw,top/tbh); glVertex2f(x+width*xscale,y); glTexCoord2f((left+width)/tbw,(top+height)/tbh); glVertex2f(x+width*xscale,y+height*yscale); glTexCoord2f(left/tbw,(top+height)/tbh); glVertex2f(x,y+height*yscale); glEnd(); glPopAttrib(); }
void draw_sprite_tiled_ext(int spr, int subimg, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, int blend, gs_scalar alpha) { get_spritev(spr2d,spr); const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount; texture_use(GmTextures[spr2d->texturearray[usi]]->gltex); const gs_scalar tbx = spr2d->texbordxarray[usi], tby = spr2d->texbordyarray[usi], width_scaled = spr2d->width*xscale, height_scaled = spr2d->height*yscale, xoff = fmod(spr2d->xoffset*xscale+x,width_scaled)-width_scaled, yoff = fmod(spr2d->yoffset*yscale+y,height_scaled)-height_scaled; const int hortil = int(ceil((view_enabled ? int(view_xview[view_current] + view_wview[view_current]) : room_width) / (width_scaled*tbx))) + 1, vertil = int(ceil((view_enabled ? int(view_yview[view_current] + view_hview[view_current]) : room_height) / (height_scaled*tby))) + 1; gs_scalar xvert1 = xoff, xvert2 = xvert1 + width_scaled, yvert1, yvert2; const gs_scalar r = __GETR(blend), g = __GETG(blend), b = __GETB(blend); for (int i=0; i<hortil; i++) { yvert1 = yoff; yvert2 = yvert1 + height_scaled; for (int c=0; c<vertil; c++) { const gs_scalar data[4*8] = { xvert1, yvert1, 0.0, 0.0, r, g, b, alpha, xvert2, yvert1, tbx, 0.0, r, g, b, alpha, xvert2, yvert2, tbx, tby, r, g, b, alpha, xvert1, yvert2, 0.0, tby, r, g, b, alpha }; plane2D_rotated(data); yvert1 = yvert2; yvert2 += height_scaled; } xvert1 = xvert2; xvert2 += width_scaled; } }
void particle_system::draw_particlesystem() { // TODO: Handle different particle shapes. // TODO: Draw the particle system either from oldest to youngest or reverse. const std::list<particle_instance>::iterator end = pi_list.end(); for (std::list<particle_instance>::iterator it = pi_list.begin(); it != end; it++) { particle_type* pt = it->pt; // TODO: Use default shape if particle type not alive. if (pt->is_particle_sprite) { particle_sprite* ps = pt->part_sprite; bind_texture(ps->texture); glPushAttrib(GL_CURRENT_BIT); // Push 1. int color = it->color; // TODO: Alpha can be set. glColor4ub(__GETR(color),__GETG(color),__GETB(color),255); const float tbx = 1, tby = 1, xvert1 = it->x - ps->width/2, xvert2 = it->x + ps->width/2, yvert1 = it->y - ps->height/2, yvert2 = it->y + ps->height/2; glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(xvert1,yvert1); glTexCoord2f(tbx,0); glVertex2f(xvert2,yvert1); glTexCoord2f(tbx,tby); glVertex2f(xvert2,yvert2); glTexCoord2f(0,tby); glVertex2f(xvert1,yvert2); glEnd(); glPopAttrib(); // Pop 1. } } }
void draw_background_ext(int back,double x,double y,double xscale,double yscale,double rot,int color,double alpha) { get_background(bck2d,back); texture_use(GmTextures[bck2d->texture]->gltex); glPushAttrib(GL_CURRENT_BIT); glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255)); rot *= M_PI/180; const float tbx = bck2d->texbordx, tby = bck2d->texbordy, w = bck2d->width*xscale, h = bck2d->height*yscale, wsinrot = w*sin(rot), wcosrot = w*cos(rot); glBegin(GL_QUADS); float ulcx = x + xscale * cos(M_PI+rot) + yscale * cos(M_PI/2+rot), ulcy = y - yscale * sin(M_PI+rot) - yscale * sin(M_PI/2+rot); glTexCoord2f(0,0); glVertex2f(ulcx,ulcy); glTexCoord2f(tbx,0); glVertex2f(ulcx + wcosrot, ulcy - wsinrot); const double mpr = 3*M_PI/2 + rot; ulcx += h * cos(mpr); ulcy -= h * sin(mpr); glTexCoord2f(tbx,tby); glVertex2f(ulcx + wcosrot, ulcy - wsinrot); glTexCoord2f(0,tby); glVertex2f(ulcx,ulcy); glEnd(); glPopAttrib(); }
void screen_redraw() { // Should implement extended lost device checking //if (d3ddev == NULL ) return; // Clean up any textures that ENIGMA may still think are binded but actually are not texture_reset(); d3ddev->BeginScene(); // begins the 3D scene dsprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_DO_NOT_ADDREF_TEXTURE); if (!view_enabled) { D3DVIEWPORT9 pViewport = { 0, 0, (DWORD)window_get_region_width_scaled(), (DWORD)window_get_region_height_scaled(), 0, 1.0f }; d3ddev->SetViewport(&pViewport); D3DXMATRIX matTrans, matScale; // Calculate a translation matrix D3DXMatrixTranslation(&matTrans, -0.5, -room_height - 0.5, 0); D3DXMatrixScaling(&matScale, 1, -1, 1); // Calculate our world matrix by multiplying the above (in the correct order) D3DXMATRIX matWorld = matTrans * matScale; // Set the matrix to be applied to anything we render from now on d3ddev->SetTransform( D3DTS_VIEW, &matWorld); D3DXMATRIX matProjection; // the projection transform matrix D3DXMatrixOrthoOffCenterLH(&matProjection, 0, (FLOAT)room_width, 0, (FLOAT)room_height, 0.0f, // the near view-plane 1.0f); // the far view-plane d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection transform if (background_showcolor) { int clearcolor = ((int)background_color) & 0x00FFFFFF; // clear the window to the background color d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(__GETR(clearcolor), __GETG(clearcolor), __GETB(clearcolor)), 1.0f, 0); // clear the depth buffer } // Clear the depth buffer if 3d mode is on at the beginning of the draw step. if (enigma::d3dMode) d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); draw_back(); // Apply and clear stored depth changes. for (map<int,pair<double,double> >::iterator it = id_to_currentnextdepth.begin(); it != id_to_currentnextdepth.end(); it++) { enigma::object_graphics* inst_depth = (enigma::object_graphics*)enigma::fetch_instance_by_id((*it).first); if (inst_depth != NULL) { drawing_depths[(*it).second.first].draw_events->unlink(inst_depth->depth.myiter); inst_iter* mynewiter = drawing_depths[(*it).second.second].draw_events->add_inst(inst_depth->depth.myiter->inst); if (instance_event_iterator == inst_depth->depth.myiter) { instance_event_iterator = inst_depth->depth.myiter->prev; } inst_depth->depth.myiter = mynewiter; } } id_to_currentnextdepth.clear(); if (enigma::particles_impl != NULL) { const double high = numeric_limits<double>::max(); const double low = drawing_depths.rbegin() != drawing_depths.rend() ? drawing_depths.rbegin()->first : -numeric_limits<double>::max(); (enigma::particles_impl->draw_particlesystems)(high, low); } bool stop_loop = false; for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++) { if (dit->second.tiles.size()) //glCallList(drawing_depths[dit->second.tiles[0].depth].tilelist); texture_reset(); enigma::inst_iter* push_it = enigma::instance_event_iterator; //loop instances for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) { enigma::instance_event_iterator->inst->myevent_draw(); if (enigma::room_switching_id != -1) { stop_loop = true; break; } } enigma::instance_event_iterator = push_it; if (stop_loop) break; //particles if (enigma::particles_impl != NULL) { const double high = dit->first; dit++; const double low = dit != drawing_depths.rend() ? dit->first : -numeric_limits<double>::max(); dit--; (enigma::particles_impl->draw_particlesystems)(high, low); } } //return; } else { bool stop_loop = false; for (view_current = 0; view_current < 7; view_current++) { if (view_visible[(int)view_current]) { int vc = (int)view_current; int vob = (int)view_object[vc]; if (vob != -1) { object_basic *instanceexists = fetch_instance_by_int(vob); if (instanceexists) { object_planar* vobr = (object_planar*)instanceexists; double vobx = vobr->x, voby = vobr->y; //int bbl=*vobr.x+*vobr.bbox_left,bbr=*vobr.x+*vobr.bbox_right,bbt=*vobr.y+*vobr.bbox_top,bbb=*vobr.y+*vobr.bbox_bottom; //if (bbl<view_xview[vc]+view_hbor[vc]) view_xview[vc]=bbl-view_hbor[vc]; double vbc_h, vbc_v; (view_hborder[vc] > view_wview[vc]/2) ? vbc_h = view_wview[vc]/2 : vbc_h = view_hborder[vc]; (view_vborder[vc] > view_hview[vc]/2) ? vbc_v = view_hview[vc]/2 : vbc_v = view_vborder[vc]; if (view_hspeed[vc] == -1) { if (vobx < view_xview[vc] + vbc_h) view_xview[vc] = vobx - vbc_h; else if (vobx > view_xview[vc] + view_wview[vc] - vbc_h) view_xview[vc] = vobx + vbc_h - view_wview[vc]; } else { if (vobx < view_xview[vc] + vbc_h) { view_xview[vc] -= view_hspeed[vc]; if (view_xview[vc] < vobx - vbc_h) view_xview[vc] = vobx - vbc_h; } else if (vobx > view_xview[vc] + view_wview[vc] - vbc_h) { view_xview[vc] += view_hspeed[vc]; if (view_xview[vc] > vobx + vbc_h - view_wview[vc]) view_xview[vc] = vobx + vbc_h - view_wview[vc]; } } if (view_vspeed[vc] == -1) { if (voby < view_yview[vc] + vbc_v) view_yview[vc] = voby - vbc_v; else if (voby > view_yview[vc] + view_hview[vc] - vbc_v) view_yview[vc] = voby + vbc_v - view_hview[vc]; } else { if (voby < view_yview[vc] + vbc_v) { view_yview[vc] -= view_vspeed[vc]; if (view_yview[vc] < voby - vbc_v) view_yview[vc] = voby - vbc_v; } if (voby > view_yview[vc] + view_hview[vc] - vbc_v) { view_yview[vc] += view_vspeed[vc]; if (view_yview[vc] > voby + vbc_v - view_hview[vc]) view_yview[vc] = voby + vbc_v - view_hview[vc]; } } if (view_xview[vc] < 0) view_xview[vc] = 0; else if (view_xview[vc] > room_width - view_wview[vc]) view_xview[vc] = room_width - view_wview[vc]; if (view_yview[vc] < 0) view_yview[vc] = 0; else if (view_yview[vc] > room_height - view_hview[vc]) view_yview[vc] = room_height - view_hview[vc]; } } D3DVIEWPORT9 pViewport = { (DWORD)view_xport[vc], (DWORD)view_yport[vc], (DWORD)(window_get_region_width_scaled() - view_xport[vc]), (DWORD)(window_get_region_height_scaled() - view_yport[vc]), 0, 1.0f }; d3ddev->SetViewport(&pViewport); D3DXMATRIX matTrans, matScale; // Calculate a translation matrix D3DXMatrixTranslation(&matTrans, -view_xview[vc] - 0.5, -view_yview[vc] - room_height - 0.5, 0); D3DXMatrixScaling(&matScale, 1, -1, 1); // Calculate our world matrix by multiplying the above (in the correct order) D3DXMATRIX matWorld = matTrans * matScale; // Set the matrix to be applied to anything we render from now on d3ddev->SetTransform( D3DTS_VIEW, &matWorld); D3DXMATRIX matProjection; // the projection transform matrix D3DXMatrixOrthoOffCenterLH(&matProjection, 0, (FLOAT)view_wview[vc], 0, (FLOAT)view_hview[vc], 0.0f, // the near view-plane 1.0f); // the far view-plane d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection transform if (background_showcolor && view_current == 0) { int clearcolor = ((int)background_color) & 0x00FFFFFF; // clear the window to the background color d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(__GETR(clearcolor), __GETG(clearcolor), __GETB(clearcolor)), 1.0f, 0); } // Clear the depth buffer if 3d mode is on at the beginning of the draw step. if (enigma::d3dMode) d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); if (view_current == 0) { draw_back(); } // Apply and clear stored depth changes. for (map<int,pair<double,double> >::iterator it = id_to_currentnextdepth.begin(); it != id_to_currentnextdepth.end(); it++) { enigma::object_graphics* inst_depth = (enigma::object_graphics*)enigma::fetch_instance_by_id((*it).first); if (inst_depth != NULL) { drawing_depths[(*it).second.first].draw_events->unlink(inst_depth->depth.myiter); inst_iter* mynewiter = drawing_depths[(*it).second.second].draw_events->add_inst(inst_depth->depth.myiter->inst); if (instance_event_iterator == inst_depth->depth.myiter) { instance_event_iterator = inst_depth->depth.myiter->prev; } inst_depth->depth.myiter = mynewiter; } } id_to_currentnextdepth.clear(); if (enigma::particles_impl != NULL) { const double high = numeric_limits<double>::max(); const double low = drawing_depths.rbegin() != drawing_depths.rend() ? drawing_depths.rbegin()->first : -numeric_limits<double>::max(); (enigma::particles_impl->draw_particlesystems)(high, low); } for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++) { if (dit->second.tiles.size()) //glCallList(drawing_depths[dit->second.tiles[0].depth].tilelist); texture_reset(); enigma::inst_iter* push_it = enigma::instance_event_iterator; //loop instances for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) { enigma::instance_event_iterator->inst->myevent_draw(); if (enigma::room_switching_id != -1) { stop_loop = true; break; } } enigma::instance_event_iterator = push_it; if (stop_loop) break; //particles if (enigma::particles_impl != NULL) { const double high = dit->first; dit++; const double low = dit != drawing_depths.rend() ? dit->first : -numeric_limits<double>::max(); dit--; (enigma::particles_impl->draw_particlesystems)(high, low); } } if (stop_loop) break; } } view_current = 0; } int culling = d3d_get_culling(); d3d_set_culling(rs_none); // Now process the sub event of draw called draw gui // It is for drawing GUI elements without view scaling and transformation if (enigma::gui_used) { // Now process the sub event of draw called draw gui // It is for drawing GUI elements without view scaling and transformation D3DVIEWPORT9 pViewport = { 0, 0, window_get_region_width_scaled(), window_get_region_height_scaled(), 0, 1.0f }; d3ddev->SetViewport(&pViewport); D3DXMATRIX matTrans, matScale; // Calculate a translation matrix D3DXMatrixTranslation(&matTrans, -0.5, -room_height - 0.5, 0); D3DXMatrixScaling(&matScale, 1, -1, 1); // Calculate our world matrix by multiplying the above (in the correct order) D3DXMATRIX matWorld = matTrans * matScale; // Set the matrix to be applied to anything we render from now on d3ddev->SetTransform( D3DTS_VIEW, &matWorld); D3DXMATRIX matProjection; // the projection transform matrix D3DXMatrixOrthoOffCenterLH(&matProjection, 0, (FLOAT)enigma::gui_width, 0, (FLOAT)enigma::gui_height, 0.0f, // the near view-plane 1.0f); // the far view-plane d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection transform //dsprite->SetWorldViewRH(NULL, &matWorld); // Clear the depth buffer if hidden surface removal is on at the beginning of the draw step. if (enigma::d3dMode) d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); bool stop_loop = false; for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++) { enigma::inst_iter* push_it = enigma::instance_event_iterator; //loop instances for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) { enigma::instance_event_iterator->inst->myevent_drawgui(); if (enigma::room_switching_id != -1) { stop_loop = true; break; } } enigma::instance_event_iterator = push_it; if (stop_loop) break; } } // Textures should be clamped when rendering 2D sprites and stuff, so memorize it. DWORD wrapu, wrapv, wrapw; d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSU, &wrapu ); d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSV, &wrapv ); d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSW, &wrapw ); d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP ); // The D3D sprite batcher uses clockwise face culling which is default but can't tell if // this here should memorize it and force it to CW all the time and then reset what the user had // or not. //d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); dsprite->End(); // And now reset the texture repetition. d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSU, wrapu ); d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSV, wrapv ); d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSW, wrapw ); // reset the culling d3d_set_culling(culling); d3ddev->EndScene(); // ends the 3D scene screen_refresh(); }
void show_info(string info, int bgcolor, int left, int top, int width, int height, bool embedGameWindow, bool showBorder, bool allowResize, bool stayOnTop, bool pauseGame, string caption) { LoadLibrary(TEXT("Riched32.dll")); // Center Information Window to the Middle of the Screen if (left < 0) { left = (GetSystemMetrics(SM_CXSCREEN) - width)/2; } if (top < 0) { top = (GetSystemMetrics(SM_CYSCREEN) - height)/2; } HWND main; //TODO: Fix me embedGameWindow = false; if (embedGameWindow) { main = enigma::hWnd; } else { WNDCLASS wc = {CS_VREDRAW|CS_HREDRAW,(WNDPROC)ShowInfoProc,0,0,enigma::hInstance,0, 0,GetSysColorBrush(COLOR_WINDOW),0,"infodialog"}; RegisterClass(&wc); DWORD flags = WS_VISIBLE|WS_POPUP|WS_SYSMENU|WS_TABSTOP|WS_CLIPCHILDREN; // DS_3DLOOK|DS_CENTER|DS_FIXEDSYS if (showBorder) { flags |= WS_BORDER | WS_DLGFRAME | WS_CAPTION; } if (stayOnTop) { flags |= DS_MODALFRAME; // Same as WS_EX_TOPMOST } if (allowResize) { flags |= WS_SIZEBOX; } main = CreateWindow("infodialog", TEXT(caption.c_str()), flags, left, top, width, height, enigma::hWnd, 0, enigma::hInstance, 0); if (showBorder) { // Set Window Information Icon HICON hIcon = LoadIcon(enigma::hInstance, MAKEINTRESOURCE(3)); if (hIcon) { SendMessage(main, WM_SETICON, ICON_SMALL,(LPARAM)hIcon); SendMessage(main, WM_SETICON, ICON_BIG, (LPARAM)hIcon); } } } enigma::infore=CreateWindowEx(WS_EX_TOPMOST,"RICHEDIT",TEXT("information text"), ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 0,0,width,height,main,0,enigma::hInstance,0); // Size the RTF Component to the Window RECT rectParent; GetClientRect(main, &rectParent); MoveWindow(enigma::infore, rectParent.top, rectParent.left, rectParent.right, rectParent.bottom, TRUE); // Set RTF Editor Background Color SendMessage(enigma::infore, EM_SETBKGNDCOLOR, (WPARAM)0, (LPARAM)RGB(__GETR(bgcolor), __GETG(bgcolor), __GETB(bgcolor))); // Set RTF Information Text SETTEXTEX se; se.codepage = CP_ACP; se.flags = ST_DEFAULT; SendMessage(enigma::infore, EM_SETTEXTEX, (WPARAM)&se, (LPARAM)info.c_str()); //TODO: Figure out how to block if we need to pause the game, otherwise ShowWindowAsync ShowWindow(main,SW_SHOWDEFAULT); if (!embedGameWindow) { SetFocus(enigma::infore); } /* MSG msg; BOOL bRet; bool bQuit = false; while (!bQuit) { bRet = PeekMessage(&msg, main, 0, 0, PM_REMOVE); if (bRet == -1) { // handle the error and possibly exit } else if (msg.message == WM_CLOSE) { bQuit = true; } else { TranslateMessage(&msg); DispatchMessage(&msg); } }*/ /* Round two... MSG msg; BOOL bRet; bool bQuit = false; while (!bQuit) { // Check RTF Control Messages bRet = PeekMessage(&msg, infore, 0, 0, PM_REMOVE); if (bRet == -1) { // handle the error and possibly exit PostMessage(embedGameWindow ? infore : main, WM_CLOSE, 0, 0); bQuit = true; } else { if (msg.message == WM_KEYUP) { switch(msg.wParam) { case VK_ESCAPE: PostMessage(embedGameWindow ? infore : main, WM_CLOSE, 0, 0); bQuit = true; break; } } else { TranslateMessage(&msg); DispatchMessage(&msg); } } // If game information was showed in a separate window, then handle the messages for sizing and stuff if (!embedGameWindow) { bRet = PeekMessage(&msg, main, 0, 0, PM_REMOVE); if (bRet == -1) { // handle the error and possibly exit PostMessage(main, WM_CLOSE, 0, 0); bQuit = true; } else { if (msg.message == WM_KEYUP) { switch(msg.wParam) { case VK_ESCAPE: PostMessage(main, WM_CLOSE, 0, 0); bQuit = true; break; } } else if (msg.message == WM_SIZE) { RECT rectParent; GetClientRect(main, &rectParent); MoveWindow(infore, rectParent.top, rectParent.left, rectParent.right, rectParent.bottom, TRUE); } else { TranslateMessage(&msg); DispatchMessage(&msg); } } } } */ }
void d3d_light_define_ambient(int col) { float color[4] = {float(__GETR(col)), float(__GETG(col)), float(__GETB(col)), 1.0f}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color); }
void draw_set_color(int col) { enigma::currentcolor[0] = __GETR(col); enigma::currentcolor[1] = __GETG(col); enigma::currentcolor[2] = __GETB(col); }
void draw_clear_alpha(int col, float alpha) { d3dmgr->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_COLORVALUE(__GETR(col), __GETG(col), __GETB(col), alpha), 1.0f, 0); }
void draw_clear(int col) { glClearColor(__GETR(col)/255.0,__GETG(col)/255.0,__GETB(col)/255.0,1); glClear(GL_COLOR_BUFFER_BIT); }
void draw_clear_alpha(int col,float alpha) { //Unfortunately, we lack a 255-based method for setting ClearColor. glClearColor(__GETR(col)/255.0,__GETG(col)/255.0,__GETB(col)/255.0,alpha); glClear(GL_COLOR_BUFFER_BIT); }
int color_get_saturation(int color) { int r = __GETR(color), g = __GETG(color), b = __GETB(color); int cmpmax = r>g ? (r>b ? r : b) : (g>b ? g : b); return cmpmax ? 255 - int(255 * (r<g ? (r<b?r:b) : (g<b?g:b)) / double(cmpmax)) : 0; }
int color_get_value(int c) { int r = __GETR(c), g = __GETG(c), b = __GETB(c); return r>g ? (r>b?r:b) : (g>b?g:b); }
int color_get_blue (int c) { return __GETB(c); }
void d3d_set_fog_color(int color) { d3dmgr->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_COLORVALUE(__GETR(color), __GETG(color), __GETB(color), 1.0f)); // Highest 8 bits are not used. }
void d3d_light_define_ambient(int col) { d3dmgr->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(__GETR(col), __GETG(col), __GETB(col), 1)); }
void draw_clear(int col) { d3dmgr->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(__GETR(col), __GETG(col), __GETB(col)), 1.0f, 0); }