Example #1
0
static void
Redisplay(void)
{
   CheckError(__LINE__);
   glClear(GL_COLOR_BUFFER_BIT);

   glPushMatrix();

   CheckError(__LINE__);
   glUseProgram(program);
   CheckError(__LINE__);

   glBegin(GL_POLYGON);
#if USE_RECT
   /* scale coords by two to test projection */
   glTexCoord4f(        0,         0,   0, 2.0);  glVertex2f(-1, -1);
   glTexCoord4f(2*TEXSIZE,         0, 2*1, 2.0);  glVertex2f( 1, -1);
   glTexCoord4f(2*TEXSIZE, 2*TEXSIZE, 2*1, 2.0);  glVertex2f( 1,  1);
   glTexCoord4f(        0, 2*TEXSIZE,   0, 2.0);  glVertex2f(-1,  1);
#else
   glTexCoord3f(0, 0, 0);  glVertex2f(-1, -1);
   glTexCoord3f(1, 0, 1);  glVertex2f( 1, -1);
   glTexCoord3f(1, 1, 1);  glVertex2f( 1,  1);
   glTexCoord3f(0, 1, 0);  glVertex2f(-1,  1);
#endif
   glEnd();

   glPopMatrix();

   glUseProgram(0);
   glWindowPos2iARB(80, 20);
   PrintString("white   black   white   black");

   glutSwapBuffers();
}
Example #2
0
void ButtonRender( struct Button * b )
{
	if( b->text != b->oldtext || !b->geotext )
	{
		if( b->oldtext)
			free( b->oldtext );
		if( b->geotext )
			DestroyGPUGeometry( b->geotext );

		b->geotext = EmitGeometryFromFontString( OldSansBlack, b->text, TEXTFLIPY );
		b->oldtext = b->text;
	}


//	b->w = sin(TotalTime)*100+100;
//	b->h = cos(TotalTime)*100+100;

	ApplyShader( ButtonShader, OverallUniforms );
	glColor4fv( b->color );
	glBegin(GL_QUADS);
	glTexCoord4f(0.0, 0.0, b->w, b->h);
	glVertex3f(b->x, b->y, 0.0);
	glTexCoord4f(b->w, 0.0, b->w, b->h);
	glVertex3f(b->x+b->w, b->y, 0.0);
	glTexCoord4f(b->w, b->h, b->w, b->h );
	glVertex3f(b->x+b->w, b->y+b->h, 0.0);
	glTexCoord4f(0.0, b->h, b->w, b->h );
	glVertex3f(b->x, b->y+b->h, 0.0);
	glEnd();
	CancelShader( ButtonShader );

	if( b->color[0] + b->color[1] + b->color[2] > 1.5 )
		glColor4f( 0, 0, 0, 1 );
	else
		glColor4f( 1,1,1,1 );

	if( b->geotext )
	{
		float mx = b->geotext->maxs[0]-b->geotext->mins[0];
		float my = b->geotext->maxs[1]-b->geotext->mins[1];

		float scaleby = b->h / OldSansBlack->fontsize;

		glTranslatef( b->x+(b->w-mx*scaleby)/2, b->y+(b->h-(my+32)*scaleby)/2, 0 );
		glScalef( scaleby, scaleby, 0.0 );

//		ApplyShader( TextShader, OverallUniforms );
		RenderGPUGeometry( b->geotext );
//		CancelShader( TextShader );
	}

	glColor4f( 1,1,1,1 );

}
Example #3
0
// Render a non-world polygon (such as on an actor).  
geBoolean DRIVERCC Render_MiscTexturePoly(DRV_TLVertex *Pnts, int32 NumPoints, 
										  geRDriver_THandle *THandle, uint32 Flags)
{
	GLint i;
	GLfloat zRecip;
	DRV_TLVertex *pPnt = Pnts;
	GLubyte alpha;

	if(!RenderingIsOK)
		return GE_TRUE;

	if(Flags & DRV_RENDER_ALPHA)
	{
		alpha = (GLubyte)Pnts->a;
	}
	else
	{
		alpha = 255;
	}

	if(boundTexture != THandle->TextureID)
	{
		glBindTexture(GL_TEXTURE_2D, THandle->TextureID);
		boundTexture = THandle->TextureID;
	}

	if(THandle->Flags & THANDLE_UPDATE)
	{
		THandle_Update(THandle);
	}

	if(Flags & DRV_RENDER_NO_ZMASK)
	{
		glDisable(GL_DEPTH_TEST);
	}

	glBegin(GL_TRIANGLE_FAN);

	for(i = 0; i < NumPoints; i++)
	{
		zRecip = 1.0f / pPnt->z;                    

		glColor4ub((GLubyte)pPnt->r, (GLubyte)pPnt->g, (GLubyte)pPnt->b, alpha);

		glTexCoord4f(pPnt->u * zRecip, pPnt->v * zRecip, 0.0f, zRecip);

		glVertex3f(pPnt->x, pPnt->y, -1.0f + zRecip);

		pPnt++;
	}

	glEnd();  

	if(Flags & DRV_RENDER_NO_ZMASK)
	{
		glEnable(GL_DEPTH_TEST);
	}

	return GE_TRUE;
}
Example #4
0
void GemShape :: SetVertex(GemState* state,float x, float y, float z,
                           float s, float t, float r, float q,
                           int curCoord)
{
  int numCoords = 0;
  int numUnits = 0;

  state->get(GemState::_GL_TEX_NUMCOORDS, numCoords);
  state->get(GemState::_GL_TEX_UNITS, numUnits);

  if (numCoords) {
    s*=state->texCoordX(curCoord);
    t*=state->texCoordY(curCoord);
  }

  if (numUnits) {
    for(int i=0; i<numUnits; i++) {
      glMultiTexCoord4fARB(GL_TEXTURE0+i, s, t, r, q);
    }
  } else { // no multitexturing!
    glTexCoord4f(s, t, r, q);
  }

  glVertex3f( x, y, z );
}
void renderStreamlineStrip(vertex v)
{
	/// render a single part of a streamline strip
	float halofactor = (1.0f + 2.0f * HALOSIZE);

	// simple rendering	

	glColor3fv(&v.col[0]);
	glNormal3fv(&v.norm[0]);

	glTexCoord4f(-v.radius * halofactor, v.radius, v.rot, v.zdiff);
	glVertex3fv(&v.pos[0]);

	glTexCoord4f(v.radius * halofactor, v.radius, v.rot, v.zdiff);
	glVertex3fv(&v.pos[0]);
}
Example #6
0
static void WINE_GLAPI wine_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
    if(target != GL_TEXTURE0) {
        ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
        return;
    }
    glTexCoord4f(s, t, r, q);
}
/// render a single streamline part
void renderStreamline(vertex a, vertex b)
{
	// halofactor is the value by which we have to scale the width of the streamline to accomodate for the added halo
	float halofactor = (1.0f + 2.0f * HALOSIZE);

	// simple rendering	

	// set color of lower side
	glColor3fv(&a.col[0]);

	// transfer tangent of lower side
	glNormal3fv(&a.norm[0]);

	// set rendering values for bottom left vertex :
	//   float 1 : horizontal extrusion amount, modified by halofactor and user determined scale factor
	//   float 2 : radius of the streamline, needed for depth correction and similar things
	//   float 3 : vertical texture coordinate, used for rotation effects and the like
	//   float 4 : vertical extrusion amount
	glTexCoord4f(-a.radius * halofactor, a.radius, a.rot, 0.0f);

	// render vertex
	glVertex3fv(&a.pos[0]);

	// set rendering values for bottom right vertex
	glTexCoord4f(a.radius * halofactor, a.radius, a.rot, 0.0f);

	// render vertex
	glVertex3fv(&a.pos[0]);

	// set color of upper side
	glColor3fv(&b.col[0]);

	// set tangent of upper side
	glNormal3fv(&b.norm[0]);

	// set rendering values for top right vertex
	glTexCoord4f(b.radius * halofactor, b.radius, b.rot, 0.0f);

	// render vertex
	glVertex3fv(&b.pos[0]);

	// set rendering values for top left vertex
	glTexCoord4f(-b.radius * halofactor, b.radius, b.rot, 0.0f);

	// render vertex
	glVertex3fv(&b.pos[0]);
}
Example #8
0
GLvoid
glTexCoord3f(GLfloat s, GLfloat t, GLfloat r)
{
    if (vt_coordsize[0] > 3){
        glTexCoord4f(s, t, r, 0);
    } else {
        vt_coordsize[0] = 3;
        vt_current->coord[0].s = s;
        vt_current->coord[0].t = t;
        vt_current->coord[0].r = r;
    }
}
Example #9
0
static void Display( void )
{
   glClear( GL_COLOR_BUFFER_BIT );

   glPushMatrix();
   glRotatef(Xrot, 1.0, 0.0, 0.0);
   glRotatef(Yrot, 0.0, 1.0, 0.0);
   glRotatef(Zrot, 0.0, 0.0, 1.0);

   glBegin(GL_POLYGON);
#define Q 2
   glColor4f(1.0, 1.0, 1.0, 1);   glTexCoord4f(0, 0, 0, Q);   glVertex2f(-1, -1);
   glColor4f(0.2, 0.2, 1.0, 1);   glTexCoord4f(1, 0, 0, Q);   glVertex2f( 1, -1);
   glColor4f(0.2, 1.0, 0.2, 1);   glTexCoord4f(1, 1, 0, Q);   glVertex2f( 1,  1);
   glColor4f(1.0, 0.2, 0.2, 1);   glTexCoord4f(0, 1, 0, Q);   glVertex2f(-1,  1);
   glEnd();

   glPopMatrix();

   glutSwapBuffers();
}
Example #10
0
void PsychGLTexCoord4f(PsychWindowRecordType *windowRecord, float s, float t, float u, float v)
{
    // Classic OpenGL? Use glEnd() and be done:
    if (PsychIsGLClassic(windowRecord)) {
        glTexCoord4f(s, t, u, v);
        return;
    }

    currentTexCoord[0] = s;
    currentTexCoord[1] = t;
    currentTexCoord[2] = u;
    currentTexCoord[3] = v;
}
Example #11
0
/////////////////////////////////////////////////////////
// renderShape
//
/////////////////////////////////////////////////////////
void trapezoid :: renderShape(GemState *state)
{
  float top=m_size*m_top;
  float tx = m_scale_texcoord * m_top;

  int drawType = m_drawType;
  if(drawType==GL_DEFAULT_GEM)drawType=GL_QUADS;

  if (drawType == GL_LINE_LOOP)
    glLineWidth(m_linewidth);
  if (m_top<0)
    top*=-1;

  glNormal3f(0.0f, 0.0f, 1.0f);

  glBegin(drawType);

  SetVertex(state,-m_size, -m_size, 0.0f,  0., 0.,         0);
  SetVertex(state, m_size, -m_size, 0.0f,  1., 0.,         1);
  SetVertex(state,    top,  m_size, 0.0f,  tx, tx, 0., tx, 2);
  SetVertex(state,   -top,  m_size, 0.0f,  0., tx, 0., tx, 3);

#if 0
  glTexCoord2f( 0,  0);
  glVertex2f  (-1, -1);

  glTexCoord2f( 256,  0);
  glVertex2f  ( 1, -1);

  glTexCoord4f( 256*tx,  256*tx, 0, tx);
  glVertex2f  ( m_size,  1);

  glTexCoord4f(  0,  256*tx, 0, tx);
  glVertex2f  (-m_size,  1);
#endif

  glEnd();
}
Example #12
0
void Redraw(void)
{
    GLfloat tmp[4];
    int ii;

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glBegin(GL_QUADS);

    for (ii = 0; ii < 4; ii++) {

        /* Transform a vertex from object to window coordinates.
         * 1/w is returned as tmp[3] for perspective-correcting
         * the texture coordinates.
         */
        DoTransform(quadV[ii], tmp);

        /* Ideally the colors will be computed by the lighting equation,
         * but I've hard-coded values for this example.
         */
        glColor3fv(quadC[ii]);

        /* Scale by 1/w (stored in tmp[3]) */
        glTexCoord4f(quadT[ii][0] * tmp[3],
                     quadT[ii][1] * tmp[3], 0.0f, tmp[3]);

        /* Note I am using Vertex3, not Vertex4, since we have already
         * performed the perspective divide.
         */
        glVertex3fv(tmp);
    }

    glEnd();

    glutSwapBuffers();
}
Example #13
0
/* GL locking is done by the caller */
static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context *context,
        const struct wined3d_stream_info *si, UINT NumVertexes, GLenum glPrimType,
        const void *idxData, UINT idxSize, UINT startIdx)
{
    unsigned int               textureNo    = 0;
    const WORD                *pIdxBufS     = NULL;
    const DWORD               *pIdxBufL     = NULL;
    UINT vx_index;
    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    const UINT *streamOffset = This->stateBlock->streamOffset;
    long                      SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex;
    BOOL                      pixelShader = use_ps(This->stateBlock);
    BOOL specular_fog = FALSE;
    const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
    const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
    const struct wined3d_gl_info *gl_info = context->gl_info;
    UINT texture_stages = gl_info->limits.texture_stages;
    const struct wined3d_stream_info_element *element;
    UINT num_untracked_materials;
    DWORD tex_mask = 0;

    TRACE("Using slow vertex array code\n");

    /* Variable Initialization */
    if (idxSize != 0) {
        /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer.
         * If the index buffer has no vbo(not supported or other reason), or with user pointer drawing
         * idxData will be != NULL
         */
        if(idxData == NULL) {
            idxData = buffer_get_sysmem((struct wined3d_buffer *) This->stateBlock->pIndexData);
        }

        if (idxSize == 2) pIdxBufS = idxData;
        else pIdxBufL = idxData;
    } else if (idxData) {
        ERR("non-NULL idxData with 0 idxSize, this should never happen\n");
        return;
    }

    /* Start drawing in GL */
    glBegin(glPrimType);

    if (si->use_map & (1 << WINED3D_FFP_POSITION))
    {
        element = &si->elements[WINED3D_FFP_POSITION];
        position = element->data + streamOffset[element->stream_idx];
    }

    if (si->use_map & (1 << WINED3D_FFP_NORMAL))
    {
        element = &si->elements[WINED3D_FFP_NORMAL];
        normal = element->data + streamOffset[element->stream_idx];
    }
    else
    {
        glNormal3f(0, 0, 0);
    }

    num_untracked_materials = context->num_untracked_materials;
    if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
    {
        element = &si->elements[WINED3D_FFP_DIFFUSE];
        diffuse = element->data + streamOffset[element->stream_idx];

        if (num_untracked_materials && element->format_desc->format != WINED3DFMT_B8G8R8A8_UNORM)
            FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format_desc->format));
    }
    else
    {
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    }

    if (si->use_map & (1 << WINED3D_FFP_SPECULAR))
    {
        element = &si->elements[WINED3D_FFP_SPECULAR];
        specular = element->data + streamOffset[element->stream_idx];

        /* special case where the fog density is stored in the specular alpha channel */
        if (This->stateBlock->renderState[WINED3DRS_FOGENABLE]
                && (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE
                    || si->elements[WINED3D_FFP_POSITION].format_desc->format == WINED3DFMT_R32G32B32A32_FLOAT)
                && This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
        {
            if (gl_info->supported[EXT_FOG_COORD])
            {
                if (element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) specular_fog = TRUE;
                else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->format_desc->format));
            }
            else
            {
                static BOOL warned;

                if (!warned)
                {
                    /* TODO: Use the fog table code from old ddraw */
                    FIXME("Implement fog for transformed vertices in software\n");
                    warned = TRUE;
                }
            }
        }
    }
    else if (gl_info->supported[EXT_SECONDARY_COLOR])
    {
        GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
    }

    for (textureNo = 0; textureNo < texture_stages; ++textureNo)
    {
        int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
        DWORD texture_idx = This->texUnitMap[textureNo];

        if (!gl_info->supported[ARB_MULTITEXTURE] && textureNo > 0)
        {
            FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
            continue;
        }

        if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;

        if (texture_idx == WINED3D_UNMAPPED_STAGE) continue;

        if (coordIdx > 7)
        {
            TRACE("tex: %d - Skip tex coords, as being system generated\n", textureNo);
            continue;
        }
        else if (coordIdx < 0)
        {
            FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
            continue;
        }

        if (si->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)))
        {
            element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
            texCoords[coordIdx] = element->data + streamOffset[element->stream_idx];
            tex_mask |= (1 << textureNo);
        }
        else
        {
            TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
            if (gl_info->supported[ARB_MULTITEXTURE])
                GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
            else
                glTexCoord4f(0, 0, 0, 1);
        }
    }

    /* We shouldn't start this function if any VBO is involved. Should I put a safety check here?
     * Guess it's not necessary(we crash then anyway) and would only eat CPU time
     */

    /* For each primitive */
    for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
        UINT texture, tmp_tex_mask;
        /* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
         * function pipeline at all. A Fixme for them is printed after decoding the vertex declaration
         */

        /* For indexed data, we need to go a few more strides in */
        if (idxData != NULL) {

            /* Indexed so work out the number of strides to skip */
            if (idxSize == 2)
                SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
            else
                SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
        }

        tmp_tex_mask = tex_mask;
        for (texture = 0; tmp_tex_mask; tmp_tex_mask >>= 1, ++texture)
        {
            int coord_idx;
            const void *ptr;
            DWORD texture_idx;

            if (!(tmp_tex_mask & 1)) continue;

            coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX];
            ptr = texCoords[coord_idx] + (SkipnStrides * si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].stride);

            texture_idx = This->texUnitMap[texture];
            multi_texcoord_funcs[si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format_desc->emit_idx](
                    GL_TEXTURE0_ARB + texture_idx, ptr);
        }

        /* Diffuse -------------------------------- */
        if (diffuse) {
            const void *ptrToCoords = diffuse + SkipnStrides * si->elements[WINED3D_FFP_DIFFUSE].stride;

            diffuse_funcs[si->elements[WINED3D_FFP_DIFFUSE].format_desc->emit_idx](ptrToCoords);
            if (num_untracked_materials)
            {
                DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
                unsigned char i;
                float color[4];

                color[0] = D3DCOLOR_B_R(diffuseColor) / 255.0f;
                color[1] = D3DCOLOR_B_G(diffuseColor) / 255.0f;
                color[2] = D3DCOLOR_B_B(diffuseColor) / 255.0f;
                color[3] = D3DCOLOR_B_A(diffuseColor) / 255.0f;

                for (i = 0; i < num_untracked_materials; ++i)
                {
                    glMaterialfv(GL_FRONT_AND_BACK, context->untracked_materials[i], color);
                }
            }
        }

        /* Specular ------------------------------- */
        if (specular) {
            const void *ptrToCoords = specular + SkipnStrides * si->elements[WINED3D_FFP_SPECULAR].stride;

            specular_funcs[si->elements[WINED3D_FFP_SPECULAR].format_desc->emit_idx](ptrToCoords);

            if (specular_fog)
            {
                DWORD specularColor = *(const DWORD *)ptrToCoords;
                GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
            }
        }

        /* Normal -------------------------------- */
        if (normal != NULL) {
            const void *ptrToCoords = normal + SkipnStrides * si->elements[WINED3D_FFP_NORMAL].stride;
            normal_funcs[si->elements[WINED3D_FFP_NORMAL].format_desc->emit_idx](ptrToCoords);
        }

        /* Position -------------------------------- */
        if (position) {
            const void *ptrToCoords = position + SkipnStrides * si->elements[WINED3D_FFP_POSITION].stride;
            position_funcs[si->elements[WINED3D_FFP_POSITION].format_desc->emit_idx](ptrToCoords);
        }

        /* For non indexed mode, step onto next parts */
        if (idxData == NULL) {
            ++SkipnStrides;
        }
    }

    glEnd();
    checkGLcall("glEnd and previous calls");
}
Example #14
0
//--------------------------------------------------------------
void testApp::draw(){

	ofSetColor(0,0,0);
	ofDrawBitmapString("press '1' to turn off shaders\npress '2' to toggle on/off rotating camera\npress '3' to toggle on/off on shader A [only]\npress '4' to toggle on/off on shader B [only]\npress '5' to map or not a texture on the GL_QUAD", 20, 20);

	if (cam_IsActive) cam.place();

	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if (useTex) {
		glEnable(tex.getTextureData().textureTarget );
		glBindTexture (tex.getTextureData().textureTarget, (GLuint)tex.getTextureData().textureID ); 
	}
	
	
	if (shaderA_IsActive) {
		shaderA.setShaderActive(shaderA_IsActive);
		shaderA.setUniform("time", (float)timer);
	} else if (shaderB_IsActive) {
		shaderB.setShaderActive(shaderB_IsActive);
	}
	
	//glTranslatef(256.0f,128.0f, 0.0f);

	if (useTex) {
	/*
		glBegin(GL_QUADS);
			glTexCoord3f(0.0f, 0.0f, 0.0f);
			glVertex3f(0.0f,0.0f, 0.0f);
			glTexCoord3f(512.0f, 0.0f, 0.0f);
			glVertex3f(512.0f,0.0f, 0.0f);
			glTexCoord3f(512.0f,512.0f, 0.0f);
			glVertex3f(512.0f,512.0f, 0.0f);
			glTexCoord3f(0.0f, 512.0f, 0.0f);
			glVertex3f(0.0f, 512.0f, 0.0f);
		glEnd();
	*/	
		glBegin(GL_QUADS);
			// x,y,z, size of the quad
			glTexCoord4f( 512.0f, 384.0f, 0.0f, 512.0f); // <-- IMPORTANT
			glVertex2f( -1.0f, -1.0f );
			glVertex2f( +1.0f, -1.0f );
			glVertex2f( +1.0f, +1.0f );
			glVertex2f( -1.0f, +1.0f ); 
		glEnd();
	} else {
		glTranslatef(256.0f,128.0f, 0.0f);
		glBegin(GL_QUADS);
			glVertex3f(0.0f,0.0f, 0.0f);
			glVertex3f(512.0f,0.0f, 0.0f);
			glVertex3f(512.0f,512.0f, 0.0f);
			glVertex3f(0.0f, 512.0f, 0.0f);
		glEnd();
	}
	
 
	
	if (shaderA_IsActive) {
		shaderA.setShaderActive(false);
	} else {
		shaderB.setShaderActive(false);
	}
	
	if (useTex) {
		glBindTexture(tex.getTextureData().textureTarget, 0);
		glDisable(tex.getTextureData().textureTarget );
	}
	

}
Example #15
0
static bool
render_and_check(int w, int h, int d, GLenum format, float q,
		 const GLubyte *data, const char* test)
{
	int x, y, z;
	int layer;
	GLubyte *readback;
	const GLubyte *texp;
	GLubyte *readp;
	int ncomp = 0;

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);
	glEnable(GL_TEXTURE_3D);

	x = y = 0;
	for(layer = 0; layer < d; ++layer) {
		float r = (layer+0.5)/d;
		glBegin(GL_QUADS);
			glTexCoord4f(0, 0, r*q, q);
			glVertex2f(x, y);
			glTexCoord4f(q, 0, r*q, q);
			glVertex2f(x+w, y);
			glTexCoord4f(q, q, r*q, q);
			glVertex2f(x+w, y+h);
			glTexCoord4f(0, q, r*q, q);
			glVertex2f(x, y+h);
		glEnd();
		x += w;
		if (x + w >= piglit_width) {
			y += h;
			x = 0;
		}
	}

	readback = (GLubyte*)malloc(w*h*d*4);
	x = y = 0;
	for(layer = 0; layer < d; ++layer) {
		glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, readback+layer*w*h*4);
		x += w;
		if (x + w >= piglit_width) {
			y += h;
			x = 0;
		}
	}

	texp = data;
	readp = readback;
	ncomp = nrcomponents(format);
	for(z = 0; z < d; ++z) {
		for(y = 0; y < h; ++y) {
			for(x = 0; x < w; ++x, readp += 4, texp += ncomp) {
				GLubyte expected[4];
				int i;
				expected_rgba(format, texp, expected);
				for(i = 0; i < 4; ++i) {
					if (expected[i] != readp[i]) {
						fprintf(stderr, "%s: Mismatch at %ix%ix%i\n", test, x, y, z);
						fprintf(stderr, " Expected: %i,%i,%i,%i\n",
							expected[0], expected[1], expected[2], expected[3]);
						fprintf(stderr, " Readback: %i,%i,%i,%i\n",
							readp[0], readp[1], readp[2], readp[3]);
						free(readback);
						return false;
					}
				}
			}
		}
	}
	free(readback);

	piglit_present_results();

	return true;
}
inline void glTexCoord( const GLfloat & s, const GLfloat & t, const GLfloat & r, const GLfloat & q )		{ glTexCoord4f( s, t, r, q ); }
Example #17
0
GLboolean test_one(unsigned vert_clamp, unsigned frag_clamp, unsigned semantic,
                   unsigned blend, unsigned logicop, unsigned vpmode, unsigned fpmode)
{
	GLfloat probe[4];
	char test_name[4096];
	unsigned clamped = (semantic == 0 && (clamp_enums[vert_clamp] == GL_TRUE || (clamp_enums[vert_clamp] == GL_FIXED_ONLY_ARB && fixed))) || clamp_enums[frag_clamp] == GL_TRUE || (clamp_enums[frag_clamp] == GL_FIXED_ONLY_ARB && fixed);
	float *expected;
	GLboolean cpass;
	GLboolean opass;

	glFogi(GL_FOG_MODE, GL_LINEAR);

	sprintf(test_name, "%s: Attrib %s  VertClamp %s  FragClamp %s  Blending %s  LogicOp %s  %s  %s  Fog %s (expecting %sclamping)",
		format_name,
		semantic ? "TEXCOORD0" : "COLOR    ",
		clamp_strings[vert_clamp],
		clamp_strings[frag_clamp],
		blend_strings[blend],
		logicop ? "Yes" : "No ",
		vpmode ? "ARB_vp" : "ffvp  ",
		fpmode ? "ARB_fp" : "fffp  ",
		test_fog ? "Yes" : "No ",
		clamped ? "" : "no ");
	if (!sanity) {
		glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, clamp_enums[vert_clamp]);
		glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, clamp_enums[frag_clamp]);
	}

	glColor4f(0.1f, 0.2f, 0.3f, 0.4f);
	glTexCoord4f(0.5f, 0.6f, 0.7f, 0.8f);

	if (vpmode) {
		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vps[semantic]);
		glEnable(GL_VERTEX_PROGRAM_ARB);
	}
	else {
		if (semantic == 0)
			glColor4f(pixels[0], pixels[1], pixels[2], pixels[3]);
		else
			glTexCoord4f(pixels[0], pixels[1], pixels[2], pixels[3]);
	}

	if (fpmode) {
		glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fps[semantic + (test_fog ? 2 : 0)]);
		glEnable(GL_FRAGMENT_PROGRAM_ARB);
	}
	else {
		if (test_fog)
			glEnable(GL_FOG);
	}

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	if (blend) {
		glEnable(GL_BLEND);
		glBlendFunc(blend_src[blend], blend_dst[blend]);
		glBlendColor(2.0f, 2.0f, 2.0f, 2.0f);
	}

	if (logicop)
		glEnable(GL_COLOR_LOGIC_OP);

	piglit_draw_rect(-1, -1, 1, 1);

	if (logicop)
		glDisable(GL_COLOR_LOGIC_OP);
	if (blend)
		glDisable(GL_BLEND);
	if (vpmode)
		glDisable(GL_VERTEX_PROGRAM_ARB);
	if (fpmode)
		glDisable(GL_FRAGMENT_PROGRAM_ARB);
	else if (test_fog)
		glDisable(GL_FOG);

	if (blend == 2 && !logicop) {
		if (fixed_snorm)
			expected = clamped ? clamped_pixels : signed_clamped_pixels;
		else if (fixed)
			expected = clamped_pixels;
		else
			expected = clamped ? clamped_pixels_mul_2 : pixels_mul_2;
	}
	else if (blend == 3 && !logicop) {
		if (fixed_snorm)
			expected = clamped ? clamped_pixels_plus_half_signed_clamped : signed_clamped_pixels_plus_half_signed_clamped;
		else if (fixed)
			expected = clamped_pixels_plus_half_clamped;
		else
			expected = clamped ? clamped_pixels_plus_half : pixels_plus_half;
	}
	else {
		expected = clamped ? clamped_pixels :
			fixed_snorm ? signed_clamped_pixels :
			fixed ? clamped_pixels :
			pixels;
	}

	opass = cpass = piglit_probe_pixel_rgba_silent(0, 0, expected, probe);

	if (nvidia_driver && clamped && !(semantic == 0 && clamp_enums[vert_clamp] == GL_TRUE) && clamp_enums[frag_clamp] == GL_TRUE && !fixed && fpmode && (!blend || logicop || format == GL_RGBA16F_ARB)) {
		printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with ARB_fp on either fp32 with no blending or fp16!\n");
		opass = GL_TRUE;
	}
	if (nvidia_driver && clamped && !fixed && !fpmode && semantic == 0 && clamp_enums[vert_clamp] != GL_TRUE && clamp_enums[frag_clamp] == GL_TRUE) {
		printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with fffp, vertex clamp off and fragment clamp on fp16/fp32!\n");
		opass = GL_TRUE;
	}

	if (test_fog && fpmode)	{
		//printf("Unclear specification on GL_ARB_fog_*\n");
		opass = GL_TRUE;
	}

	if (!opass) {
		printf("%s: %s\n", (cpass ? "PASS" : "FAIL"), test_name);
		printf("  Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
		printf("  Observed: %f %f %f %f\n", probe[0], probe[1], probe[2], probe[3]);
		
	}

	return opass;
}
Example #18
0
// Render a world polygon without multitexture support.  This will do two-polygon draws,
// one with the regular texture, then another with the lightmap texture.  Clearly we hope
// we don't have to use this function (if multitexture is supported in hardware and OpenGL
// ICD, we won't have to), but its here just in case.
void Render_WorldPolyRegular(DRV_TLVertex *Pnts, int32 NumPoints, geRDriver_THandle *THandle,
							 DRV_LInfo *LInfo, GLfloat shiftU, GLfloat shiftV, 
							 GLfloat scaleU, GLfloat scaleV,
							 GLubyte alpha)
{
	DRV_TLVertex *pPnt;
	GLfloat zRecip;
	GLfloat tu, tv;
	GLint	i;

#ifdef USE_LIGHTMAPS
	if(LInfo != NULL)
	{
		glDepthMask(GL_FALSE);
	}
#endif

	pPnt = Pnts;

	glBegin(GL_TRIANGLE_FAN);	

	for(i = 0; i < NumPoints; i++)
	{	
		zRecip = 1.0f / pPnt->z;   

		tu = (pPnt->u * scaleU + shiftU);
		tv = (pPnt->v * scaleV + shiftV);

		glColor4ub((GLubyte)pPnt->r, (GLubyte)pPnt->g, (GLubyte)pPnt->b, alpha);

		glTexCoord4f(tu * THandle->InvScale * zRecip, 
			tv * THandle->InvScale * zRecip, 0.0f, zRecip);
	
		glVertex3f(pPnt->x, pPnt->y, -1.0f + zRecip);
		
		pPnt++;
	}

	glEnd(); 

#ifdef USE_LIGHTMAPS
	if(LInfo != NULL)
	{
		glDepthMask(GL_TRUE);
		
		glBlendFunc(GL_DST_COLOR,GL_ZERO);

		pPnt = Pnts;

		if(boundTexture != LInfo->THandle->TextureID)
		{
			glBindTexture(GL_TEXTURE_2D, LInfo->THandle->TextureID);
			boundTexture = LInfo->THandle->TextureID;
		}

		if(LInfo->THandle->Flags & THANDLE_UPDATE)
		{
			THandle_Update(LInfo->THandle);
		}

		shiftU = (GLfloat)LInfo->MinU - 8.0f;
		shiftV = (GLfloat)LInfo->MinV - 8.0f;

		glColor4ub(255, 255, 255, 255);

	    glBegin(GL_TRIANGLE_FAN);	
		
		for(i = 0; i < NumPoints; i++)
		{	
			zRecip = 1.0f / pPnt->z;   

			tu = pPnt->u - shiftU;
			tv = pPnt->v - shiftV;

			glTexCoord4f(tu * LInfo->THandle->InvScale * zRecip, 
				tv * LInfo->THandle->InvScale * zRecip, 0.0f, zRecip);

			glVertex3f(pPnt->x, pPnt->y, -1.0f + zRecip);
			
			pPnt++;
		}
		
		glEnd(); 

		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
#endif
}
Example #19
0
bool glWindow::ResetGL () {

    if (m_resetGLMode == RGM_RECREATEWINDOW) {
        RecreateWindow (m_fullScreen, m_border, m_width, m_height, m_bpp, m_stencil, m_title, m_allowResizing, m_fitToWorkArea);
        return true;
    }
    else if (m_resetGLMode == RGM_RECREATECONTEXT) {
        RecreateGLContext ();
        return true;
    }

    // Setup OpenGL defaults.
    // This should reset as much as possible back to the initial state of OpenGL.

    // Exceptions:
    //      * Projection matrix is initialised to a perspective transform

    // End current gl block
    try { glEnd ();                                                             } catch (...) { ; }    
    m_dontPaint = false;

    // Intialise matrices
    try { glMatrixMode (GL_PROJECTION);   ClearGLMatrix ();                     } catch (...) { ; }
    try { glMatrixMode (GL_TEXTURE);      ClearGLMatrix ();                     } catch (...) { ; }
    try { glMatrixMode (GL_MODELVIEW);    ClearGLMatrix ();                     } catch (...) { ; }

    // Initialise state
    int i;
    try { glColor4f (1, 1, 1, 1);                                               } catch (...) { ; }
    try { glIndexi (1);                                                         } catch (...) { ; }
    try { glTexCoord4f (0, 0, 0, 1);                                            } catch (...) { ; }
    try { glNormal3f (0, 0, 1);                                                 } catch (...) { ; }
//    try { glRasterPos4f (0, 0, 0, 1);                                           } catch (...) { ; }
    try { glEdgeFlag (GL_TRUE);                                                 } catch (...) { ; }
    try { glDisable (GL_VERTEX_ARRAY);                                          } catch (...) { ; }
    try { glDisable (GL_NORMAL_ARRAY);                                          } catch (...) { ; }
    try { glDisable (GL_COLOR_ARRAY);                                           } catch (...) { ; }
    try { glDisable (GL_INDEX_ARRAY);                                           } catch (...) { ; }
    try { glDisable (GL_TEXTURE_COORD_ARRAY);                                   } catch (...) { ; }
    try { glDisable (GL_EDGE_FLAG_ARRAY);                                       } catch (...) { ; }
    try { glDepthRange (0, 1);                                                  } catch (...) { ; }
    try { glDisable (GL_NORMALIZE);                                             } catch (...) { ; }
    for (i = 0; i < GL_MAX_CLIP_PLANES; i++)
        try { glDisable (GL_CLIP_PLANE0 + i);                                   } catch (...) { ; }
    GLfloat fog[] = {0, 0, 0, 0};
    try { glFogfv (GL_FOG_COLOR, fog);                                          } catch (...) { ; }
    try { glFogi (GL_FOG_INDEX, 0);                                             } catch (...) { ; }
    try { glFogf (GL_FOG_DENSITY, 1.0);                                         } catch (...) { ; }
    try { glFogf (GL_FOG_START, 0.0);                                           } catch (...) { ; }
    try { glFogf (GL_FOG_END, 1.0);                                             } catch (...) { ; }
    try { glFogi (GL_FOG_MODE, GL_EXP);                                         } catch (...) { ; }
    try { glDisable (GL_FOG);                                                   } catch (...) { ; }
    try { glShadeModel (GL_SMOOTH);                                             } catch (...) { ; }
    try { glDisable (GL_LIGHTING);                                              } catch (...) { ; }
    try { glDisable (GL_COLOR_MATERIAL);                                        } catch (...) { ; }
    try { glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);          } catch (...) { ; }

    GLfloat ambient[]   = { 0.2, 0.2, 0.2, 1.0 },
            diffuse[]   = { 0.8, 0.8, 0.8, 1.0 },
            specular[]  = { 0.0, 0.0, 0.0, 1.0 },
            emission[]  = { 0.0, 0.0, 0.0, 1.0 },
            shininess[] = { 0.0 };
    try { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT,    ambient);             } catch (...) { ; }
    try { glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE,    diffuse);             } catch (...) { ; }
    try { glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,  specular);             } catch (...) { ; }
    try { glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION,   emission);            } catch (...) { ; }
    try { glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS,  shininess);           } catch (...) { ; }
    try { glLightModelfv (GL_LIGHT_MODEL_AMBIENT, ambient);                     } catch (...) { ; }
    try { glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);                } catch (...) { ; }
    try { glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);                    } catch (...) { ; }
    GLfloat lambient[]      = { 0.0, 0.0, 0.0, 1.0 },
            ldiffuse0[]     = { 1.0, 1.0, 1.0, 1.0 },
            ldiffuse1[]     = { 0.0, 0.0, 0.0, 1.0 },
            lspecular0[]    = { 1.0, 1.0, 1.0, 1.0 },
            lspecular1[]    = { 0.0, 0.0, 0.0, 1.0 },
            lposition[]     = { 0.0, 0.0, 1.0, 0.0 };
    for (i = 0; i < 8; i++) {
        try { glLightfv (GL_LIGHT0 + i, GL_AMBIENT, lambient);                              } catch (...) { ; }
        try { glLightfv (GL_LIGHT0 + i, GL_DIFFUSE, i == 0 ? ldiffuse0 : ldiffuse1);        } catch (...) { ; }
        try { glLightfv (GL_LIGHT0 + i, GL_SPECULAR, i == 0 ? lspecular0 : lspecular1);     } catch (...) { ; }
        try { glLightfv (GL_LIGHT0 + i, GL_POSITION, lposition);                            } catch (...) { ; }
        try { glLightf (GL_LIGHT0 + i, GL_SPOT_EXPONENT, 0.0);                              } catch (...) { ; }
        try { glLightf (GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 1.0);                       } catch (...) { ; }
        try { glLightf (GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 0.0);                         } catch (...) { ; }
        try { glLightf (GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 0.0);                      } catch (...) { ; }
        try { glDisable (GL_LIGHT0 + i);                                                    } catch (...) { ; }
    }

    try { glPointSize (1.0);                                                    } catch (...) { ; }
    try { glDisable (GL_POINT_SMOOTH);                                          } catch (...) { ; }
    try { glLineWidth (1.0);                                                    } catch (...) { ; }
    try { glDisable (GL_LINE_SMOOTH);                                           } catch (...) { ; }
    try { glLineStipple (1, 0xffff);                                            } catch (...) { ; }
    try { glDisable (GL_LINE_STIPPLE);                                          } catch (...) { ; }
    try { glDisable (GL_CULL_FACE);                                             } catch (...) { ; }
    try { glCullFace (GL_BACK);                                                 } catch (...) { ; }
    try { glFrontFace (GL_CCW);                                                 } catch (...) { ; }
    try { glDisable (GL_POLYGON_SMOOTH);                                        } catch (...) { ; }
    try { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);                           } catch (...) { ; }
    try { glDisable (GL_TEXTURE_1D);                                            } catch (...) { ; }
    try { glDisable (GL_TEXTURE_2D);                                            } catch (...) { ; }

    try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } catch (...) { ; }
    try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);                } catch (...) { ; }
    try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);                    } catch (...) { ; }
    try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);                    } catch (...) { ; }
    GLfloat texBorder[] = {0, 0, 0, 0};
    try { glTexParameterfv (GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, texBorder);             } catch (...) { ; }
    try { glDisable (GL_TEXTURE_GEN_T);                                                     } catch (...) { ; }
    try { glDisable (GL_TEXTURE_GEN_S);                                                     } catch (...) { ; }
    try { glDisable (GL_TEXTURE_GEN_R);                                                     } catch (...) { ; }
    try { glDisable (GL_TEXTURE_GEN_Q);                                                     } catch (...) { ; }
    for (i = 0; i < 4; i++) {
        GLenum coord;
        switch (i) {
        case 0: coord = GL_T; break;
        case 1: coord = GL_S; break;
        case 2: coord = GL_R; break;
        case 3: coord = GL_Q; break;
        }
        try { glTexGeni (coord, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);            } catch (...) { ; }
    }

    try { glDisable (GL_SCISSOR_TEST);                                          } catch (...) { ; }
    try { glDisable (GL_ALPHA_TEST);                                            } catch (...) { ; }
    try { glAlphaFunc (GL_ALWAYS, 0);                                           } catch (...) { ; }
    try { glDisable (GL_STENCIL_TEST);                                          } catch (...) { ; }
    try { glStencilFunc (GL_ALWAYS, 0, 0xffffffff);                             } catch (...) { ; }
    try { glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);                              } catch (...) { ; }
    try { glDisable (GL_DEPTH_TEST);                                            } catch (...) { ; }
    try { glDepthFunc (GL_LESS);                                                } catch (...) { ; }
    try { glDisable (GL_BLEND);                                                 } catch (...) { ; }
    try { glBlendFunc (GL_ONE, GL_ZERO);                                        } catch (...) { ; }
    try { glDrawBuffer (GL_BACK);                                               } catch (...) { ; }
    try { glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);                     } catch (...) { ; }
    try { glDepthMask (GL_TRUE);                                                } catch (...) { ; }
    try { glClearAccum (0, 0, 0, 0);                                            } catch (...) { ; }
    try { glClearColor (0, 0, 0, 0);                                            } catch (...) { ; }
    try { glClearDepth (1);                                                     } catch (...) { ; }
    try { glClearIndex (0);                                                     } catch (...) { ; }
    try { glClearStencil (0);                                                   } catch (...) { ; }

    try { glPixelStorei (GL_PACK_SWAP_BYTES, GL_FALSE);                         } catch (...) { ; }
    try { glPixelStorei (GL_PACK_LSB_FIRST, GL_FALSE);                          } catch (...) { ; }
    try { glPixelStoref (GL_PACK_ROW_LENGTH, 0);                                } catch (...) { ; }
    try { glPixelStoref (GL_PACK_SKIP_PIXELS, 0);                               } catch (...) { ; }
    try { glPixelStorei (GL_PACK_ALIGNMENT, 4);                                 } catch (...) { ; }
    try { glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);                       } catch (...) { ; }
    try { glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);                        } catch (...) { ; }
    try { glPixelStoref (GL_UNPACK_ROW_LENGTH, 0);                              } catch (...) { ; }
    try { glPixelStoref (GL_UNPACK_SKIP_PIXELS, 0);                             } catch (...) { ; }
    try { glPixelStorei (GL_UNPACK_ALIGNMENT, 4);                               } catch (...) { ; }
    try { glPixelTransferi (GL_MAP_COLOR, GL_FALSE);                            } catch (...) { ; }
    try { glPixelTransferi (GL_MAP_STENCIL, GL_FALSE);                          } catch (...) { ; }
    try { glPixelTransferi (GL_INDEX_SHIFT, 0);                                 } catch (...) { ; }
    try { glPixelTransferi (GL_INDEX_OFFSET, 0);                                } catch (...) { ; }
    try { glPixelTransferf (GL_RED_SCALE, 1.0);                                 } catch (...) { ; }
    try { glPixelTransferf (GL_GREEN_SCALE, 1.0);                               } catch (...) { ; }
    try { glPixelTransferf (GL_BLUE_SCALE, 1.0);                                } catch (...) { ; }
    try { glPixelTransferf (GL_ALPHA_SCALE, 1.0);                               } catch (...) { ; }
    try { glPixelTransferf (GL_DEPTH_SCALE, 1.0);                               } catch (...) { ; }
    try { glPixelTransferf (GL_RED_BIAS, 0.0);                                  } catch (...) { ; }
    try { glPixelTransferf (GL_GREEN_BIAS, 0.0);                                } catch (...) { ; }
    try { glPixelTransferf (GL_BLUE_BIAS, 0.0);                                 } catch (...) { ; }
    try { glPixelTransferf (GL_ALPHA_BIAS, 0.0);                                } catch (...) { ; }
    try { glPixelTransferf (GL_DEPTH_BIAS, 0.0);                                } catch (...) { ; }

    try { glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);                } catch (...) { ; }
    try { glHint (GL_POINT_SMOOTH_HINT, GL_DONT_CARE);                          } catch (...) { ; }
    try { glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);                           } catch (...) { ; }
    try { glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);                        } catch (...) { ; }
    try { glHint (GL_FOG_HINT, GL_DONT_CARE);                                   } catch (...) { ; }

    // Multitexturing
    if (ExtensionSupported ("GL_ARB_multitexture")) {

        // Disable texturing for all texture units
        int units;
        try { glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &units);                 } catch (...) { ; }
        for (int i = 0; i < units; i++) {
            if (glActiveTexture != NULL)
                glActiveTexture (GL_TEXTURE0_ARB + i);
            try { glDisable (GL_TEXTURE_2D);                                    } catch (...) { ; }
            try { glDisable (GL_TEXTURE_1D);                                    } catch (...) { ; }
            if (i == 0) try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } catch (...) { ; }
            else        try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);    } catch (...) { ; }
        }

        if (glActiveTexture != NULL)
            try { glActiveTexture (GL_TEXTURE0_ARB);                            } catch (...) { ; }
    }

    // Setup OpenGL defaults
    OpenGLDefaults ();

	return TRUE;									// Initialization Went OK
}
Example #20
0
void glTexCoord2f(float s,float t)
{
  glTexCoord4f(s,t,0,1);
}
Example #21
0
void Graph :: drawneighboredges(int ndid, bool forshade, double thick){
	double RADIUS = 0.01;
	double HALOSIZE = 1.1;
	
	GraphNode * gn = getGraphNode(ndid);
	vector<GraphEdge *> edgelist = gn -> edgesvec();
	
	for (int e=0; e<edgelist.size(); e++) {
		
		if (forshade) {
			glBegin(GL_QUADS);
			vec3d point1 = edgelist.at(e)->get_from()->getPos();
			vec3d point2 = edgelist.at(e)->get_to()->getPos();
			
			vec3d tang = point2 - point1;
			
			glNormal3f(tang.x, tang.y, tang.z);
			
			glTexCoord4f(-1.0*RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
			//glTexCoord3f(-1.0, alpha, thick); 
			glVertex3f(point1.x, point1.y, point1.z);
			
			glTexCoord4f(RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
			//glTexCoord3f(1.0, alpha, thick); 
			glVertex3f(point1.x, point1.y, point1.z);
			
			glNormal3f(tang.x, tang.y, tang.z);
			
			glTexCoord4f(RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
			//glTexCoord3f(1.0, alpha, thick); 
			glVertex3f(point2.x, point2.y, point2.z);
			
			glTexCoord4f(-1.0*RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
			//glTexCoord3f(-1.0, alpha, thick); 
			glVertex3f(point2.x, point2.y, point2.z);
			
			glEnd();
		}
		else {
			
			glLineWidth(thick);
			glBegin(GL_LINES);
			
			vec3d point1 = edgelist.at(e)->get_from()->getPos();
			vec3d point2 = edgelist.at(e)->get_to()->getPos();
			glVertex3d(point1.x, point1.y, point1.z);
			glVertex3d(point2.x, point2.y, point2.z);
				
			glEnd();
			
		}
		
		
	
	}

	
	

	
}
Example #22
0
static void drawSample( int x, int y, int w, int h,
                        int texgenenabled, int coordnr )
{
   char buf[255];

   glViewport( x, y, w, h );
   glScissor( x, y, w, h );

   glClearColor( 0.1, 0.1, 0.1, 1.0 );
   glClear( GL_COLOR_BUFFER_BIT );

   begin2D( w, h );
   if (texgenenabled == 2) {
      sprintf( buf, "TexCoord%df", coordnr);
      drawString( buf, 10, h - 15, labelInfoColor );
      sprintf( buf, "texgen enabled for %s coordinate(s)", coordnr == 2 ? "S" : "S/T");
      drawString( buf, 10, 5, labelInfoColor );
   }
   else if (texgenenabled == 0) {
      sprintf( buf, "TexCoord%df", coordnr);
      drawString( buf, 10, h - 15, labelInfoColor );
      drawString( "no texgen", 10, 5, labelInfoColor );
   }
   else if (texgenenabled == 1) {
      drawString( "no TexCoord", 10, h - 15, labelInfoColor );
      sprintf( buf, "texgen enabled for %s coordinate(s)",
         coordnr == 2 ? "S/T" : (coordnr == 3 ? "S/T/R" : "S/T/R/Q"));
      drawString( buf, 10, 5, labelInfoColor );
   }

   end2D();

   glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );

   loadTexture( textureWidth, textureHeight );

   if ( drawTextured ) {
      glEnable( GL_TEXTURE_2D );
   }

   glDisable( GL_TEXTURE_GEN_S );
   glDisable( GL_TEXTURE_GEN_T );
   glDisable( GL_TEXTURE_GEN_R );
   glDisable( GL_TEXTURE_GEN_Q );

   glMatrixMode( GL_TEXTURE );
   glLoadIdentity();
   glMatrixMode( GL_MODELVIEW );
   glPushMatrix();

   switch (coordnr) {
   case 2:
      switch (texgenenabled) {
      case 0:
         glBegin( GL_QUADS );
         glTexCoord2f( 0.0, 0.0 );
         glVertex2f( -0.8, -0.8 );

         glTexCoord2f( 1.0, 0.0 );
         glVertex2f( 0.8, -0.8 );

         glTexCoord2f( 1.0, 1.0 );
         glVertex2f( 0.8, 0.8 );

         glTexCoord2f( 0.0, 1.0 );
         glVertex2f( -0.8, 0.8 );
         glEnd();
         break;
      case 1:
         glTranslatef( -0.8, -0.8, 0.0 );
         glScalef( 1.6, 1.6, 1.0 );
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS3);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT3);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);

         glEnable( GL_TEXTURE_GEN_S );
         glEnable( GL_TEXTURE_GEN_T );

         /* Issue a texcoord here to be sure Q isn't left over from a
          * previous sample.
          */
         glTexCoord1f( 0.0 );
         glBegin( GL_QUADS );
         glVertex2f( 0.0, 0.0 );
         glVertex2f( 1.0, 0.0 );
         glVertex2f( 1.0, 1.0 );
         glVertex2f( 0.0, 1.0 );
         glEnd();
         break;
      case 2:
         /* make sure that texgen T and non-texgen S coordinate are wrong */
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS1);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, nullPlane);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);

         glEnable( GL_TEXTURE_GEN_S );

         glBegin( GL_QUADS );
         /* use z coordinate to get correct texgen values... */
         glTexCoord2f( 0.0, 0.0 );
         glVertex3f( -0.8, -0.8, 0.8 );

         glTexCoord2f( 0.0, 0.0 );
         glVertex3f( 0.8, -0.8, 0.2 );

         glTexCoord2f( 0.0, 1.0 );
         glVertex3f( 0.8, 0.8, 0.2 );

         glTexCoord2f( 0.0, 1.0 );
         glVertex3f( -0.8, 0.8, 0.8 );
         glEnd();
         break;
      }
      break;
   case 3:
      glMatrixMode( GL_TEXTURE );
      glLoadMatrixf( texmat_swap_rq );
      glMatrixMode( GL_MODELVIEW );
      glTranslatef( -0.8, -0.8, 0.0 );
      glScalef( 1.6, 1.6, 1.0 );
      switch (texgenenabled) {
      case 0:
         glBegin( GL_QUADS );
         glTexCoord3f( 0.0, 0.0, 0.5 );
         glVertex2f( 0.0, 0.0 );

         glTexCoord3f( 0.5, 0.0, 0.5 );
         glVertex2f( 1.0, 0.0 );

         glTexCoord3f( 0.5, 0.5, 0.5 );
         glVertex2f( 1.0, 1.0 );

         glTexCoord3f( 0.0, 0.5, 0.5 );
         glVertex2f( 0.0, 1.0 );
         glEnd();
         break;
      case 1:
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);

         glEnable( GL_TEXTURE_GEN_S );
         glEnable( GL_TEXTURE_GEN_T );
         glEnable( GL_TEXTURE_GEN_R );

         glTexCoord1f( 0.0 ); /* to make sure Q is 1.0 */
         glBegin( GL_QUADS );
         glVertex3f( 0.0, 0.0, 0.5 );
         glVertex3f( 1.0, 0.0, 0.5 );
         glVertex3f( 1.0, 1.0, 0.5 );
         glVertex3f( 0.0, 1.0, 0.5 );
         glEnd();
         break;
      case 2:
         /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);

         glEnable( GL_TEXTURE_GEN_S );
         glEnable( GL_TEXTURE_GEN_T );

         glBegin( GL_QUADS );
         glTexCoord3f( 0.0, 0.0, 0.5 );
         glVertex2f( 0.0, 0.0);

         glTexCoord3f( 0.0, 0.0, 0.5 );
         glVertex2f( 1.0, 0.0);

         glTexCoord3f( 0.0, 0.0, 0.5 );
         glVertex2f( 1.0, 1.0);

         glTexCoord3f( 0.0, 0.0, 0.5 );
         glVertex2f( 0.0, 1.0);
         glEnd();
         break;
      }
      break;
   case 4:
      switch (texgenenabled) {
      case 0:
         glBegin( GL_QUADS );
         /* don't need r coordinate but still setting it I'm mean */
         glTexCoord4f( 0.0, 0.0, 0.0, 0.5 );
         glVertex2f( -0.8, -0.8 );

         glTexCoord4f( 0.5, 0.0, 0.2, 0.5 );
         glVertex2f( 0.8, -0.8 );

         glTexCoord4f( 0.5, 0.5, 0.5, 0.5 );
         glVertex2f( 0.8, 0.8 );

         glTexCoord4f( 0.0, 0.5, 0.5, 0.5 );
         glVertex2f( -0.8, 0.8 );
         glEnd();
         break;
      case 1:
         glTranslatef( -0.8, -0.8, 0.0 );
         glScalef( 1.6, 1.6, 1.0 );
         /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, ObjPlaneQ);

         glEnable( GL_TEXTURE_GEN_S );
         glEnable( GL_TEXTURE_GEN_T );
         glEnable( GL_TEXTURE_GEN_R );
         glEnable( GL_TEXTURE_GEN_Q );

         glBegin( GL_QUADS );
         glVertex2f( 0.0, 0.0 );
         glVertex2f( 1.0, 0.0 );
         glVertex2f( 1.0, 1.0 );
         glVertex2f( 0.0, 1.0 );
         glEnd();
         break;
      case 2:
         glTranslatef( -0.8, -0.8, 0.0 );
         glScalef( 1.6, 1.6, 1.0 );
         /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */
         glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
         glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2);
         glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2);
         glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane);
         glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane);

         glEnable( GL_TEXTURE_GEN_S );
         glEnable( GL_TEXTURE_GEN_T );

         glBegin( GL_QUADS );
         glTexCoord4f( 0.0, 0.0, 0.0, 0.5 );
         glVertex2f( 0.0, 0.0 );

         glTexCoord4f( 0.0, 0.0, 0.2, 0.5 );
         glVertex2f( 1.0, 0.0 );

         glTexCoord4f( 0.0, 0.0, 0.5, 0.5 );
         glVertex2f( 1.0, 1.0 );

         glTexCoord4f( 0.0, 0.0, 0.75, 0.5 );
         glVertex2f( 0.0, 1.0 );
         glEnd();
         break;
      }
      break;
   }

   glPopMatrix();
   glDisable( GL_TEXTURE_2D );

}
Example #23
0
static void infinity_xy_plane(eCoord const & pos, const eCoord &dir,REAL h=0){
    bool use_rim=false;
    REAL zero=0;

    if (sr_highRim)
        use_rim=true;

    if ( se_bugRip )
        use_rim=false;

    // always use the rim if infinity rendering is turned off
    use_rim |= !sr_infinityPlane;

    if (use_rim){
        /*
          // the rim wall based rendering does not work properly for shaped arenas, so
          // it's been replaced.

                BeginTriangles();
                for(int i=se_rimWalls.Len()-1;i>=0;i--){
                    eCoord p1=se_rimWalls(i)->EndPoint(0);
                    eCoord p2=se_rimWalls(i)->EndPoint(1);

                    glTexCoord2f(pos.x, pos.y);
                    glVertex3f  (pos.x, pos.y, h);

                    glTexCoord2f(p1.x, p1.y);
                    glVertex3f  (p1.x, p1.y, h);

                    glTexCoord2f(p2.x, p2.y);
                    glVertex3f  (p2.x, p2.y, h);
                }
                RenderEnd();
        */
        finite_xy_plane( pos, dir, h, eWallRim::GetBounds() );
    }
    else
    {
        if (!sr_infinityPlane)
            zero=.001;

        BeginTriangleFan();

        glTexCoord4f(pos.x-dir.x, pos.y-dir.y, h, 1);
        glVertex4f  (pos.x-dir.x, pos.y-dir.y, h, 1);

        glTexCoord4f(1,0.1,zero*h,zero);
        glVertex4f  (1,0.1,zero*h,zero);

        glTexCoord4f(0.1,1.1,zero*h,zero);
        glVertex4f  (0.1,1.1,zero*h,zero);

        glTexCoord4f(-1,0.1,zero*h,zero);
        glVertex4f  (-1,0.1,zero*h,zero);


        glTexCoord4f(0.1,-1.1,zero*h,zero);
        glVertex4f  (0.1,-1.1,zero*h,zero);

        glTexCoord4f(1,0.1,zero*h,zero);
        glVertex4f  (1,0.1,zero*h,zero);

        RenderEnd();
    }
}
Example #24
0
template< > inline void glTexCoord4< float >			(float s,float t,float r, float q )	{	glTexCoord4f(s,t,r,q);	};
Example #25
0
/////////////////////////////////////////////////////////
// Render
//
void GEMglTexCoord4f :: render(GemState *state) {
	glTexCoord4f (s, t, r, q);
}
Example #26
0
void Graph :: drawedges(bool forshade, double thick){
	
	double RADIUS = 0.008;
	double HALOSIZE = 1.2;
	
	
	if (forshade) {
		
	
		for (int e=0; e< edgelist.size(); e++) {
			
			//if (! edgelist.at(e)->getHighlight()) {
				
			
				glBegin(GL_QUADS);
				vec3d point1 = edgelist.at(e)->get_from()->getPos();
				vec3d point2 = edgelist.at(e)->get_to()->getPos();
				
				vec3d tang = point2 - point1;
				
							
				glNormal3f(tang.x, tang.y, tang.z);
				
				glTexCoord4f(-1.0*RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
				//glTexCoord3f(-1.0, alpha, thick); 
				glVertex3f(point1.x, point1.y, point1.z);
				
				glTexCoord4f(RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
				//glTexCoord3f(1.0, alpha, thick); 
				glVertex3f(point1.x, point1.y, point1.z);
				
				glNormal3f(tang.x, tang.y, tang.z);
				
				glTexCoord4f(RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
				//glTexCoord3f(1.0, alpha, thick); 
				glVertex3f(point2.x, point2.y, point2.z);
				
				glTexCoord4f(-1.0*RADIUS * HALOSIZE, RADIUS, 0.0, 0.0);
				//glTexCoord3f(-1.0, alpha, thick); 
				glVertex3f(point2.x, point2.y, point2.z);
				
				glEnd();
				
			//}
			
		}	
		
	}
	
	else {
		
		
		glLineWidth(thick);
		glBegin(GL_LINES);
		for (int e=0; e< edgelist.size(); e++) {
			
			//if (! edgelist.at(e)->getHighlight()) {
				vec3d point1 = edgelist.at(e)->get_from()->getPos();
				vec3d point2 = edgelist.at(e)->get_to()->getPos();
				glVertex3d(point1.x, point1.y, point1.z);
				glVertex3d(point2.x, point2.y, point2.z);
			//}
			
		}
		glEnd();
		
		linethick = thick;
		//redraw_n1_edges(thick);
		//redraw_n2_edges(thick);
	}

}
Example #27
0
void glTexCoord2f(GLfloat s,GLfloat t)
{
  glTexCoord4f(s,t,int2sll(0),int2sll(1));
}
Example #28
0
void glTexCoord2fv(float *v)
{
  glTexCoord4f(v[0],v[1],0,1);
}
Example #29
0
void glTexCoord2fv(GLfloat *v)
{
  glTexCoord4f(v[0],v[1],int2sll(0),int2sll(1));
}