void Draw_Sprite2D(int type, int rot, int frame, int x, int y, float scale, int pal, rcolor c) { spritedef_t *sprdef; spriteframe_t *sprframe; float flip = 0.0f; int w; int h; int offsetx = 0; int offsety = 0; GL_SetState(GLSTATE_BLEND, 1); sprdef=&spriteinfo[type]; sprframe = &sprdef->spriteframes[frame]; GL_BindSpriteTexture(sprframe->lump[rot], pal); w = spritewidth[sprframe->lump[rot]]; h = spriteheight[sprframe->lump[rot]]; if(scale <= 1.0f) { if(sprframe->flip[rot]) { flip = 1.0f; } else { flip = 0.0f; } offsetx = (int)spriteoffset[sprframe->lump[rot]]; offsety = (int)spritetopoffset[sprframe->lump[rot]]; } GL_SetOrthoScale(scale); GL_SetupAndDraw2DQuad(flip ? (float)(x + offsetx) - w : (float)x - offsetx, (float)y - offsety, w, h, flip, 1.0f - flip, 0, 1.0f, c, 0); GL_SetOrthoScale(1.0f); cursprite = -1; curgfx = -1; GL_SetState(GLSTATE_BLEND, 0); }
void DL_ProcessDrawList(int tag, dboolean(*procfunc) (vtxlist_t *, int *)) { drawlist_t *dl; int i; int drawcount = 0; vtxlist_t *head; vtxlist_t *tail; dboolean checkNightmare = false; if (tag < 0 && tag >= NUMDRAWLISTS) return; dl = &drawlist[tag]; if (dl->max > 0) { int palette = 0; if (tag != DLT_SPRITE) { qsort(dl->list, dl->index, sizeof(vtxlist_t), SortDrawList); } else if (dl->index >= 2) { qsort(dl->list, dl->index, sizeof(vtxlist_t), SortSprites); } tail = &dl->list[dl->index]; for (i = 0; i < dl->index; i++) { vtxlist_t *rover; head = &dl->list[i]; // break if no data found in list if (!head->data) break; if (drawcount >= MAXDLDRAWCOUNT) I_Error ("DL_ProcessDrawList: Draw overflow by %i, tag=%i", dl->index, tag); if (procfunc) { if (!procfunc(head, &drawcount)) continue; } rover = head + 1; if (tag != DLT_SPRITE) { if (rover != tail) { if (head->texid == rover->texid && head->params == rover->params) continue; } } // setup texture ID if (tag == DLT_SPRITE) { int flags = ((visspritelist_t *) head->data)->spr-> flags; // textid in sprites contains hack that stores palette index data palette = head->texid >> 24; head->texid = head->texid & 0xffff; GL_BindSpriteTexture(head->texid, palette); // villsa 12152013 - change blend states for nightmare things if ((checkNightmare ^ (flags & MF_NIGHTMARE))) { if (!checkNightmare && (flags & MF_NIGHTMARE)) { dglBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR); checkNightmare ^= 1; } else if (checkNightmare && !(flags & MF_NIGHTMARE)) { dglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); checkNightmare ^= 1; } } } else {