Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. help in building a color lookup table

help in building a color lookup table

Scheduled Pinned Locked Moved Graphics
graphicsgame-devdata-structureshelpquestion
13 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M mesho

    i used i/255 to compute the red value,i didn't test my program yet but my question was is this enough to build the lookup table or I should use some gl commands to enable the index color mode?? can i use now glindex()?? thanks

    T Offline
    T Offline
    Tim Craig
    wrote on last edited by
    #4

    I never used Glut when I was playing with OpenGL but it appears like if you're in color index mode that should setup the table. There might even be a default table already there. I'm not sure why you're maintaining the array of colors, when you can access Glut's color table once you've set it. You're trying to setup up the table with green a constant zero. Red varying linearly from zero to one and blue being one minus red. However, the reason I asked you to think about what i/255 evaluates to means that's not what you're going to get. Your color table will be considerably more boring.

    "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

    I'm a proud denizen of the Real Soapbox[^]
    ACCEPT NO SUBSTITUTES!!!

    M 1 Reply Last reply
    0
    • T Tim Craig

      I never used Glut when I was playing with OpenGL but it appears like if you're in color index mode that should setup the table. There might even be a default table already there. I'm not sure why you're maintaining the array of colors, when you can access Glut's color table once you've set it. You're trying to setup up the table with green a constant zero. Red varying linearly from zero to one and blue being one minus red. However, the reason I asked you to think about what i/255 evaluates to means that's not what you're going to get. Your color table will be considerably more boring.

      "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

      I'm a proud denizen of the Real Soapbox[^]
      ACCEPT NO SUBSTITUTES!!!

      M Offline
      M Offline
      mesho
      wrote on last edited by
      #5

      thanks, i solved the problem of th table but i have another question pls i implement this function to render the face normal of the mesh but when i debug i found that the program doesn't enter the loop at all and i get this in the watch of the debug when i type i: i CXX0017: Error: symbol "i" not found inline void CMesh::RenderFaceNormals() { float t=0.5; CVector v0,v1; for(int i=0 ; iget_v0()]->get_gp()+ verts[faces[i]->get_v1()]->get_gp()+ verts[faces[i]->get_v2()]->get_gp() )/3; v1 = t * faces[i]->get_normal(); glBegin(GL_LINES); glVertex3f(v0.X(), v0.Y(), v0.Z()); // origin of the line glVertex3f(v1.X(), v1.Y(), v1.Z()); // ending point of the line glEnd(); } } it seems that my program doesn't see i?? can anyone help me?? :((

      T 1 Reply Last reply
      0
      • M mesho

        thanks, i solved the problem of th table but i have another question pls i implement this function to render the face normal of the mesh but when i debug i found that the program doesn't enter the loop at all and i get this in the watch of the debug when i type i: i CXX0017: Error: symbol "i" not found inline void CMesh::RenderFaceNormals() { float t=0.5; CVector v0,v1; for(int i=0 ; iget_v0()]->get_gp()+ verts[faces[i]->get_v1()]->get_gp()+ verts[faces[i]->get_v2()]->get_gp() )/3; v1 = t * faces[i]->get_normal(); glBegin(GL_LINES); glVertex3f(v0.X(), v0.Y(), v0.Z()); // origin of the line glVertex3f(v1.X(), v1.Y(), v1.Z()); // ending point of the line glEnd(); } } it seems that my program doesn't see i?? can anyone help me?? :((

        T Offline
        T Offline
        Tim Craig
        wrote on last edited by
        #6

        As written above, I'm not sure how this compiled. Your for loop is malformed by missing the closing parenthesis at the very least and the second semicolon.

        "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

        I'm a proud denizen of the Real Soapbox[^]
        ACCEPT NO SUBSTITUTES!!!

        M 1 Reply Last reply
        0
        • T Tim Craig

          As written above, I'm not sure how this compiled. Your for loop is malformed by missing the closing parenthesis at the very least and the second semicolon.

          "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

          I'm a proud denizen of the Real Soapbox[^]
          ACCEPT NO SUBSTITUTES!!!

          M Offline
          M Offline
          mesho
          wrote on last edited by
          #7

          No i'm sure there is no syntax errors, the error in the loop header only appear when i copy from my program anyone have solutions for my problem???? inline void CMesh::RenderFaceNormals() { float t=0.5; CVector v0,v1; for(int i=0 ; i< get_numOfFaces() ;i++) { v0 = (verts[faces[i]->get_v0()]->get_gp()+ verts[faces[i]->get_v1()]->get_gp()+ verts[faces[i]->get_v2()]->get_gp() )/3; v1 = t * faces[i]->get_normal(); glBegin(GL_LINES); glVertex3f(v0.X(), v0.Y(), v0.Z()); // origin of the line glVertex3f(v1.X(), v1.Y(), v1.Z()); // ending point of the line glEnd(); } }

          T 1 Reply Last reply
          0
          • M mesho

            No i'm sure there is no syntax errors, the error in the loop header only appear when i copy from my program anyone have solutions for my problem???? inline void CMesh::RenderFaceNormals() { float t=0.5; CVector v0,v1; for(int i=0 ; i< get_numOfFaces() ;i++) { v0 = (verts[faces[i]->get_v0()]->get_gp()+ verts[faces[i]->get_v1()]->get_gp()+ verts[faces[i]->get_v2()]->get_gp() )/3; v1 = t * faces[i]->get_normal(); glBegin(GL_LINES); glVertex3f(v0.X(), v0.Y(), v0.Z()); // origin of the line glVertex3f(v1.X(), v1.Y(), v1.Z()); // ending point of the line glEnd(); } }

            T Offline
            T Offline
            Tim Craig
            wrote on last edited by
            #8

            What compiler and version are you using?

            "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

            I'm a proud denizen of the Real Soapbox[^]
            ACCEPT NO SUBSTITUTES!!!

            M 1 Reply Last reply
            0
            • T Tim Craig

              What compiler and version are you using?

              "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

              I'm a proud denizen of the Real Soapbox[^]
              ACCEPT NO SUBSTITUTES!!!

              M Offline
              M Offline
              mesho
              wrote on last edited by
              #9

              Microsoft Visual Studio 2005

              T 1 Reply Last reply
              0
              • M mesho

                Microsoft Visual Studio 2005

                T Offline
                T Offline
                Tim Craig
                wrote on last edited by
                #10

                Then it should be ok with defining the loop variable inside the for header. But to determine if something else is causing a side effect, try this: int i; for (i = 0 ; whatever your condition was ; i++) { your stuff }

                "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

                I'm a proud denizen of the Real Soapbox[^]
                ACCEPT NO SUBSTITUTES!!!

                M 1 Reply Last reply
                0
                • T Tim Craig

                  Then it should be ok with defining the loop variable inside the for header. But to determine if something else is causing a side effect, try this: int i; for (i = 0 ; whatever your condition was ; i++) { your stuff }

                  "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

                  I'm a proud denizen of the Real Soapbox[^]
                  ACCEPT NO SUBSTITUTES!!!

                  M Offline
                  M Offline
                  mesho
                  wrote on last edited by
                  #11

                  Thanks Tim very much for ur help i solve the problem, the problem was that my project was in release mode so i changed it now to debuge mode and it works well i really appreciate your help:rose:

                  T L 2 Replies Last reply
                  0
                  • M mesho

                    Thanks Tim very much for ur help i solve the problem, the problem was that my project was in release mode so i changed it now to debuge mode and it works well i really appreciate your help:rose:

                    T Offline
                    T Offline
                    Tim Craig
                    wrote on last edited by
                    #12

                    I'm not sure how switching to debug compile from release "fixes" the problem. Usually then that happens, you have a problem with unitialized memory that debug mode automatically sets to zero or you're using something like an assert macro that is compiled out in release mode and leaves a hole in your code but lets debug mode work.

                    "Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke

                    I'm a proud denizen of the Real Soapbox[^]
                    ACCEPT NO SUBSTITUTES!!!

                    1 Reply Last reply
                    0
                    • M mesho

                      Thanks Tim very much for ur help i solve the problem, the problem was that my project was in release mode so i changed it now to debuge mode and it works well i really appreciate your help:rose:

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #13

                      Hi, if the release build also works well, then you can claim you solved the problem. if not, you just closed your eyes. switching to debug mode does not solve anything that turning off the computer would not solve. if you need some advice on fixing release problems, read Debugging Release Mode Problems[^] and this[^]. :)

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups