Sign in to follow this  
nickme

opentk:texcoord1 cant produces colors.

Recommended Posts

hi

 

i wrote a program that uses texture1d as palette for my fractals.  when i use the GL.Color4(), it show the desired image, but when i use texcoord1(), it just show a black screen.  here is a snippet of code that show where my codes to draw to the window.  

 

the bmp file that the loaded as a palette was called somewhere else.  the textureid was past to this class by program.cs.

 

 

 
        private void setColor(double c)
        {
            if (c >= 0.9)
                GL.Color4(1.0, 0.0, 0.0, 1.0);
            else if (c >= 0.8)
                GL.Color4(0.0, 1.0, 1.0, 1.0);
            else if (c >= 0.70)
                GL.Color4(1.0, 1.0, 0.0, 1.0);
            else if (c >= 0.50)
                GL.Color4(1.0, 0.0, 1.0, 1.0);
            else if (c >= 0.4)
                GL.Color4(0.0, 0.0, 1.0, 1.0);
            else if (c >= 0.30)
                GL.Color4(0.0, 1.0, 0.0, 1.0);
            else if (c >= 0.2)
                GL.Color4(0.0, 0.0, 0.0, 1.0);
            else 
                GL.Color4(1.0, 1.0, 1.0, 1.0); 
        }
 
        private void plotDot(double x, double y, int c)
        {
            GL.Begin(BeginMode.Points);
                GL.TexCoord1((double)c / (double)maxIter);
//                setColor((double) c / (double) maxIter);
                GL.Vertex2(cx(x), cy(y));
            GL.End();
 
        }
 
        int compute(double x, double y)
        {
            if (func == function.julia)
                return Julia(x, y);
            return Mandelbrot(x, y);
        }
 
        public void display_fractal(int ID)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.ClearColor(Color4.Gold);
 
            GL.Disable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Texture1D);
            GL.BindTexture(TextureTarget.Texture1D, ID);
            for (double y = b; y <= t; y += deltay)
            {
                for (double x = lMsX; x <= r + sX; x += deltax)
                {
                    plotDot(x, y, compute(x, y));
                }
            }
            GL.BindTexture(TextureTarget.Texture1D, 0);
            GL.Disable(EnableCap.Texture1D);
        }
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this