Ejemplo n.º 1
0
void CSegment::Read (CFile& cf)
{
#if DBG
if (Index () == nDbgSeg)
	nDbgSeg = nDbgSeg;
#endif
if (gameStates.app.bD2XLevel) {
	m_owner = cf.ReadByte ();
	m_group = cf.ReadByte ();
	}
else {
	m_owner = -1;
	m_group = -1;
	}

ubyte flags = bNewFileFormat ? cf.ReadByte () : 0x7f;

if (gameData.segs.nLevelVersion == 5) { // d2 SHAREWARE level
	ReadType (cf, flags);
	ReadVerts (cf);
	ReadChildren (cf, flags);
	}
else {
	ReadChildren (cf, flags);
	ReadVerts (cf);
	if (gameData.segs.nLevelVersion <= 1) { // descent 1 level
		ReadType (cf, flags);
		}
	}
m_objects = -1;

if (gameData.segs.nLevelVersion <= 5) // descent 1 thru d2 SHAREWARE level
	m_xAvgSegLight	= fix (cf.ReadShort ()) << 4;

// Read the walls as a 6 byte array
flags = bNewFileFormat ? cf.ReadByte () : 0x3f;

int i;

for (i = 0; i < MAX_SIDES_PER_SEGMENT; i++)
	m_sides [i].ReadWallNum (cf, (flags & (1 << i)) != 0);

ushort sideVerts [4];

for (i = 0; i < MAX_SIDES_PER_SEGMENT; i++) {
	::GetCorners (Index (), i, sideVerts);
	m_sides [i].Read (cf, sideVerts, m_children [i] == -1);
	}
}
Ejemplo n.º 2
0
void PezInitialize()
{
    TweakBar = TwNewBar("TweakBar");
    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar.
    TwDefine(" TweakBar size='200 400' color='96 216 224' "); // change default tweak bar size and color

    TwAddVarRW(TweakBar, "Theta", TW_TYPE_FLOAT, &Scene.Theta, " min=0.01 max=6.28 step=0.01 ");
    TwAddVarRW(TweakBar, "TargetVector", TW_TYPE_DIR3F, &TargetVector, " ");
    TwAddVarRW(TweakBar, "TargetScale", TW_TYPE_FLOAT, &TargetScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "EyeVector", TW_TYPE_DIR3F, &EyeVector, " ");
    TwAddVarRW(TweakBar, "EyeScale", TW_TYPE_FLOAT, &EyeScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "YScale", TW_TYPE_FLOAT, &YScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "YOffset", TW_TYPE_FLOAT, &YOffset, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "TessLevel", TW_TYPE_FLOAT, &TessLevel, " min=1.0 max=10.00 step=0.01 ");
    TwAddButton(TweakBar, "Lookup AO", LookupAoCallback, 0, "");
    TwAddVarRW(TweakBar, "Show AO", TW_TYPE_BOOL8, &ShowAO, "");

    PezConfig cfg = PezGetConfig();

    pezAddPath("../Cover/PostTess/", ".glsl");
    Scene.DisplayProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Display");
    Scene.FloorProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Floor");
    Scene.OffscreenProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Offscreen");
    Scene.QuadProgram = LoadProgram("PostTess.Quad.VS", 0, 0, 0, "PostTess.Quad.FS");
    Scene.Theta = 2.36f;

    Scene.Surfaces = CreateSurfaces(cfg.Width, cfg.Height, 4, 3);
    GLenum err = glGetError();
    pezCheck(err == GL_NO_ERROR, "OpenGL error.\n");

    Scene.QuadVao = CreateQuad();

    ReadVerts("../Cover/PreTess/City.dat");
    glEnable(GL_DEPTH_TEST);
    glClearColor(0, 0, 0, 0);

    glGenTextures(1, &Scene.CompositeTexture);
    glBindTexture(GL_TEXTURE_2D, Scene.CompositeTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, cfg.Width, cfg.Height, GL_FALSE, GL_RGBA, GL_FLOAT, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    err = glGetError();
    pezCheck(err == GL_NO_ERROR, "OpenGL error.\n");
}