Exemple #1
0
static void
Init(void)
{
  static float ambient[] =
  {0.1, 0.1, 0.1, 1.0};
  static float diffuse[] =
  {1.0, 1.0, 1.0, 1.0};
  static float position[] =
  {0.0, 0.0, -150.0, 0.0};
  static float front_mat_diffuse[] =
  {1.0, 0.2, 1.0, 1.0};
  static float back_mat_diffuse[] =
  {1.0, 1.0, 0.2, 1.0};
  static float lmodel_ambient[] =
  {1.0, 1.0, 1.0, 1.0};
  static float lmodel_twoside[] =
  {GL_TRUE};
  static float decal[] =
  {GL_DECAL};
  static float repeat[] =
  {GL_REPEAT};
  static float nr[] =
  {GL_NEAREST};

  glFrontFace(GL_CCW);

  glEnable(GL_DEPTH_TEST);

  glMap1d(GL_MAP1_VERTEX_4, 0.0, 1.0, VDIM, VORDER, point1);
  glMap1d(GL_MAP1_COLOR_4, 0.0, 1.0, CDIM, CORDER, cpoint1);

  glMap2d(GL_MAP2_VERTEX_4, 0.0, 1.0, VMINOR_ORDER * VDIM, VMAJOR_ORDER, 0.0,
    1.0, VDIM, VMINOR_ORDER, point2);
  glMap2d(GL_MAP2_COLOR_4, 0.0, 1.0, CMINOR_ORDER * CDIM, CMAJOR_ORDER, 0.0,
    1.0, CDIM, CMINOR_ORDER, cpoint2);
  glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, TMINOR_ORDER * TDIM,
    TMAJOR_ORDER, 0.0, 1.0, TDIM, TMINOR_ORDER, tpoint2);

  glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, position);

  glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
  glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);

  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);

  glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal);
  glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
  glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
  glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nr);
  glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nr);
  glTexImage2D(GL_TEXTURE_2D, 0, 4, 2, 4, 0, GL_RGBA, GL_FLOAT,
    (GLvoid *) textureImage);
}
Exemple #2
0
static void hugsprim_glMap2d_3(HugsStackPtr hugs_root)
{
    HsWord32 arg1;
    HsDouble arg2;
    HsDouble arg3;
    HsInt32 arg4;
    HsInt32 arg5;
    HsDouble arg6;
    HsDouble arg7;
    HsInt32 arg8;
    HsInt32 arg9;
    HsPtr arg10;
    arg1 = hugs->getWord32();
    arg2 = hugs->getDouble();
    arg3 = hugs->getDouble();
    arg4 = hugs->getInt32();
    arg5 = hugs->getInt32();
    arg6 = hugs->getDouble();
    arg7 = hugs->getDouble();
    arg8 = hugs->getInt32();
    arg9 = hugs->getInt32();
    arg10 = hugs->getPtr();
    glMap2d(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
    
    hugs->returnIO(hugs_root,0);
}
Exemple #3
0
void
__glXDispSwap_Map2d(GLbyte * pc)
{
    GLdouble u1, u2, v1, v2, *points;
    GLint uorder, vorder, ustride, vstride, k, compsize;
    GLenum target;

    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;

    __GLX_SWAP_DOUBLE(pc + 0);
    __GLX_SWAP_DOUBLE(pc + 8);
    __GLX_SWAP_DOUBLE(pc + 16);
    __GLX_SWAP_DOUBLE(pc + 24);
    __GLX_SWAP_INT(pc + 32);
    __GLX_SWAP_INT(pc + 36);
    __GLX_SWAP_INT(pc + 40);

    target = *(GLenum *) (pc + 32);
    uorder = *(GLint *) (pc + 36);
    vorder = *(GLint *) (pc + 40);
    k = __glMap2d_size(target);
    if (vorder <= 0 || uorder <= 0 || k < 0) {
        /* Erroneous command. */
        compsize = 0;
    }
    else {
        compsize = uorder * vorder * k;
    }
    __GLX_GET_DOUBLE(u1, pc);
    __GLX_GET_DOUBLE(u2, pc + 8);
    __GLX_GET_DOUBLE(v1, pc + 16);
    __GLX_GET_DOUBLE(v2, pc + 24);
    __GLX_SWAP_DOUBLE_ARRAY(pc + 44, compsize);
    pc += 44;
    ustride = vorder * k;
    vstride = k;

#ifdef __GLX_ALIGN64
    if (((unsigned long) pc) & 7) {
        /*
         ** Copy the doubles up 4 bytes, trashing the command but aligning
         ** the data in the process
         */
        __GLX_MEM_COPY(pc - 4, pc, compsize * 8);
        points = (GLdouble *) (pc - 4);
    }
    else {
        points = (GLdouble *) pc;
    }
#else
    points = (GLdouble *) pc;
#endif
    glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
}
Exemple #4
0
static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
{
#if defined(_WIN32_WCE)
		int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;
#else
    double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
    long i, j, k, l;
#endif

    glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
    glEnable( GL_AUTO_NORMAL );
    glEnable( GL_NORMALIZE );
    glEnable( GL_MAP2_VERTEX_3 );
    glEnable( GL_MAP2_TEXTURE_COORD_2 );

    glPushMatrix();
    glRotated( 270.0, 1.0, 0.0, 0.0 );
    glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );
    glTranslated( 0.0, 0.0, -1.5 );

#if defined(_WIN32_WCE)
    glRotated( 90.0, 1.0, 0.0, 0.0 );
    glBegin( GL_TRIANGLE_STRIP );

    for( i = 0; i < numV-1; i++ )
    {
        int vidx = strip_vertices[i],
            nidx = strip_normals[i];

        if( vidx != -1 )
        {
            glNormal3fv( normals[nidx]  );
            glVertex3fv( vertices[vidx] );
        }
        else
        {
            glEnd();
            glBegin( GL_TRIANGLE_STRIP );
        }
    }

    glEnd();
#else
    for (i = 0; i < 10; i++) {
      for (j = 0; j < 4; j++) {
        for (k = 0; k < 4; k++) {
          for (l = 0; l < 3; l++) {
            p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
            q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
            if (l == 1)
              q[j][k][l] *= -1.0;
            if (i < 6) {
              r[j][k][l] =
                cpdata[patchdata[i][j * 4 + (3 - k)]][l];
              if (l == 0)
                r[j][k][l] *= -1.0;
              s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
              if (l == 0)
                s[j][k][l] *= -1.0;
              if (l == 1)
                s[j][k][l] *= -1.0;
            }
          }
        }
      }

      glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,
        &tex[0][0][0]);
      glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
        &p[0][0][0]);
      glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);
      glEvalMesh2(type, 0, grid, 0, grid);
      glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
        &q[0][0][0]);
      glEvalMesh2(type, 0, grid, 0, grid);
      if (i < 6) {
        glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
          &r[0][0][0]);
        glEvalMesh2(type, 0, grid, 0, grid);
        glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
          &s[0][0][0]);
        glEvalMesh2(type, 0, grid, 0, grid);
      }
    }
#endif  /* defined(_WIN32_WCE) */

    glPopMatrix();
    glPopAttrib();
}
Exemple #5
0
M(void, glMap2d, jint target, jdouble u1, jdouble u2, jint ustride, jint uorder, jdouble v1, jdouble v2, jint vstride, jint vorder, jobject points) {
	glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, BUFF(GLdouble, points));
}
Exemple #6
0
    void Plane::draw() {
    
        
        // permissao de atribuicao directa de cores
        // para objectos que nao tem material atribuido, como
        // e' o caso dos eixos e da esfera que simboliza a fonte de luz...
        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
        //glEnable(GL_COLOR_MATERIAL);
        
        // INICIALIZACOES RELACIONADAS COM OS "EVALUATORS"
        
        // declaram-se quatro interpoladores, de coordenadas, de
        //     normais, de cores e de texturas:
        // o parâmetro de controlo dos interpoladors varia de 0 a 1,
        //     tanto em U como em V
        // os strides (ordem de visita no array de dados final) são:
        //     3 e 6 para o interpol. de coord. (respectivamente U e V)
        //     3 e 6 para o interpol. de normais (respectivamente U e V)
        //     4 e 8 para o interpolador de cores (respectivamente U e V)
        //     2 e 4 para o interpolador de texturas (respectivamente U e V)
        // a interpolação é linear (de grau 1) pelo que se coloca o
        //     valor "2" (grau + 1) nos quatro casos
        
        glColor3f(1.0,1.0,1.0);
        
                glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2, 0.0, 1.0, 3*2, 2, &planeControlPoints[0][0]);

        
        glMap2f(GL_MAP2_NORMAL,   0.0, 1.0, 3, 2,  0.0, 1.0, 3*2, 2,  &planeNormals[0][0]);
        glMap2f(GL_MAP2_COLOR_4,  0.0, 1.0, 4, 2,  0.0, 1.0, 4*2, 2,  &planeColors[0][0]);
        glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2, 0.0, 1.0, 2*2, 2,  &textPoints[0][0]);
        
        
        // When we actually go to evaluate and render the evaluator map as a 2D mesh, we need to indicate the number of partitions of U and V (number of grid rows and columns) and over what region of the parametric U and V domain we will iterate across. So we tell OpenGL to iterate across the full 0.0 to 1.0 range setup above with 5 rows and 6 columns. This is done with glMapGrid2f:
        glMapGrid2d(parts, 0.0, 1.0,parts, 0.0, 1.0);
        
        // os interpoladores activam-se:
        glEnable(GL_MAP2_VERTEX_3);
        glEnable(GL_MAP2_NORMAL);
        glEnable(GL_MAP2_COLOR_4);
        glEnable(GL_MAP2_TEXTURE_COORD_2);
        glEnable(GL_TEXTURE_2D);
        
        //glBindTexture(GL_TEXTURE_2D, 2);
        
        //After this setup is performed, a single OpenGL command evaluates and renders the specified grid as an evaluator mesh:
        glEvalMesh2(GL_FILL, 0.0, parts, 0.0, parts);
        
        // so' para referencia visual... onde estao os quatro pontos
        // de controlo:
        glDisable(GL_TEXTURE_2D);
        glColor3f(1.0, 1.0, 0.0);
        for (int i = 0; i < 4; i++)
        {
            glRasterPos3f(planeControlPoints[i][0],planeControlPoints[i][1],planeControlPoints[i][2]);
            glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '0'+i);
        }
        
        glDisable(GL_MAP2_VERTEX_3);
        glDisable(GL_MAP2_NORMAL);
        glDisable(GL_MAP2_TEXTURE_COORD_2);
        glDisable(GL_TEXTURE_2D);
        
        //glDisable(GL_COLOR_MATERIAL);
    }