Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 14

Thread: Colors on terrain, glcolorpointer ?

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    43

    Colors on terrain, glcolorpointer ?

    glcolorpointer doesn't work. i mean, it changes nothing on the tiles.. what is missing ?


    init loop :

    Code :
    keslan[z * TERRAIN_SIZE + x].x=x - TERRAIN_SIZE/2;
    			keslan[z * TERRAIN_SIZE + x].y=heightmap[z * TERRAIN_SIZE + x]  / SCALE_FACTOR ;
    			keslan[z * TERRAIN_SIZE + x].z=z - TERRAIN_SIZE/2;
    			keslan[z * TERRAIN_SIZE + x].u=(GLfloat)x/TERRAIN_SIZE*16;
    			keslan[z * TERRAIN_SIZE + x].v=(GLfloat)z/TERRAIN_SIZE*16;
    			keslan[z * TERRAIN_SIZE + x].r=0.5f + 0.5f * keslan[z * TERRAIN_SIZE + x].y / MAX_HEIGHT;
    			keslan[z * TERRAIN_SIZE + x].g=0.5f + 0.5f * keslan[z * TERRAIN_SIZE + x].y / MAX_HEIGHT;
    			keslan[z * TERRAIN_SIZE + x].b=0.5f + 0.5f * keslan[z * TERRAIN_SIZE + x].y / MAX_HEIGHT;
    			keslan[z * TERRAIN_SIZE + x].a=1.0f;



    draw code :

    Code :
    glBindBuffer(GL_ARRAY_BUFFER,m_vert);
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    	glEnableClientState(GL_COLOR_ARRAY);
    	glVertexPointer(3, GL_FLOAT, sizeof(vrt), NULL);
    	glTexCoordPointer(2,GL_FLOAT,sizeof(vrt),(char*)NULL + 12);
    	glColorPointer(4,GL_FLOAT,sizeof(vrt),(char*)NULL + 20);
    	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_ind);
    	glDrawElements(GL_TRIANGLE_STRIP,indices.size(),GL_UNSIGNED_INT,0);
    	glBindBuffer(GL_ARRAY_BUFFER,0);
    	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
    	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    	glDisableClientState(GL_VERTEX_ARRAY);
    	glDisableClientState(GL_COLOR_ARRAY);

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171
    I can't see anything wrong with the array setup code.
    How are you shading the terrain, where's the rest of the draw code and state?

  3. #3
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    43
    Code :
    void CGfxOpenGL::Render()
    {
    	glClearColor(0.0f, 0.0, 0.0, 0.0);
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    	glLoadIdentity();
    	gluLookAt(cameraX, cameraY, cameraZ, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
     
     
    	m_skybox.Render(cameraX, cameraY, cameraZ);
     
    	DrawTerrain();
    }

    drawterrain is the above one

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    381
    Are you using shaders, or the fixed function? If you are using shaders you will need to use gl_Color for colors to have any effect.

  5. #5
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    43
    shaders ? i don't think i use them. what do you mean by fixed function ?

  6. #6
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171
    I think we need to see what's inside DrawTerrain();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •