vertex array with smoothness

  • vertex array with smoothness nkint

    I'm using vertex array to draw 2d geometry, but I can't achieve smoothness.

    This is the code I'm using:

    glColorPointer(4, GL_UNSIGNED_BYTE, 0, shared_colors);
    glVertexPointer(3, GL_FLOAT, 0, shared_vertex);
    glDrawArrays(GL_LINES, 0, shared_counter);

    Some advice?

  • Simply use glShadeModel(GL_SMOOTH) when you want to smooth out the colors between your primtitive's vertices. The initial value is GL_SMOOTH, so if you haven't changed it, you'll probably don't need to set it.

    If you want smooth lines, use glEnable(GL_LINE_SMOOTH).

  • Quite some time since i had the pleasure to play with opengl, but one thing comes to mind: Is it not necessary to specify the normals if you want your smooth shading?

c++ vertex-arrays
Related questions and answers
  • ); glDisableClientState( GL_COLOR_ARRAY ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } Back to the Vertex Array Object though. My code for creating the Vertex... ) return; glBindBuffer( GL_ARRAY_BUFFER, m_nVboId ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_nVboIdIndex ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); glVertexPointer( 3, GL_FLOAT, sizeof(CustomVertex), ((char*)NULL + 0) ); glTexCoordPointer(3, GL_FLOAT, sizeof

  • ); glEnableClientState(GL_VERTEX_ARRAY); // Point them to the objects arrays if (Objects[i].textured) glTexCoordPointer(2, GL_FLOAT, 0, Objects[i].TexCoords...); // Set The Color Of The Model ( NEW ) // ORIGINAL DRAWING CODE //Draw the model as an interpolation between the two frames glBegin(GL_TRIANGLES); for(int i = 0; i... ) glEnable (GL_BLEND); // Enable Blending ( NEW ) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // Set The Blend Mode ( NEW ) glPolygonMode (GL

  • (mats.mvHandle,1,GL_FALSE,glm::value_ptr(mats.modelViewMatrix)); //bind to vertex array object glBindVertexArray(vaoHandle); //render scene glDrawArrays(GL_TRIANGLES, 0, 240*3 ); //do post-processing if we have it enabled if(postFlag&&fboSetup) { glFlush(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgram(fboProgram); glClear(GL_COLOR_BUFFER_BIT); glBindTexture(GL...I'm trying to get a 2 pass post-processing system going in OpenGL in a cross-platform manor using FBOs. I'm starting the dev on mac OSX (since in the past I've found it the most finicky to get

  • I am making a game using OpenGL, with SDL_Image employed to load the textures. When drawn on screen, there's no alpha -- in an exact square around the opaque contents of the texture, black is drawn; outside that space, white is drawn. Here is my OpenGL init code... SDL_SetVideoMode(windowWidth, windowHeight, 16, SDL_HWSURFACE|SDL_GL_DOUBLEBUFFER|SDL_OPENGL); glClearColor(0, 0, 0, 0...); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLoadIdentity(); is my image loading function... SDL_Surface *loadImage (const char *filename, bool alpha = true) { SDL_Surface

  • I'm having problems drawing a simple sprite. When I draw: void CSprite2D::render() { CHECKGL(glLoadIdentity()); CHECKGL(glEnable(GL_TEXTURE_2D)); CHECKGL(glEnable(GL_BLEND)); CHECKGL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); m_texture->bind(); //CHECKGL(glPushMatrix()); CHECKGL(glBegin(GL_TRIANGLE_STRIP...(glVertex3i( m_position.x, m_position.y + m_dimensions.y,0)); CHECKGL(glEnd()); //CHECKGL(glPopMatrix()); CHECKGL(glDisable(GL_BLEND)); } I'm always get an GL_INVALID

  • (GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, 0, indices); glTexCoordPointer(2, GL_FLOAT, sizeof(float)*3, indices); glVertexPointer(3, GL...); vertices.push_back(pos[0]); vertices.push_back(pos[1]); vertices.push_back(pos[2]); } } glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, 0, &normals[0]); glTexCoordPointer(2, GL_FLOAT, 0, &textCoords[0

  • ); glBindFramebuffer(GL_FRAMEBUFFER, 0); } Here is my drawing box code, which just takes a transformation matrix and calls the appropriate functions. The current values of P is a projection matrix...() { ///////////////////////////////////////// // Render to FBO glClearColor(0, 0, 0.2f,0); glBindFramebuffer(GL_FRAMEBUFFER, fbo_id); glViewport(0, 0, m_FBOWidth, m_FBOHeight); glClear(GL_COLOR_BUFFER_BIT...(); ///////////////////////////////////////// // Render to Window glClearColor(0, 0, 0, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, screen_width, screen_height); glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT

  • ).getHeightImage(); int widthMap = 40 + offsetX/32; int heigthMap = 23; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glBindTexture( GL_TEXTURE_2D, ); for (int i = 0; i < heigthMap; i++) { int startX = offsetX/32..._FLOAT, 0, texVerts); glDrawArrays(GL_QUADS, 0, 4); startX++; } } glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE

  • ); glEnable(GL_BLEND); // enable read-only depth buffer glDepthMask(GL_FALSE); // set the blend function to what we use for transparency glBlendFunc(GL_SRC_ALPHA, GL_ONE); // set back to normal depth...i wanna walk to terrain... first i created the terrain void desenha_terreno(float px, float pz){ for (int z = 0; z < iwidth-1; z++) { glBegin(GL_TRIANGLE_STRIP); for (int x = 0; x < iheight-1; x++) { // for each vertex, we calculate the grayscale shade color, // we set the texture coordinate, and we draw the vertex. /* the vertices

Data information