Results 1 to 7 of 7

Thread: OpenGL 3.0 and texture

  1. #1
    Member Contributor
    Join Date
    Oct 2007
    Location
    persia,tabriz
    Posts
    71

    OpenGL 3.0 and texture

    hi

    working with textures in OpenGL3.x is like as other versions of OpenGL (for example 2.1,2.0)???

    i know this is like as silly question, but i read a documention in the web (about 1 mounth ago) which writes
    working with textures is not like in the other version and u dosnet need to use glEnable(GL_TEXTURE_ ...

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,651

    Re: OpenGL 3.0 and texture

    Creating and populating the textures is largely the same.

    It's when you go to use the textures things differ, if you are using shaders. You still bind textures to texture units as before, but instead of telling the hardware how to generate the shader (e.g.:

    Code :
    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    this being one small piece of the "shader" logic), you write the shader yourself, give it to the driver, and then bind it to make it active. Your shader is coded with the logic to sample specific texture units and combine them in some way you find useful.

  3. #3
    V-man
    Guest

    Re: OpenGL 3.0 and texture

    That is correct, when using shaders, you don't need to enable (glEnable(GL_TEXTURE_2D))
    It has been this way since shaders were first introduced, which was even before GL 2.0

    I recommend reading the Wiki

    http://www.opengl.org/wiki/GLSL_:_common_mistakes

  4. #4
    Member Contributor
    Join Date
    Oct 2007
    Location
    persia,tabriz
    Posts
    71

    Re: OpenGL 3.0 and texture

    eemmmmmmmmmmmmmmmm

    activing all texture unit in OGL 3.x or 2.x with using of shaders can hit program performance.

    for example in my game engine, i want to active all texture units in start up render rather than activing them in every frame or evey bind.

  5. #5
    Member Contributor
    Join Date
    Oct 2007
    Location
    persia,tabriz
    Posts
    71

    Re: OpenGL 3.0 and texture

    this is my shader program for basic texturing, why it dosent work?

    vertex :
    Code :
    #version 150
    in vec3 in_Position;
    in vec2 in_TexCoord;    
    out vec2 texcoord;
    void main(void)
    {
     
       gl_Position = vec4(in_Position, 1.0);
       texcoord = in_TexCoord;
    }

    fragment:
    Code :
    #version 150 core   
    in vec2 texcoord;
    out vec4 out_Color;
    uniform sampler2D Tex1;
    void main(void)
    {
    out_Color = texture2D(Tex1,texcoord);
    }

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,651

    Re: OpenGL 3.0 and texture

    Quote Originally Posted by Pswin
    this is my shader program for basic texturing, why it dosent work?
    Well, without seeing the whole program, could be anything. But the one thing that looks a little fishy in your shader is that you're using the position vertex attribute directly as your vertex shader output position:

    vertex :
    Code :
    ...
    gl_Position = vec4(in_Position, 1.0);
    ...
    It's not that it "can't" work (if you feed the right clip-space vertex attribute positions in), but typically you'll feed in object-space vertex positions and then see this multiplied by ModelViewProjection in the vertex shader.

    Regardless, there may be problem(s) in your C++ code though, particularly if the above is what you meant to do.

  7. #7
    Member Contributor
    Join Date
    Oct 2007
    Location
    persia,tabriz
    Posts
    71

    Re: OpenGL 3.0 and texture

    hi

    i found problem, texture is not created successfully, becase i bind texture after setting target params. target prams must be seted after binding texture

Similar Threads

  1. OpenGL second Texture is not showing up (OpenGL Texture Unit).
    By Haiiro no Jiren in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 01-18-2018, 07:17 AM
  2. OpenGL texture flickering when rendering only parts of texture
    By wrymnn in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-30-2015, 02:01 PM
  3. Texture on SDL- OpenGL
    By XaBerr in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-07-2013, 12:37 PM
  4. OpenGL 4.2, How to Copy a color texture into a depth texture ?
    By imported_cippyboy in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-26-2013, 01:17 AM
  5. float texture: OpenGL vs OpenGL ES
    By rldivide in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-10-2012, 02:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean