Example #1
0
/////////////////////////////////////////////////////////
// startRendering
//
/////////////////////////////////////////////////////////
void pix_snap2tex :: startRendering(void)
{
  if(GLEW_VERSION_1_1) {
    glGenTextures(1, &m_textureObj);

    if(GLEW_VERSION_1_3) {
      glActiveTexture(GL_TEXTURE0_ARB + m_texUnit);
    }

    m_textureType = (m_rectangle?m_canRectangle:GL_TEXTURE_2D);

    glBindTexture(m_textureType, m_textureObj);
    setUpTextureState();
  } else {
    glGenTexturesEXT(1, &m_textureObj);
    glBindTextureEXT(m_textureType, m_textureObj);
    setUpTextureState();
  }
  if(GLEW_VERSION_1_3) {
    glActiveTexture(GL_TEXTURE0_ARB);
  }

  m_texWidth = m_texHeight = -1;
  m_init=true;

  if (!m_textureObj)	{
    error("Unable to allocate texture object");
    return;
  }
}
Example #2
0
int __glXDisp_GenTexturesEXT(__GLXclientState *cl, GLbyte *pc)
{
	GLsizei n;
	__GLXcontext *cx;
	ClientPtr client = cl->client;
	int error;
	GLuint answerBuffer[200];
	char *answer;

	cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
	if (!cx) {
		return error;
	}
	pc += __GLX_VENDPRIV_HDR_SIZE;
	n = *(GLsizei *)(pc + 0);

	__GLX_GET_ANSWER_BUFFER(answer,cl,n*4,4);
	glGenTexturesEXT( 
		*(GLsizei  *)(pc + 0),
		(GLuint   *) answer
	);
	__GLX_BEGIN_REPLY(n*4);
	__GLX_SEND_HEADER();
	__GLX_SEND_INT_ARRAY(n);
	return Success;
}
Example #3
0
void glGenTextures(GLsizei n, GLuint *textures)
{
#if 0 /* see comments above */
	__GLX_SINGLE_DECLARE_VARIABLES();
	xGLXSingleReply reply;
	__GLX_SINGLE_LOAD_VARIABLES();
	__GLX_SINGLE_BEGIN(X_GLsop_GenTextures,4);
	__GLX_SINGLE_PUT_LONG(0,n);
	__GLX_SINGLE_READ_XREPLY();
	__GLX_SINGLE_GET_LONG_ARRAY(textures,n);
	__GLX_SINGLE_END();
#else
        glGenTexturesEXT(n, textures);
#endif
}
Example #4
0
/////////////////////////////////////////////////////////
// startRendering
//
/////////////////////////////////////////////////////////
void pix_snap2tex :: startRendering()
{
  if(GLEW_VERSION_1_1) {
    glGenTextures(1, &m_textureObj);
    glBindTexture(m_textureType, m_textureObj);
    setUpTextureState();
  } else {
    glGenTexturesEXT(1, &m_textureObj);
    glBindTextureEXT(m_textureType, m_textureObj);    
    setUpTextureState();
  }

  m_oldWidth = m_oldHeight = m_texWidth = m_texHeight = -1;
  if (!m_textureObj)	{
    error("Unable to allocate texture object");
    return;
  }

}
Example #5
0
static void Init(void)
{

    doSphere = GL_FALSE;
    xRotation = 0.0;
    yRotation = 0.0;
    zTranslate = -3.125;

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    if (multTex && texObj) {
	int i;

	glGenTexturesEXT(NUM_TEXTURES, texNames);
	for (i = 1; i < NUM_TEXTURES; i++) {
	    glBindTextureEXT(GL_TEXTURE_2D, texNames[i]);
	    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, images[i]->sizeX,
			      images[i]->sizeY, GL_RGB, GL_UNSIGNED_BYTE,
			      images[i]->data);
	}
	glBindTextureEXT(GL_TEXTURE_2D, texNames[0]);
	glPrioritizeTexturesEXT(NUM_TEXTURES, texNames, texPriorities);
    }
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, images[0]->sizeX, images[0]->sizeY,
		      GL_RGB, GL_UNSIGNED_BYTE, images[0]->data);

    glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal);
    glEnable(GL_TEXTURE_2D);

    glFrontFace(GL_CCW);
    glCullFace(GL_FRONT);
    glEnable(GL_CULL_FACE);

    BuildLists();

    glClearColor(0.0, 0.0, 0.0, 0.0);

    magFilter = nr;
    minFilter = nr;
    sWrapMode = repeat;
    tWrapMode = repeat;
}
Example #6
0
static GLuint makeHalo( GLubyte *texbuf, int width )
{
    int texSize;
    GLuint texid;
    GLubyte *p;
    int i,j;
    double radius;

    // create a texture id
#ifdef GL_VERSION_1_1
    glGenTextures(1, &texid);
    glBindTexture(GL_TEXTURE_2D, texid);
#elif GL_EXT_texture_object
    glGenTexturesEXT(1, &texid);
    glBindTextureEXT(GL_TEXTURE_2D, texid);
#else
#   error port me
#endif

    glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;

    // create the actual texture contents
    texSize = width * width;

    if ( !texbuf ) {
        cout << "ouch ..." << endl;
        exit(-1);  // Ugly!
    }

    p = texbuf;

    radius = (double)(width / 2);

    GLubyte value;
    double x, y, d;
    for ( i = 0; i < width; i++ )
    {
        for ( j = 0; j < width; j++ )
        {
            x = fabs((double)(i - (width / 2)));
            y = fabs((double)(j - (width / 2)));
            d = sqrt((x * x) + (y * y));
            if (d < radius)
            {
                // t is 1.0 at center, 0.0 at edge
                double t = 1.0 - (d / radius);

                // inverse square looks nice
                value = (int)((double) 0xff * (t*t));
            }
            else
            {
                value = 0x00;
            }
            *p = value;
            *(p+1) = value;
            *(p+2) = value;
            p += 3;
        }
    }

    /* glTexImage2D( GL_TEXTURE_2D,
    	  0,
    	  GL_RGBA,
    	  width, width,
    	  0,
    	  GL_RGBA, GL_UNSIGNED_BYTE,
    	  texbuf ); */

    return texid;
}