Exemple #1
0
/*
 * R_DrawSurfacesLines_default
 */
static void R_DrawSurfacesLines_default(const r_bsp_surfaces_t *surfs) {
	unsigned int i;

	R_EnableTexture(&texunit_diffuse, false);

	R_EnableColorArray(true);

	R_SetArrayState(r_world_model);

	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	for (i = 0; i < surfs->count; i++) {

		if (surfs->surfaces[i]->frame != r_locals.frame)
			continue;

		R_DrawSurface_default(surfs->surfaces[i]);
	}

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	R_EnableColorArray(false);

	R_EnableTexture(&texunit_diffuse, true);
}
Exemple #2
0
/*
 * R_DrawSurfaces_default
 */
static void R_DrawSurfaces_default(const r_bsp_surfaces_t *surfs) {
	unsigned int i;

	R_SetArrayState(r_world_model);

	// draw the surfaces
	for (i = 0; i < surfs->count; i++) {

		if (surfs->surfaces[i]->frame != r_locals.frame)
			continue;

		R_SetSurfaceState_default(surfs->surfaces[i]);

		R_DrawSurface_default(surfs->surfaces[i]);
	}

	// reset state
	if (r_state.lighting_enabled) {

		if (r_state.bumpmap_enabled)
			R_EnableBumpmap(NULL, false);

		R_EnableLights(0);
	}

	glColor4ubv(color_white);
}
Exemple #3
0
/**
 * @param[in] drawFunc The function pointer to the surface draw function
 * @param[in] surfType The primary rendering type of the surface
 */
static void R_RenderBspRRefs (drawSurfaceFunc drawFunc, surfaceArrayType_t surfType)
{
	glEnable(GL_CULL_FACE);
	glCullFace(GL_FRONT); /* our triangles are backwards to what OpenGL expects, so tell it to render only back faces */

	for (int i = 0; i < numBspRRefs; i++) {
		const bspRenderRef_t* const bspRR = &bspRRefs[i];
		const mBspModel_t* const bsp = bspRR->bsp;
		const mBspModel_t* const tile = &r_mapTiles[bsp->maptile]->bsp; /* This is required to find the tile (world) bsp model to which arrays belong (submodels do not own arrays, but use world model ones) */
		glElementIndex_t* indexPtr;

		if (!bsp->sorted_surfaces[surfType]->count)
			continue;

		R_SetArrayState(tile);

		/* Vertex buffers are nullptr-based, arrays are not */
		if (qglBindBuffer && r_vertexbuffers->integer)
			indexPtr = nullptr;
		else
			indexPtr = tile->indexes;

		glPushMatrix();

		glTranslatef(bspRR->origin[0], bspRR->origin[1], bspRR->origin[2]);
		glRotatef(bspRR->angles[YAW], 0, 0, 1);
		glRotatef(bspRR->angles[PITCH], 0, 1, 0);
		glRotatef(bspRR->angles[ROLL], 1, 0, 0);

		drawFunc(bsp->sorted_surfaces[surfType], indexPtr);

		/** @todo make it work again; also reimplement r_showbox 2 */
#if 0
		/* show model bounding box */
		if (r_showbox->integer) {
			const model_t* model = bspRR->bsp;
			R_DrawBoundingBox(model->mins, model->maxs);
		}
#endif

		glPopMatrix();
	}

	/* and restore array pointers */
	R_ResetArrayState();

	glCullFace(GL_BACK);
	glDisable(GL_CULL_FACE);
}
Exemple #4
0
/**
 * @brief Sets renderer state for the given entity.
 */
static void R_SetMeshShellState_default(const r_entity_t *e) {

	R_SetArrayState(e->model);

	R_SetMeshShellColor_default(e);

	R_RotateForEntity(e);

	if (e->effects & EF_WEAPON) {
		R_DepthRange(0.0, 0.3);
		R_UseShellOffset_shell(0.250);
	} else {
		R_UseShellOffset_shell(1.125);
	}

	// setup lerp for animating models
	if (e->old_frame != e->frame) {
		R_UseInterpolation(e->lerp);
	}
}