Пример #1
0
void renderScene( void ) {

	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	glLoadIdentity();
	gluLookAt(	0.0,0.0,10.0,
			0.0,0.0,0.0,
			0.0,1.0,0.0 );

	glPushMatrix();
	glTranslatef(-1.5,0.0,0.0);
	glRotatef(angle1, 0.0, 0.0, 1.0);
	glBegin(GL_TRIANGLES);
		glColor3i(red,green,blue);
		glVertex3f( -1.0, -1.0, 0.0 );
		glColor3i(red,green,blue);
		glVertex3f( 1.0, 0.0, 0.0 );
		glColor3i(red,green,blue);
		glVertex3f( 0.0, 1.0, 0.0 );
	glEnd();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(1.5,0.0,0.0);
	glRotatef(angle1, 0.0, 0.0, 1.0);
	glBegin(GL_TRIANGLES);
		glColor3f(1.0,0.0,0.0);
		glVertex3f( -1.0, -1.0, 0.0 );
		glColor3f(0.0,1.0,0.0);
		glVertex3f( 1.0, 0.0, 0.0 );
		glColor3f(0.0,0.0,1.0);
		glVertex3f( 0.0, 1.0, 0.0 );
	glEnd();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(0.0,1.5,0.0);
	glRotatef(angle1, 0.0, 0.0, 1.0);
	glBegin(GL_TRIANGLES);
		glColor3f(1.0,0.0,0.0);
		glVertex3f( -1.0, -1.0, 0.0 );
		glColor3f(0.0,1.0,0.0);
		glVertex3f( 1.0, 0.0, 0.0 );
		glColor3f(0.0,0.0,1.0);
		glVertex3f( 0.0, 1.0, 0.0 );
	glEnd();
	glPopMatrix();

	update();

	glutSwapBuffers();

}
Пример #2
0
void Floor::DrawDots()
{
	if(COLOR == BLACK)glColor3i(BB);
	else if(COLOR == WHITE)glColor3i(WW);
	glPointSize((GLint)1);
	glBegin(GL_POINTS);
	for(int x=0;x<WIDTH;x++){
		for(int y=0;y<HEIGHT;y++){
			if( dot[x][y] == COLOR )glVertex2i((GLint)x, (GLint)y);
		}
	}
	glEnd();
}
Пример #3
0
void Draw(float rotx, float roty, float rotz)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Apply some transformations for the cube
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0.0f, 0.0f, -200.f);

	glRotatef(rotx+45.0f, 0.0f, 1.0f, 0.0f);
	glRotatef(roty, 1.0f, 0.0f, 0.0f);
	glRotatef(rotz, 0.0f, 0.0f, 1.0f);


	//Draw a cube
	glBegin(GL_QUADS);//draw some squares
	glColor3i(0,1,1);
	glVertex3f(-50.0f, -50.0f, -50.0f);
	glVertex3f(-50.0f,  50.0f, -50.0f);
	glVertex3f( 50.0f,  50.0f, -50.0f);
	glVertex3f( 50.0f, -50.0f, -50.0f);

	glColor3f(0,0,1);
	glVertex3f(-50.f, -50.f, 50.f);
	glVertex3f(-50.f,  50.f, 50.f);
	glVertex3f( 50.f,  50.f, 50.f);
	glVertex3f( 50.f, -50.f, 50.f);

	glColor3f(1,0,1);
	glVertex3f(-50.f, -50.f, -50.f);
	glVertex3f(-50.f,  50.f, -50.f);
	glVertex3f(-50.f,  50.f,  50.f);
	glVertex3f(-50.f, -50.f,  50.f);

	glColor3f(0,1,0);
	glVertex3f(50.f, -50.f, -50.f);
	glVertex3f(50.f,  50.f, -50.f);
	glVertex3f(50.f,  50.f,  50.f);
	glVertex3f(50.f, -50.f,  50.f);

	glColor3f(1,1,0);
	glVertex3f(-50.f, -50.f,  50.f);
	glVertex3f(-50.f, -50.f, -50.f);
	glVertex3f( 50.f, -50.f, -50.f);
	glVertex3f( 50.f, -50.f,  50.f);

	glColor3f(1,0,0);
	glVertex3f(-50.f, 50.f,  50.f);
	glVertex3f(-50.f, 50.f, -50.f);
	glVertex3f( 50.f, 50.f, -50.f);
	glVertex3f( 50.f, 50.f,  50.f);

	glEnd();
}
Пример #4
0
/*
 * Name      : void vInitGL(int iXSize, int iYSize)
 *
 * Parameters: None.
 *
 * Returns   : void
 *
 * Purpose   : Initializes the components of GL
 */
void vInitGL(int iXSize, int iYSize)
{

    /*
     * Set various modes.
     */
    glEnable(GL_DEPTH_TEST);
    glClearColor( 1.0, 1.0, 1.0, 1.0 );\
    glColor3i( 0, 0, 0 );

    glViewport(0, 0, iXSize, iYSize);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(50.0, iXSize/iYSize, 0.1, 1000.0);
/*     lookat(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0); */
    glMatrixMode(GL_MODELVIEW);
}
Пример #5
0
void			draw_ground()
{
	extern t_client	t;
	extern GLuint	texture_ground;
	int		i;

	glBindTexture(GL_TEXTURE_2D, texture_ground);
	glColor3ub(255, 255, 255);
	glBegin(GL_QUADS);
		glTexCoord2i(0, 0);
		glVertex3i(-t.x_map, -t.y_map, 0);
		glTexCoord2i(t.x_map, 0);
		glVertex3i(t.x_map, -t.y_map, 0);
		glTexCoord2i(t.x_map, t.y_map);
		glVertex3i(t.x_map, t.y_map, 0);
		glTexCoord2i(0, t.y_map);
		glVertex3i(-t.x_map, t.y_map, 0);
	glEnd();
	glColor3i(0, 0, 0);
	glBegin(GL_LINES);
		for (i = 0;i * 2 != t.x_map * 2;i++)
		{
			glVertex2i(i * 2, -t.y_map * 2);
			glVertex2i(i * 2, t.y_map * 2);
		}
		for (i = 0;i * 2 != t.x_map * 2;i++)
		{
			glVertex2i(-i * 2, -t.y_map * 2);
			glVertex2i(-i * 2, t.y_map * 2);
		}
		for (i = 0;i * 2 != t.y_map * 2;i++)
		{
			glVertex2i(-t.x_map * 2, i * 2);
			glVertex2i(t.x_map * 2, i * 2);
		}
		for (i = 0;i * 2 != t.y_map * 2;i++)
		{
			glVertex2i(-t.x_map * 2, -i * 2);
			glVertex2i(t.x_map * 2, -i * 2);
		}
	glEnd();
}
Пример #6
0
void SimpleCameraModel::draw() {
	if (!ModelerDrawState::Instance()->showMarkers) { return; }

	Vec3f position, lookAt, up;
	float fov;
	toVectors(position, lookAt, up, fov);
	Vec3f direction = lookAt - position;
	direction.normalize();
	Vec3f side = direction ^ up;
	side.normalize();
	float h = tan(fov * M_PI / 360);
	side *= h; 
	up.normalize();
	up *= h * aspectRatio;

	glDisable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);

	glColor3i(1,0,0);
	glLineWidth(2);

	Vec3f topLeft = position + direction - side + up,
		topRight = position + direction + side + up,
		bottomLeft = position + direction - side - up,
		bottomRight = position + direction + side - up;
	glBegin(GL_LINES);
		position.glVertex(); topLeft.glVertex();
		position.glVertex(); topRight.glVertex();
		position.glVertex(); bottomLeft.glVertex();
		position.glVertex(); bottomRight.glVertex();
	glEnd();

	glBegin(GL_LINE_LOOP);
		topLeft.glVertex();
		topRight.glVertex();
		bottomRight.glVertex();
		bottomLeft.glVertex();
	glEnd();

	glEnable(GL_LIGHTING);
	glEnable(GL_TEXTURE_2D);
}
Пример #7
0
void GUIPlayerView::drawName(bool animating)
{
    glPushMatrix();
    glTranslatef(0, -(GUICard::CARDY/2 + 15), 0);
    if (status_ == ATTACKER)
        glColor3f(1,0,0);
    else if (status_ == DEFENDER || status_ == DEFENDERLOST)
        glColor3f(0,0,1);
    else
        glColor3i(0,0,0);
    name_->draw();

    glColor3f(1,1,1);
    glTranslatef(name_->getWidth()/2 + EMBLEM_SIZE/2. + 3, -5, 0);
    if (status_ == ATTACKER)
        drawEmblem(attackEmblem);
    else if (status_ == DEFENDER)
        drawEmblem(defendEmblem);
    else if (status_ == DEFENDERLOST)
        drawEmblem(defendLostEmblem);

    glPopMatrix();
}
Пример #8
0
void LegoCloudNode::render()
{
  /*float specularity_[4] = {0.7, 0.7, 0.7, 1.0};
  glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  glEnable(GL_COLOR_MATERIAL);
  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularity_);
  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 32);
  glLineWidth(getDefaultMaterial()->getEdgeWidth());
  glPointSize(getDefaultMaterial()->getVertexRadius());*/

//  glPushAttrib(GL_CULL_FACE | GL_POLYGON_MODE | GL_LINE_SMOOTH | GL_BLEND);
//  glEnable(GL_CULL_FACE);
//  glCullFace(GL_BACK);

//  glDisable(GL_LIGHTING);

//  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

  /*
  glEnable(GL_LINE_SMOOTH);
  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);                 // Set Line Antialiasing
  glEnable(GL_BLEND);                         // Enable Blending
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  */


  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_COLOR_MATERIAL);
  glShadeModel(GL_SMOOTH);

  const LegoGraph& graph = legoCloud_->getLegoGraph();

  if(renderBricks_)
  {
//    glPushAttrib(GL_POLYGON_OFFSET_FILL);
//    glEnable(GL_POLYGON_OFFSET_FILL);
//    glPolygonOffset(1.0, 1.0);

    LegoGraph::vertex_iterator vertexIt, vertexItEnd;
    for (boost::tie(vertexIt, vertexItEnd) = boost::vertices(graph); vertexIt != vertexItEnd; ++vertexIt)
    {
      LegoBrick* brick = graph[*vertexIt].brick;
      if((!renderLayerByLayer_ && brick->isOuter())|| (renderLayerByLayer_ && brick->getLevel() == renderLayer_))
      {
        setColor(*vertexIt);
        drawLegoBrick(*brick);
        //drawNeighbourhood(*brick, legoCloud_->getNeighbours(brick));
      }
    }

    glColor3i(0,0,0);
    for (boost::tie(vertexIt, vertexItEnd) = boost::vertices(graph); vertexIt != vertexItEnd; ++vertexIt)
    {
      LegoBrick* brick = graph[*vertexIt].brick;
      if((!renderLayerByLayer_ && brick->isOuter())|| (renderLayerByLayer_ && brick->getLevel() == renderLayer_))
      {

        drawBrickOutline(*brick);
        //drawNeighbourhood(*brick, legoCloud_->getNeighbours(brick));
      }
    }
//    glPopAttrib();
  }

  drawDirty_ = false;

  glDisable(GL_COLOR_MATERIAL);
  glDisable(GL_LIGHT0);
  glDisable(GL_LIGHTING);

  glDisable(GL_DEPTH_TEST);

  if(renderGraph_)
    drawLegoGraph(graph);

//  glDisable(GL_LINE_SMOOTH);
//  glDisable(GL_BLEND);
//  glDisable(GL_CULL_FACE);
  glPopAttrib();
}
Пример #9
0
void GLSphere::draw()
{
   if (m_red >= 0) glColor3i(m_red, m_blue, m_green);
   gluQuadricOrientation(s_quadric, GLU_OUTSIDE);
   gluSphere(s_quadric, m_radius, 2*m_segments, m_segments);
}
Пример #10
0
////////////////////////////////////////////////////////////
/// Entry point of application
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML OpenGL");

    // Create a clock for measuring time elapsed
    sf::Clock Clock;

    // prepare OpenGL surface for HSR
    glClearDepth(1.f);
    glClearColor(0.3f, 0.3f, 0.3f, 0.f);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    //// Setup a perspective projection & Camera position
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 300.0f); // fov, aspect, zNear, zFar


 
    bool rotate = true;
    float angle;

    // Start game loop
    while(App.isOpen()) {
        // Process events
        sf::Event Event;
        while(App.pollEvent(Event)) {
            // Close window : exit
            if(Event.type == sf::Event::Closed) App.close();

            // Escape key : exit
            if((Event.type == sf::Event::KeyPressed) &&
               (Event.key.code == sf::Keyboard::Escape))
                App.close();

            if((Event.type == sf::Event::KeyPressed) &&
               (Event.key.code == sf::Keyboard::A))
            {
                rotate = !rotate;
            }
        }

        // Prepare for drawing
        // Clear color and depth buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Apply some transformations for the cube
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);

        if(rotate) {
            angle = Clock.getElapsedTime().asSeconds();
        }
        glRotatef(angle * 50, 1.f, 0.f, 0.f);
        glRotatef(angle * 30, 0.f, 1.f, 0.f);
        glRotatef(angle * 90, 0.f, 0.f, 1.f);



        // Draw a cube
        glBegin(GL_QUADS); // draw some squares
        glColor3i(0, 1, 1);
        glVertex3f(-50.f, -50.f, -50.f);
        glVertex3f(-50.f, 50.f, -50.f);
        glVertex3f(50.f, 50.f, -50.f);
        glVertex3f(50.f, -50.f, -50.f);

        glColor3f(0, 0, 1);
        glVertex3f(-50.f, -50.f, 50.f);
        glVertex3f(-50.f, 50.f, 50.f);
        glVertex3f(50.f, 50.f, 50.f);
        glVertex3f(50.f, -50.f, 50.f);

        glColor3f(1, 0, 1);
        glVertex3f(-50.f, -50.f, -50.f);
        glVertex3f(-50.f, 50.f, -50.f);
        glVertex3f(-50.f, 50.f, 50.f);
        glVertex3f(-50.f, -50.f, 50.f);

        glColor3f(0, 1, 0);
        glVertex3f(50.f, -50.f, -50.f);
        glVertex3f(50.f, 50.f, -50.f);
        glVertex3f(50.f, 50.f, 50.f);
        glVertex3f(50.f, -50.f, 50.f);

        glColor3f(1, 1, 0);
        glVertex3f(-50.f, -50.f, 50.f);
        glVertex3f(-50.f, -50.f, -50.f);
        glVertex3f(50.f, -50.f, -50.f);
        glVertex3f(50.f, -50.f, 50.f);

        glColor3f(1, 0, 0);
        glVertex3f(-50.f, 50.f, 50.f);
        glVertex3f(-50.f, 50.f, -50.f);
        glVertex3f(50.f, 50.f, -50.f);
        glVertex3f(50.f, 50.f, 50.f);

        glEnd();

        // Finally, display rendered frame on screen
        App.display();
    }

    return EXIT_SUCCESS;
}
Пример #11
0
template< > inline void glColor3< int >			(int red,int green,int blue )								{	glColor3i(red,green,blue);	};
Пример #12
0
int G3DrawTexPolySimple (
    int			nVertices,
    g3sPoint		**pointList,
    tUVL			*uvlList,
    CBitmap	*bmP,
    CFixVector	*pvNormal,
    int			bBlend)
{
    int			i;
    int			bLight = 1,
                bDynLight = gameStates.render.bApplyDynLight && !gameStates.app.bEndLevelSequence;
    g3sPoint		*pl, **ppl;
#if USE_VERTNORMS
    CFloatVector		vNormal, vVertPos;
#endif

    if (gameStates.render.nShadowBlurPass == 1) {
        G3DrawWhitePoly (nVertices, pointList);
        return 0;
    }
    r_tpolyc++;
    if (FAST_SHADOWS) {
        if (!bBlend)
            glDisable (GL_BLEND);
#if 0
        else
            glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#endif
    }
    else {
        if (gameStates.render.nShadowPass == 1)
            bLight = !bDynLight;
        else if (gameStates.render.nShadowPass == 3) {
            glEnable (GL_BLEND);
            glBlendFunc (GL_ONE, GL_ONE);
        }
    }
    glDepthFunc (GL_LEQUAL);
    bmP = bmP->Override (-1);
    if (bmP == gameData.endLevel.satellite.bmP) {
        ogl.SelectTMU (GL_TEXTURE0);
        glEnable (GL_TEXTURE_2D);
    }
    else
        InitTMU0 (0);
    if (bmP->Bind (1))
        return 1;
    if (bmP == bmpDeadzone)
        bmP->Texture ()->Wrap (GL_CLAMP);
    else
        bmP->Texture ()->Wrap (GL_REPEAT);

    if (SHOW_DYN_LIGHT) {
#if USE_VERTNORMS
        if (pvNormal)
            vNormal.Assign (*pvNormal);
        else
            G3CalcNormal (pointList, &vNormal);
#else
        G3Normal (pointList, pvNormal);
#endif
    }
    if (gameStates.render.bFullBright) {
        glColor3d (1,1,1);
        bLight = 0;
    }
    else if (!gameStates.render.nRenderPass)
        bLight = 0;
    else if (!bLight)
        glColor3i (0,0,0);
    if (!bLight)
        bDynLight = 0;
    ogl.m_states.bDynObjLight = bDynLight;
    ogl.m_states.fAlpha = gameStates.render.grAlpha;
    glBegin (GL_TRIANGLE_FAN);
    if (bDynLight) {
        for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
            pl = *ppl;
            G3VERTPOS (vVertPos, pl);
            G3VertexColor (G3GetNormal (pl, &vNormal), vVertPos.XYZ(), pl->p3_index, NULL, NULL,
                           /*gameStates.render.nState ? X2F (uvlList [i].l) :*/ 1, 1, 0);
            glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
            glVertex3fv (reinterpret_cast<GLfloat*> (&vVertPos));
        }
    }
    else if (bLight) {
        for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
            SetTMapColor (uvlList + i, i, bmP, 1, NULL);
            glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
            OglVertex3f (*ppl);
        }
    }
    else {
        for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
            glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
            OglVertex3f (*ppl);
        }
    }
    glEnd ();
    glDisable (GL_TEXTURE_2D);
    tMapColor.index =
        lightColor.index = 0;
    if (!bBlend)
        glEnable (GL_BLEND);
    return 0;
}
Пример #13
0
int G3DrawTexPolyMulti (
    int			nVertices,
    g3sPoint**	pointList,
    tUVL*			uvlList,
    tUVL*			uvlLMap,
    CBitmap*		bmBot,
    CBitmap*		bmTop,
    tLightmap*	lightmap,
    CFixVector*	pvNormal,
    int			orient,
    int			bBlend,
    short			nSegment)
{
    int			i, nShader, nFrame;
    int			bShaderMerge = 0,
                bSuperTransp = 0;
    int			bLight = 1,
                bDynLight = gameStates.render.bApplyDynLight && (gameStates.app.bEndLevelSequence < EL_OUTSIDE),
                bDepthSort,
                bResetColor = 0,
                bOverlay = 0;
    tFaceColor	*pc;
    CBitmap		*bmP = NULL, *mask = NULL;
    g3sPoint		*pl, **ppl;
#if USE_VERTNORMS
    CFloatVector	vNormal, vVertPos;
#endif
#if G3_DRAW_ARRAYS
    int			bVertexArrays = gameData.render.vertP != NULL;
#else
    int			bVertexArrays = 0;
#endif

    if (gameStates.render.nShadowBlurPass == 1) {
        G3DrawWhitePoly (nVertices, pointList);
        return 0;
    }
    if (!bmBot)
        return 1;
    r_tpolyc++;
    if (FAST_SHADOWS) {
        if (!bBlend)
            glDisable (GL_BLEND);
#if 0
        else
            glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#endif
    }
    else {
        if (gameStates.render.nShadowPass == 1)
            bLight = !bDynLight;
        else if (gameStates.render.nShadowPass == 3) {
            glEnable (GL_BLEND);
            glBlendFunc (GL_ONE, GL_ONE);
        }
    }
    glDepthFunc (GL_LEQUAL);
    bmBot = bmBot->Override (-1);
    bDepthSort = (!bmTop && (gameOpts->render.bDepthSort > 0) &&
                  ((gameStates.render.grAlpha < 1.0f) ||
                   (bmBot->Flags () & (BM_FLAG_TRANSPARENT | BM_FLAG_SEE_THRU | BM_FLAG_TGA)) == (BM_FLAG_TRANSPARENT | BM_FLAG_TGA)));
    if (bmTop && (bmTop = bmTop->Override (-1)) && bmTop->Frames ()) {
        nFrame = (int) (bmTop->CurFrame () - bmTop->Frames ());
        bmP = bmTop;
        bmTop = bmTop->CurFrame ();
    }
    else
        nFrame = -1;
    if (bmTop) {
        if (nFrame < 0)
            bSuperTransp = (bmTop->Flags () & BM_FLAG_SUPER_TRANSPARENT) != 0;
        else
            bSuperTransp = (bmP->Flags () & BM_FLAG_SUPER_TRANSPARENT) != 0;
        bShaderMerge = bSuperTransp && ogl.m_states.bGlTexMerge;
        bOverlay = !bShaderMerge;
    }
    else
        bOverlay = -1;
#if G3_DRAW_ARRAYS
retry:
#endif
    if (bShaderMerge) {
        mask = gameStates.render.textures.bHaveMaskShader ? bmTop->Mask () : NULL;
        nShader = bSuperTransp ? mask ? 2 : 1 : 0;
        glUseProgramObject (activeShaderProg = tmShaderProgs [nShader]);
        INIT_TMU (InitTMU0, GL_TEXTURE0, bmBot, lightmapManager.Buffer (), bVertexArrays, 0);
        glUniform1i (glGetUniformLocation (activeShaderProg, "btmTex"), 0);
        INIT_TMU (InitTMU1, GL_TEXTURE1, bmTop, lightmapManager.Buffer (), bVertexArrays, 0);
        glUniform1i (glGetUniformLocation (activeShaderProg, "topTex"), 1);
        if (mask) {
#if DBG
            InitTMU2 (bVertexArrays);
            G3_BIND (GL_TEXTURE2, mask, lightmapManager.Buffer (), bVertexArrays);
#else
            INIT_TMU (InitTMU2, GL_TEXTURE2, mask, lightmapManager.Buffer (), bVertexArrays, 0);
#endif
            glUniform1i (glGetUniformLocation (activeShaderProg, "maskTex"), 2);
        }
        glUniform1f (glGetUniformLocation (activeShaderProg, "grAlpha"), gameStates.render.grAlpha);
    }
    else if (!bDepthSort) {
        if (bmBot == gameData.endLevel.satellite.bmP) {
            ogl.SelectTMU (GL_TEXTURE0);
            glEnable (GL_TEXTURE_2D);
        }
        else
            InitTMU0 (bVertexArrays);
        if (bmBot->Bind (1))
            return 1;
        bmBot = bmBot->CurFrame (-1);
        bmBot->Texture ()->Wrap ((bmBot == bmpDeadzone) ? GL_CLAMP : GL_REPEAT);
    }

    if (!bDepthSort) {
        if (SHOW_DYN_LIGHT) {
#if USE_VERTNORMS
            if (pvNormal) {
                vNormal.Assign (*pvNormal);
                transformation.Rotate(vNormal, vNormal, 0);
            }
            else
                G3CalcNormal (pointList, &vNormal);
#else
            G3Normal (pointList, pvNormal);
#endif
        }
        if (gameStates.render.bFullBright) {
            glColor3f (1,1,1);
            bLight = 0;
        }
        else if (!gameStates.render.nRenderPass)
            bLight = 0;
        else if (!bLight)
            glColor3i (0,0,0);
        if (!bLight)
            bDynLight = 0;
        ogl.m_states.bDynObjLight = bDynLight;
    }

    ogl.m_states.fAlpha = gameStates.render.grAlpha;
    if (bVertexArrays || bDepthSort) {
        CFloatVector	vertices [8];
        tFaceColor		vertColors [8];
        tTexCoord2f		texCoord [2][8];
        int				vertIndex [8];
        //int				colorIndex [8];

        for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
            pl = *ppl;
            vertIndex [i] = pl->p3_index;
            //colorIndex [i] = i;
            if (pl->p3_index < 0)
                vertices[i].Assign (pl->p3_vec);
            else
                vertices [i] = gameData.render.vertP [pl->p3_index];
            texCoord [0][i].v.u = X2F (uvlList [i].u);
            texCoord [0][i].v.v = X2F (uvlList [i].v);
            SetTexCoord (uvlList + i, orient, 1, texCoord [1] + i, 0);
            G3VERTPOS (vVertPos, pl);
            if (bDynLight)
                G3VertexColor (G3GetNormal (pl, &vNormal), vVertPos.XYZ(), vertIndex [i], vertColors + i, NULL,
                               gameStates.render.nState ? X2F (uvlList [i].l) : 1, 0, 0);
            else if (bLight)
                SetTMapColor (uvlList + i, i, bmBot, !bOverlay, vertColors + i);
        }
#if 1
        if (gameOpts->render.bDepthSort > 0) {
            bmBot->SetupTexture (1, 0);
            transparencyRenderer.AddPoly (NULL, NULL, bmBot, vertices, nVertices, texCoord [0], NULL, vertColors, nVertices, 1, GL_TRIANGLE_FAN, GL_REPEAT, 0, nSegment);
            return 0;
        }
#endif
    }
#if G3_DRAW_ARRAYS
    if (bVertexArrays) {
        if (!ogl.EnableClientStates (1, 1, 0, GL_TEXTURE0)) {
            bVertexArrays = 0;
            goto retry;
        }
        OglVertexPointer (3, GL_FLOAT, sizeof (CFloatVector), vertices);
//	OglIndexPointer (GL_INT, 0, colorIndex);
        OglTexCoordPointer (2, GL_FLOAT, sizeof (tTexCoord3f), texCoord [0]);
        if (bLight)
            OglColorPointer (4, GL_FLOAT, sizeof (tFaceColor), vertColors);
        if (bmTop && !bOverlay) {
            if (!ogl.EnableClientStates (1, 1, 0, GL_TEXTURE1)) {
                ogl.DisableClientStates (1, 1, 0, GL_TEXTURE0);
                bVertexArrays = 0;
                goto retry;
            }
            OglVertexPointer (3, GL_FLOAT, sizeof (CFloatVector), vertices);
            if (bLight)
                OglColorPointer (4, GL_FLOAT, sizeof (tFaceColor), vertColors);
//		OglIndexPointer (GL_INT, 0, colorIndex);
            OglTexCoordPointer (2, GL_FLOAT, sizeof (tTexCoord3f), texCoord [1]);
        }
        OglDrawArrays (GL_TRIANGLE_FAN, 0, nVertices);
        ogl.DisableClientStates (1, 1, 0, GL_TEXTURE0);
        if (bmTop && !bOverlay)
            ogl.DisableClientStates (GL_TEXTURE1);
    }
    else
#endif
    {
        glBegin (GL_TRIANGLE_FAN);
        if (bDynLight) {
            if (bOverlay) {
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    pl = *ppl;
                    G3VERTPOS (vVertPos, pl);
                    G3VertexColor (G3GetNormal (pl, &vNormal), vVertPos.XYZ(), pl->p3_index, NULL, NULL,
                                   gameStates.render.nState ? X2F (uvlList [i].l) : 1, 1, 0);
                    glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
                    glVertex3fv (reinterpret_cast<GLfloat*> (&vVertPos));
                }
            }
            else {
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    pl = *ppl;
                    G3VERTPOS (vVertPos, pl);
                    G3VertexColor (G3GetNormal (pl, &vNormal), vVertPos.XYZ(), pl->p3_index, NULL, NULL,
                                   /*gameStates.render.nState ? X2F (uvlList [i].l) :*/ 1, 1, 0);
                    glMultiTexCoord2f (GL_TEXTURE0, X2F (uvlList [i].u), X2F (uvlList [i].v));
                    SetTexCoord (uvlList + i, orient, 1, NULL, mask != NULL);
                    glVertex3fv (reinterpret_cast<GLfloat*> (&vVertPos));
                }
            }
        }
        else if (bLight) {
            if (bOverlay) {
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    if (gameStates.render.nState || gameStates.app.bEndLevelSequence)
                        SetTMapColor (uvlList + i, i, bmBot, 1, NULL);
                    else {
                        pc = gameData.render.color.vertices + (*ppl)->p3_index;
                        glColor3fv (reinterpret_cast<GLfloat*> (&pc->color));
                    }
                    glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
                    OglVertex3f (*ppl);
                }
            }
            else {
                bResetColor = (bOverlay != 1);
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    if (gameStates.render.nState || !RENDERPATH)
                        SetTMapColor (uvlList + i, i, bmBot, 1, NULL);
                    else {
                        pc = gameData.render.color.vertices + (*ppl)->p3_index;
                        glColor3fv (reinterpret_cast<GLfloat*> (&pc->color));
                    }
                    glMultiTexCoord2f (GL_TEXTURE0, X2F (uvlList [i].u), X2F (uvlList [i].v));
                    SetTexCoord (uvlList + i, orient, 1, NULL, mask != NULL);
                    OglVertex3f (*ppl);
                }
            }
        }
        else {
            if (bOverlay) {
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    glTexCoord2f (X2F (uvlList [i].u), X2F (uvlList [i].v));
                    OglVertex3f (*ppl);
                }
            }
            else {
                for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                    glMultiTexCoord2f (GL_TEXTURE0, X2F (uvlList [i].u), X2F (uvlList [i].v));
                    SetTexCoord (uvlList + i, orient, 1, NULL, mask != NULL);
                    OglVertex3f (*ppl);
                }
            }
        }
        glEnd ();
    }
    if (bOverlay > 0) {
        r_tpolyc++;
        ogl.SelectTMU (GL_TEXTURE0);
        glEnable (GL_TEXTURE_2D);
        if (bmTop->Bind (1))
            return 1;
        bmTop = bmTop->CurFrame (-1);
        bmTop->Texture ()->Wrap (GL_REPEAT);
        glBegin (GL_TRIANGLE_FAN);
        if (bDynLight) {
            for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                vVertPos.Assign ((*ppl)->p3_vec);
                G3VertexColor (G3GetNormal (*ppl, &vNormal), vVertPos.XYZ(), (*ppl)->p3_index, NULL, NULL, 1, 1, 0);
                SetTexCoord (uvlList + i, orient, 0, NULL, mask != NULL);
                OglVertex3f (*ppl);
            }
        }
        else if (bLight) {
            for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                SetTMapColor (uvlList + i, i, bmTop, 1, NULL);
                SetTexCoord (uvlList + i, orient, 0, NULL, mask != NULL);
                OglVertex3f (*ppl);
            }
        }
        else {
            for (i = 0, ppl = pointList; i < nVertices; i++, ppl++) {
                SetTexCoord (uvlList + i, orient, 0, NULL, mask != NULL);
                OglVertex3f (*ppl);
            }
        }
        glEnd ();
        glDepthFunc (GL_LESS);
#if OGL_CLEANUP
        OGL_BINDTEX (0);
        glDisable (GL_TEXTURE_2D);
#endif
    }
    else if (bShaderMerge) {
#if OGL_CLEANUP
        ogl.SelectTMU (GL_TEXTURE1, bVertexArrays != 0);
        OGL_BINDTEX (0);
        glDisable (GL_TEXTURE_2D); // Disable the 2nd texture
#endif
        glUseProgramObject (activeShaderProg = 0);
    }
    ogl.SelectTMU (GL_TEXTURE0, bVertexArrays != 0);
    OGL_BINDTEX (0);
    glDisable (GL_TEXTURE_2D);
    tMapColor.index =
        lightColor.index = 0;
    if (!bBlend)
        glEnable (GL_BLEND);
    return 0;
}
Пример #14
0
inline void glColor( const GLint & red, const GLint & green, const GLint & blue )		{ glColor3i( red, green, blue ); }
Пример #15
0
/****************Function to render keys using OpenGL selection or render mode****************/
static void Render(GLenum mode) {
	GLint i;
	float colorVal = 0.8;


	for (i = 1; i <= noOfVertices; i++) {
		if (mode == GL_SELECT) {
			glLoadName(i);
		}

		glBegin(GL_QUADS);

		glColor3ubv(Vertex[i].color);
		glTexCoord2i(0,1);
		glVertex2fv(Vertex[i].v1);

		glColor3ubv(Vertex[i].color);
		glTexCoord2i(1,1);
		glVertex2fv(Vertex[i].v2);

		glColor3ubv(Vertex[i].color);
		glTexCoord2i(1,0);
		glVertex2fv(Vertex[i].v3);

		glColor3ubv(Vertex[i].color);
		glTexCoord2i(0,0);
		glVertex2fv(Vertex[i].v4);

		glEnd();

		glColor3i(0, 0, 1);
		renderChar(((Vertex[i].v1[0] + Vertex[i].v2[0]) / 2) - strlen(Vertex[i].chN) * 1.5, Vertex[i].v1[1] + keyHeight * 0.2, Vertex[i].chN);
		renderChar(((Vertex[i].v1[0] + Vertex[i].v2[0]) / 2) - strlen(Vertex[i].chS) * 1.5, Vertex[i].v1[1] + keyHeight * 0.6, Vertex[i].chS);
	}

	if(zoomedKey!=-1)
	{
		glBegin(GL_QUADS);

					glColor3fv(Vertex[zoomedKey].color);
					glTexCoord2i(0,1);
					glVertex2fv(Vertex[zoomedKey].v1);

					glColor3fv(Vertex[zoomedKey].color);
					glTexCoord2i(1,1);
					glVertex2fv(Vertex[zoomedKey].v2);

					glColor3fv(Vertex[zoomedKey].color);
					glTexCoord2i(1,0);
					glVertex2fv(Vertex[zoomedKey].v3);

					glColor3fv(Vertex[zoomedKey].color);
					glTexCoord2i(0,0);
					glVertex2fv(Vertex[zoomedKey].v4);

					glEnd();

					glColor3i(0, 0, 1);
					renderChar(((Vertex[zoomedKey].v1[0] + Vertex[zoomedKey].v2[0]) / 2) - strlen(Vertex[zoomedKey].chN) * 1.5, Vertex[zoomedKey].v1[1] + keyHeight * 0.5, Vertex[zoomedKey].chN);
					renderChar(((Vertex[zoomedKey].v1[0] + Vertex[zoomedKey].v2[0]) / 2) - strlen(Vertex[zoomedKey].chS) * 1.5, Vertex[zoomedKey].v1[1] + keyHeight , Vertex[zoomedKey].chS);

					zoomedKey = -1;
	}


	glBegin(GL_POLYGON);

				glColor3f(colorVal, colorVal, colorVal);
				glVertex2fv(Vertex[0].v1);

				glColor3f(colorVal, colorVal, colorVal);
				glVertex2fv(Vertex[0].v2);

				glColor3fv(Vertex[0].color);
				glVertex2fv(Vertex[0].v3);

				glColor3fv(Vertex[0].color);
				glVertex2fv(Vertex[0].v4);

		glEnd();


	//Render text on output bar
	glColor3i(1, 0, 0);
	renderChar(xOrigin + 5, Vertex[0].v1[1] + keyHeight+20 , text);

//	Vertex[0].color[0] = 0.0;
//	Vertex[0].color[1] = 0.0;
//	Vertex[0].color[2] = 0.0;

}
Пример #16
0
M(void, glColor3i, jint red, jint green, jint blue) {
	glColor3i(red, green, blue);
}