Пример #1
0
void ogl_ulinec(int left,int top,int right,int bot,int c)
{
	GLfloat xo,yo,xf,yf;
	GLfloat color_array[] = { CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0) };
	GLfloat vertex_array[] = { 0.0, 0.0, 0.0, 0.0 };

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	
	xo = (left + grd_curcanv->cv_bitmap.bm_x + 0.5) / (float)last_width;
	xf = (right + grd_curcanv->cv_bitmap.bm_x + 1.0) / (float)last_width;
	yo = 1.0 - (top + grd_curcanv->cv_bitmap.bm_y + 0.5) / (float)last_height;
	yf = 1.0 - (bot + grd_curcanv->cv_bitmap.bm_y + 1.0) / (float)last_height;
 
	OGL_DISABLE(TEXTURE_2D);

	vertex_array[0] = xo;
	vertex_array[1] = yo;
	vertex_array[2] = xf;
	vertex_array[3] = yf;

	glVertexPointer(2, GL_FLOAT, 0, vertex_array);
	glColorPointer(4, GL_FLOAT, 0, color_array);
	glDrawArrays(GL_LINES, 0, 2);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
}
Пример #2
0
void ogl_upixelc(int x, int y, int c)
{
	GLfloat vertex_array[] = { (x+grd_curcanv->cv_bitmap.bm_x)/(float)last_width, 1.0-(y+grd_curcanv->cv_bitmap.bm_y)/(float)last_height };
	GLfloat color_array[] = { CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0 };

	r_upixelc++;
	OGL_DISABLE(TEXTURE_2D);
	glPointSize(linedotscale);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glVertexPointer(2, GL_FLOAT, 0, vertex_array);
	glColorPointer(4, GL_FLOAT, 0, color_array);
	glDrawArrays(GL_POINTS, 0, 1);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
}
Пример #3
0
Файл: vid.c Проект: btb/d2x
void ogl_urect(int left,int top,int right,int bot){
	GLfloat xo,yo,xf,yf;
	int c=COLOR;
	
	xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
	xf = (right + 1 + grd_curcanv->cv_bitmap.bm_x) / (float)last_width;
	yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
	yf = 1.0 - (bot + 1 + grd_curcanv->cv_bitmap.bm_y) / (float)last_height;

	OGL_DISABLE(TEXTURE_2D);
	if (Gr_scanline_darkening_level >= GR_FADE_LEVELS)
		glColor3f(CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c));
	else
		glColor4f(CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0));
	glBegin(GL_QUADS);
	glVertex2f(xo,yo);
	glVertex2f(xo,yf);
	glVertex2f(xf,yf);
	glVertex2f(xf,yo);
	glEnd();
}
Пример #4
0
void ogl_ulinec(int left,int top,int right,int bot,int c) {
    GLfloat xo,yo,xf,yf;

    xo=(left+grd_curcanv->cv_bitmap.bm_x+0.5)/(float)last_width;
    xf=(right+grd_curcanv->cv_bitmap.bm_x+0.5)/(float)last_width;
    yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y+0.5)/(float)last_height;
    yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y+0.5)/(float)last_height;

    OGL_DISABLE(TEXTURE_2D);
    glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
    glBegin(GL_LINES);
    glVertex2f(xo,yo);
    glVertex2f(xf,yf);
    glEnd();
}
Пример #5
0
void ogl_urect(int left,int top,int right,int bot)
{
	GLfloat xo, yo, xf, yf, color_r, color_g, color_b, color_a;
	GLfloat color_array[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
	GLfloat vertex_array[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
	int c=COLOR;

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);

	xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
	xf = (right + 1 + grd_curcanv->cv_bitmap.bm_x) / (float)last_width;
	yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
	yf = 1.0 - (bot + 1 + grd_curcanv->cv_bitmap.bm_y) / (float)last_height;

	OGL_DISABLE(TEXTURE_2D);

	color_r = CPAL2Tr(c);
	color_g = CPAL2Tg(c);
	color_b = CPAL2Tb(c);

	if (grd_curcanv->cv_fade_level >= GR_FADE_OFF)
		color_a = 1.0;
	else
		color_a = 1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0);

	color_array[0] = color_array[4] = color_array[8] = color_array[12] = color_r;
	color_array[1] = color_array[5] = color_array[9] = color_array[13] = color_g;
	color_array[2] = color_array[6] = color_array[10] = color_array[14] = color_b;
	color_array[3] = color_array[7] = color_array[11] = color_array[15] = color_a;

	vertex_array[0] = xo;
	vertex_array[1] = yo;
	vertex_array[2] = xo;
	vertex_array[3] = yf;
	vertex_array[4] = xf;
	vertex_array[5] = yf;
	vertex_array[6] = xf;
	vertex_array[7] = yo;
	
	glVertexPointer(2, GL_FLOAT, 0, vertex_array);
	glColorPointer(4, GL_FLOAT, 0, color_array);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);//replaced GL_QUADS
	glDisableClientState(GL_VERTEX_ARRAY);
}
Пример #6
0
void ogl_urect(int left,int top,int right,int bot) {
    GLfloat xo,yo,xf,yf;
    int c=COLOR;

    xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
    xf=(right+1+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
    yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
    yf=1.0-(bot+1+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;

    OGL_DISABLE(TEXTURE_2D);
    glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
    glBegin(GL_QUADS);
    glVertex2f(xo,yo);
    glVertex2f(xo,yf);
    glVertex2f(xf,yf);
    glVertex2f(xf,yo);
    glEnd();
}
Пример #7
0
void ogl_upixelc(int x, int y, int c) {
    r_upixelc++;
//	printf("gr_upixelc(%i,%i,%i)%i\n",x,y,c,Function_mode==FMODE_GAME);
//	if(Function_mode != FMODE_GAME){
//		grd_curcanv->cv_bitmap.bm_data[y*grd_curscreen->sc_canvas.cv_bitmap.bm_w+x]=c;
//	}else{
    OGL_DISABLE(TEXTURE_2D);
    glPointSize(1.0);
    glBegin(GL_POINTS);
//		glBegin(GL_LINES);
//	ogl_pal=gr_current_pal;
    glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
//	ogl_pal=gr_palette;
    glVertex2f((x+grd_curcanv->cv_bitmap.bm_x+0.5)/(float)last_width,1.0-(y+grd_curcanv->cv_bitmap.bm_y+0.5)/(float)last_height);
//		glVertex2f(x/((float)last_width+1),1.0-y/((float)last_height+1));
    glEnd();
//	}
}
Пример #8
0
tG3ModelFace *G3AddModelFace (tG3Model *pm, tG3SubModel *psm, tG3ModelFace *pmf, vmsVector *pn, ubyte *p,
										grsBitmap **modelBitmaps, tRgbaColorf *pObjColor)
{
	short				nVerts = WORDVAL (p+2);
	tG3ModelVertex	*pmv;
	short				*pfv;
	tUVL				*uvl;
	grsBitmap		*bmP;
	tRgbaColorf		baseColor;
	fVector3			n, *pvn;
	short				i, j;
	ushort			c;
	char				bTextured;

if (!psm->pFaces)
	psm->pFaces = pmf;
Assert (pmf - pm->pFaces < pm->nFaces);
if (modelBitmaps && *modelBitmaps) {
	bTextured = 1;
	pmf->nBitmap = WORDVAL (p+28);
	bmP = modelBitmaps [pmf->nBitmap];
	if (pObjColor) {
		ubyte c = bmP->bmAvgColor;
		pObjColor->red = CPAL2Tr (gamePalette, c);
		pObjColor->green = CPAL2Tg (gamePalette, c);
		pObjColor->blue = CPAL2Tb (gamePalette, c);
		}
	baseColor.red = baseColor.green = baseColor.blue = baseColor.alpha = 1;
	i = (int) (bmP - gameData.pig.tex.bitmaps [0]);
	pmf->bThruster = (i == 24) || ((i >= 1741) && (i <= 1745));
	}
else {
	bTextured = 0;
	pmf->nBitmap = -1;
	c = WORDVAL (p + 28);
	baseColor.red = (float) PAL2RGBA (((c >> 10) & 31) << 1) / 255.0f;
	baseColor.green = (float) PAL2RGBA (((c >> 5) & 31) << 1) / 255.0f;
	baseColor.blue = (float) PAL2RGBA ((c & 31) << 1) / 255.0f;
	baseColor.alpha = GrAlpha ();
	if (pObjColor)
		*pObjColor = baseColor;
	}
pmf->nSubModel = psm - pm->pSubModels;
pmf->vNormal = *pn;
pmf->nIndex = pm->iFaceVert;
pmv = pm->pFaceVerts + pm->iFaceVert;
pvn = pm->pVertNorms + pm->iFaceVert;
if (psm->nIndex < 0)
	psm->nIndex = pm->iFaceVert;
pmf->nVerts = nVerts;
if ((pmf->bGlow = (nGlow >= 0)))
	nGlow = -1;
uvl = (tUVL *) (p + 30 + (nVerts | 1) * 2);
n = pn->ToFloat3();
for (i = nVerts, pfv = WORDPTR (p+30); i; i--, pfv++, uvl++, pmv++, pvn++) {
	j = *pfv;
	Assert (pmv - pm->pFaceVerts < pm->nFaceVerts);
	pmv->vertex = pm->pVerts [j];
	pmv->texCoord.v.u = X2F (uvl->u);
	pmv->texCoord.v.v = X2F (uvl->v);
	pmv->renderColor =
	pmv->baseColor = baseColor;
	pmv->bTextured = bTextured;
	pmv->nIndex = j;
	pmv->normal = *pvn = n;
	G3SetSubModelMinMax (psm, &pmv->vertex);
	}
pm->iFaceVert += nVerts;
pm->iFace++;
psm->nFaces++;
return ++pmf;
}
Пример #9
0
bool OglUBitMapMC(int x, int y,grs_bitmap *bm,int c)
{
	GLint curFunc;
	GLdouble xo,yo,xf,yf;
	GLdouble u1,u2,v1,v2;

r_ubitmapc++;
x+=grdCurCanv->cv_bitmap.bm_props.x;
y+=grdCurCanv->cv_bitmap.bm_props.y;
xo=x/(double)last_width;
xf=(bm->bm_props.w+x)/(double)last_width;
yo=1.0-y/(double)last_height;
yf=1.0-(bm->bm_props.h+y)/(double)last_height;

glActiveTextureARB(GL_TEXTURE0_ARB);
OglBindBmTex(bm);
OglTexWrap(bm->glTexture,GL_CLAMP);

glEnable(GL_TEXTURE_2D);
glGetIntegerv (GL_DEPTH_FUNC, &curFunc);
glDepthFunc(GL_ALWAYS);
glEnable (GL_ALPHA_TEST);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

if (bm->bm_props.x==0) {
	u1=0;
	if (bm->bm_props.w==bm->glTexture->w)
		u2=bm->glTexture->u;
	else
		u2=(bm->bm_props.w+bm->bm_props.x)/(double)bm->glTexture->tw;
	}
else {
	u1=bm->bm_props.x/(double)bm->glTexture->tw;
	u2=(bm->bm_props.w+bm->bm_props.x)/(double)bm->glTexture->tw;
	}
if (bm->bm_props.y==0) {
	v1=0;
	if (bm->bm_props.h==bm->glTexture->h)
		v2=bm->glTexture->v;
	else
		v2=(bm->bm_props.h+bm->bm_props.y)/(double)bm->glTexture->th;
	}
else{
	v1=bm->bm_props.y/(double)bm->glTexture->th;
	v2=(bm->bm_props.h+bm->bm_props.y)/(double)bm->glTexture->th;
	}

glBegin(GL_QUADS);
if (c < 0)
	glColor3d (1.0,1.0,1.0);
else
	glColor3d (CPAL2Tr (bmP->bm_palette, c), CPAL2Tg (bmP->bm_palette, c), CPAL2Tb (bmP->bm_palette, c));
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,u1, v1);
glVertex2d(xo, yo);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,u2, v1);
glVertex2d(xf, yo);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,u2, v2);
glVertex2d(xf, yf);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,u1, v2);
glVertex2d(xo, yf);
glEnd();
glDepthFunc(curFunc);
glDisable (GL_ALPHA_TEST);
glDisable (GL_BLEND);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D,0);
glDisable(GL_TEXTURE_2D);
return 0;
}
Пример #10
0
bool G3DrawPolyModel (
	tObject		*objP, 
	void			*modelP, 
	grsBitmap	**modelBitmaps, 
	vmsAngVec	*pAnimAngles, 
	vmsVector	*vOffset,
	fix			xModelLight, 
	fix			*xGlowValues, 
	tRgbaColorf	*pObjColor,
	tPOFObject  *po,
	int			nModel)
{
	ubyte *p = modelP;
	short	h;
	short bGetThrusterPos = !objP || ((objP->nType == OBJ_PLAYER) || (objP->nType == OBJ_ROBOT) || ((objP->nType == OBJ_WEAPON) && gameData.objs.bIsMissile [objP->id]));
	short bLightnings = SHOW_LIGHTNINGS && gameOpts->render.lightnings.bDamage && objP && (ObjectDamage (objP) < 0.5f);

	static int nDepth = -1;

#if DBG_SHADOWS
if (bShadowTest)
	return 1;
#endif
#if CONTOUR_OUTLINE
//if (extraGameInfo [0].bShadows && (gameStates.render.nShadowPass < 3))
	return 1;
#endif
nDepth++;
G3CheckAndSwap (modelP);
if (SHOW_DYN_LIGHT && 
	!nDepth && !po && objP && ((objP->nType == OBJ_ROBOT) || (objP->nType == OBJ_PLAYER))) {
	po = gameData.models.pofData [gameStates.app.bD1Mission][0] + nModel;
	POFGatherPolyModelItems (objP, modelP, pAnimAngles, po, 0);
	}
nGlow = -1;		//glow off by default
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
for (;;) {
	h = WORDVAL (p);
	if (h == OP_EOF)
		break;
	else if (h == OP_DEFPOINTS) {
		int n = WORDVAL (p+2);
		RotatePointList (modelPointList, VECPTR (p+4), po ? po->pVertNorms : NULL, n, 0);
		p += n * sizeof (vmsVector) + 4;
		break;
		}
	else if (h == OP_DEFP_START) {
		int n = WORDVAL (p+2);
		int s = WORDVAL (p+4);

		RotatePointList (modelPointList, VECPTR (p+8), po ? po->pVertNorms : NULL, n, s);
		p += n * sizeof (vmsVector) + 8;
		}
	else if (h == OP_FLATPOLY) {
		int nVerts = WORDVAL (p+2);
		Assert (nVerts < MAX_POINTS_PER_POLY);
#if CHECK_NORMAL_FACING
		if (G3CheckNormalFacing (VECPTR (p+4), VECPTR (p+16)) > 0) 
#endif
			{
			int i;
			//fix l = f2i (32 * xModelLight);
			GrSetColorRGB15bpp (WORDVAL (p+28), (ubyte) (255 * GrAlpha ()));
			GrFadeColorRGB (1.0);
			if (pObjColor) {
				pObjColor->red = (float) grdCurCanv->cvColor.color.red / 255.0f; 
				pObjColor->green = (float) grdCurCanv->cvColor.color.green / 255.0f;
				pObjColor->blue = (float) grdCurCanv->cvColor.color.blue / 255.0f;
				}
			p += 30;
			for (i = 0; i < nVerts; i++)
				pointList [i] = modelPointList + WORDPTR (p) [i];
			G3DrawPoly (nVerts, pointList);
			}
#if CHECK_NORMAL_FACING
		else
			p += 30;
#endif
		p += (nVerts | 1) * 2;
		}
	else if (h == OP_TMAPPOLY) {
		int nVerts = WORDVAL (p+2);
		Assert ( nVerts < MAX_POINTS_PER_POLY );
#if CHECK_NORMAL_FACING
		if (G3CheckNormalFacing (VECPTR (p+4), VECPTR (p+16)) > 0) 
#endif
			{
			tUVL *uvlList;
			int i;
			fix l;
			vmsVector *pvn = VECPTR (p+16);

			//calculate light from surface normal
			if (nGlow < 0) {			//no glow
				l = -VmVecDot (&viewInfo.view [0].fVec, VECPTR (p+16));
				l = f1_0 / 4 + (l * 3) / 4;
				l = FixMul (l, xModelLight);
				}
			else {				//yes glow
				l = xGlowValues [nGlow];
				nGlow = -1;
				}
			//now poke light into l values
			uvlList = (tUVL *) (p + 30 + (nVerts | 1) * 2);
			for (i = 0; i < nVerts; i++)
				uvlList [i].l = l;

			if (pObjColor) {
				unsigned char c = modelBitmaps [WORDVAL (p+28)]->bmAvgColor;
				pObjColor->red = CPAL2Tr (gamePalette, c);
				pObjColor->green = CPAL2Tg (gamePalette, c);
				pObjColor->blue = CPAL2Tb (gamePalette, c);
				}
			p += 30;
			for (i = 0; i < nVerts; i++)
				pointList [i] = modelPointList + WORDPTR (p) [i];
			tMapColor = gameData.objs.color;
			if (gameStates.render.bCloaked)
				G3DrawTexPolyFlat (nVerts, pointList, uvlList, NULL, modelBitmaps [WORDVAL (p-2)], NULL, NULL, VECPTR (p+16), 0, 1);
			else
				G3DrawTexPolySimple (nVerts, pointList, uvlList, modelBitmaps [WORDVAL (p-2)], VECPTR (p+16), 1);
			if (!gameStates.render.bBriefing) {
				if (bLightnings)
					RenderDamageLightnings (objP, pointList, NULL, nVerts);
				if (bGetThrusterPos)
					GetThrusterPos (nModel, pvn, vOffset, modelBitmaps [WORDVAL (p-2)], nVerts);
				}
			}
#if CHECK_NORMAL_FACING
		else
			p += 30;
#endif
		p += (nVerts | 1) * 2 + nVerts * 12;
		}
	else if (h == OP_SORTNORM) {
#if CHECK_NORMAL_FACING
		if (G3CheckNormalFacing (VECPTR (p+16), VECPTR (p+4)) > 0) 
#endif
			{		//facing
			//draw back then front
			if (!(G3DrawPolyModel (objP, p + WORDVAL (p+30), modelBitmaps, pAnimAngles, vOffset, xModelLight, xGlowValues, pObjColor, po, nModel) &&
					G3DrawPolyModel (objP, p + WORDVAL (p+28), modelBitmaps, pAnimAngles, vOffset, xModelLight, xGlowValues, pObjColor, po, nModel)))
				return 0;
			}
#if CHECK_NORMAL_FACING
		else {			//not facing.  draw front then back
			if (!(G3DrawPolyModel (objP, p + WORDVAL (p+28), modelBitmaps, pAnimAngles, vOffset, xModelLight, xGlowValues, pObjColor, po, nModel) &&
					G3DrawPolyModel (objP, p + WORDVAL (p+30), modelBitmaps, pAnimAngles, vOffset, xModelLight, xGlowValues, pObjColor, po, nModel)))
				return 0;
			}
#endif
		p += 32;
		}
	else if (h == OP_RODBM) {
		g3sPoint rodBotP, rodTopP;
		G3TransformAndEncodePoint (&rodBotP, VECPTR (p+20));
		G3TransformAndEncodePoint (&rodTopP, VECPTR (p+4));
		G3DrawRodTexPoly (modelBitmaps [WORDVAL (p+2)], &rodBotP, WORDVAL (p+16), &rodTopP, WORDVAL (p+32), f1_0, NULL);
		p += 36;
		}
	else if (h == OP_SUBCALL) {
		vmsAngVec	*va;
		vmsVector	vo;

		va = pAnimAngles ? pAnimAngles + WORDVAL (p+2) : NULL;
		vo = *VECPTR (p+4);
		if (gameData.models.nScale)
			VmVecScale (&vo, gameData.models.nScale);
		G3StartInstanceAngles (&vo, va);
		if (vOffset)
			VmVecInc (&vo, vOffset);
		if (!G3DrawPolyModel (objP, p + WORDVAL (p+16), modelBitmaps, pAnimAngles, &vo, xModelLight, xGlowValues, pObjColor, po, nModel)) {
			G3DoneInstance ();
			return 0;
			}
		G3DoneInstance ();
		p += 20;
		}
	else if (h == OP_GLOW) {
		if (xGlowValues)
			nGlow = WORDVAL (p+2);
		p += 4;
		}
	else {
#ifdef _DEBUG
		LogErr ("invalid polygon model\n");
#endif
		return 0;
		}
	}
nDepth--;
return 1;
}