Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:06:08+00:00 2026-06-07T06:06:08+00:00

I’m having some GLSL problems. When I just use normal VBO’s without the shaders,

  • 0

I’m having some GLSL problems. When I just use normal VBO’s without the shaders, everything shows up on screen as expected, and I can move around.

As soon as I link the shader, it’s like it ‘freezes’, draws once, and does not refresh. I checked and the update and render frames are executing as they should be (did a messagebox output check to make sure that it was reaching the code).

I’m thinking it has to be something to do with the matrixes, but I dont know what it is

Here is what I have:

Shader Creation:

private int vertShadHandle, fragShadHandle;
    private int shadProgHandle;

    private void ShaderCreate()
    {
        string vertShadeSource, fragShadeSource, vertcontent,fragcontent;

        vertcontent = System.IO.File.ReadAllText(@"resources/shaders/vertcoordshader.glsl");
        fragcontent = System.IO.File.ReadAllText(@"resources/shaders/fragcoordshader.glsl");


        vertShadeSource = "resources/shaders/vertcoordshader.glsl";
        fragShadeSource = "resources/shaders/fragcoordshader.glsl";


        Console.WriteLine("\nvertex shader path:" + System.IO.File.Exists("/resources/shaders/vertcoordshader.glsl"));
        Console.WriteLine("frag shader path:" + System.IO.File.Exists("/resources/shaders/fragcoordshader.glsl\n"));

        vertShadHandle= GL.CreateShader(ShaderType.VertexShader);  //connect the handles to created shaders
        fragShadHandle = GL.CreateShader(ShaderType.FragmentShader);

        shadProgHandle = GL.CreateProgram();  //create shader program

        GL.ShaderSource(vertShadHandle,vertcontent); //attach file to the shader handle
        GL.ShaderSource(fragShadHandle,fragcontent);

        GL.CompileShader(vertShadHandle); //compile the shaders
        GL.CompileShader(fragShadHandle);

        Console.WriteLine("\n" + GL.GetShaderInfoLog(vertShadHandle) + "\n");
        Console.WriteLine("\n" + GL.GetShaderInfoLog(fragShadHandle) + "\n");

        GL.AttachShader(shadProgHandle, vertShadHandle); //attach the shader to the program created
        GL.AttachShader(shadProgHandle, fragShadHandle);

        //BindAttributes go here (optional)


        GL.BindAttribLocation(shadProgHandle,0,"a_Vertex");
        GL.BindAttribLocation(shadProgHandle, 1, "a_Color");

        GL.UniformMatrix4(GL.GetUniformLocation(shadProgHandle,"MVP"), false, ref MVP);

        GL.LinkProgram(shadProgHandle); //sanity check on the created shader program, links it

        Console.WriteLine("\n"+ GL.GetProgramInfoLog(shadProgHandle) +"\n");

        GL.DeleteShader(vertShadHandle);
        GL.DeleteShader(fragShadHandle);

    }

Update Frame:

 protected override void OnUpdateFrame(FrameEventArgs e)
    {


        const float PIE = 3.141592654f;

        gamePad = XNA.GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);

        camAngle.Y += gamePad.ThumbSticks.Right.X * (float)e.Time * 180;
        camAngle.X += gamePad.ThumbSticks.Right.Y * (float)e.Time * 180;

        Vector2 RadAng = new Vector2();

        RadAng.X = (camAngle.X / 180 * PIE);
        RadAng.Y = (camAngle.Y / 180 * PIE);


        if (gamePad.ThumbSticks.Left.Y > 0)
        {
            camCoord.X -= (float)(Math.Sin(RadAng.Y) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
            camCoord.Z += (float)(Math.Cos(RadAng.Y) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
            camCoord.Y += (float)(Math.Sin(RadAng.X) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
        }
        if (gamePad.ThumbSticks.Left.Y < 0)
        {
            camCoord.X -= (float)(Math.Sin(RadAng.Y) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
            camCoord.Z += (float)(Math.Cos(RadAng.Y) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
            camCoord.Y += (float)(Math.Sin(RadAng.X) * gamePad.ThumbSticks.Left.Y) * (float)(e.Time);
        }
        if (gamePad.ThumbSticks.Left.X > 0)
        {
            camCoord.X -= (float)(Math.Cos(RadAng.Y) * gamePad.ThumbSticks.Left.X) * (float)(e.Time);
            camCoord.Z -= (float)(Math.Sin(RadAng.Y) * gamePad.ThumbSticks.Left.X) * (float)(e.Time);
        }
        if (gamePad.ThumbSticks.Left.X < 0)
        {
            camCoord.X -= (float)(Math.Cos(RadAng.Y) * gamePad.ThumbSticks.Left.X) * (float)(e.Time);
            camCoord.Z -= (float)(Math.Sin(RadAng.Y) * gamePad.ThumbSticks.Left.X) * (float)(e.Time);
        }

        //camCoord.X -= (float)(Math.Sin(RadAng.Y));
        //camCoord.Z += (float)(Math.Cos(RadAng.Y));
        //camCoord.Y += (float)(Math.Sin(RadAng.X));

        if (camAngle.X > 89)
        {
            camAngle.X = 89;
        }
        if (camAngle.X < -89)
        {
            camAngle.X = -89;
        }

        if (camAngle.Y > 360)
        {
            camAngle.Y -= 360;
        }
        else if (camAngle.Y < 0)
        {
            camAngle.Y += 360;
        }

        CameraMatrix();
        MVP = Matrix4.Mult(camMatrix, perspectivematrix);
    }

Camera Function:

public Matrix4 MVP = new Matrix4();
    public Matrix4 camMatrix = new Matrix4();
    private void CameraMatrix()
    {
        camMatrix = Matrix4.Identity;
        camMatrix = Matrix4.CreateRotationX(camAngle.X);
        camMatrix = Matrix4.CreateRotationY(camAngle.Y);
        camMatrix = Matrix4.CreateTranslation(camCoord);
        //GL.Rotate(camAngle.X, 1, 0, 0);
        //GL.Rotate(camAngle.Y, 0, 1, 0);
        //GL.Translate(camCoord);
    }

Render Frame:

protected override void OnRenderFrame(FrameEventArgs e)
    {

        //Qfont display debug info



        GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);


        coordSys.Draw(ref shadProgHandle);

        GL.PushAttrib(AttribMask.ColorBufferBit);


        int qFontLine = 0;
        QFont.Begin();
        InfFont.Print("FPS: " + Math.Round(RenderFrequency, 2), new Vector2(0, 0));
        ++qFontLine;
        InfFont.Print(new String('\n', ++qFontLine) + "X: " + -Math.Round(camCoord.X, 2));
        InfFont.Print(new String('\n', ++qFontLine) + "Y: " + -Math.Round(camCoord.Y, 2));
        InfFont.Print(new String('\n', ++qFontLine) + "Z: " + -Math.Round(camCoord.Z, 2));
        ++qFontLine;
        InfFont.Print(new String('\n', ++qFontLine) + "H-Angle: " + -Math.Round(camAngle.Y, 2));
        InfFont.Print(new String('\n', ++qFontLine) + "V-Angle: " + -Math.Round(camAngle.X, 2));
        ++qFontLine;
        InfFont.Print(new String('\n', ++qFontLine) + "Thumbsticks: ");
        InfFont.Print(new String('\n', ++qFontLine) + "Left.X : " + Math.Round(gamePad.ThumbSticks.Left.X,2));
        InfFont.Print(new String('\n', ++qFontLine) + "Left.Y : " + Math.Round(gamePad.ThumbSticks.Left.Y,2));
        InfFont.Print(new String('\n', ++qFontLine) + "Right.X: " + Math.Round(gamePad.ThumbSticks.Right.X,2));
        InfFont.Print(new String('\n', ++qFontLine) + "Right.X: " + Math.Round(gamePad.ThumbSticks.Right.Y,2));
        QFont.End();

        GL.PopAttrib();

        SwapBuffers();
    }

The Drawing command

GL.UseProgram(ShaderProgramHandle);


 GL.EnableVertexAttribArray(0);
        GL.EnableVertexAttribArray(1);

        GL.BindBuffer(BufferTarget.ArrayBuffer, _VBO[1]);
        GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 0, 0);

        GL.BindBuffer(BufferTarget.ArrayBuffer, _VBO[0]);
        GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);



        GL.DrawArrays(BeginMode.Lines, 0, 6);


        GL.DisableVertexAttribArray(0);
        GL.DisableVertexAttribArray(1);

and finally, the vertex and frag shaders respectively:

    #version 330

in vec3 a_Vertex;
in vec3 a_Color;

uniform mat4 MVP;

out vec3 color;

void main()
{

    gl_Position = vec4(a_Vertex,1.0);// * MVP;

    color = a_Color;
}

    #version 330

in vec3 color;
out vec4 outColor;

void main()
{
    outColor = vec4(1,1,1,1.0); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:06:09+00:00Added an answer on June 7, 2026 at 6:06 am

    I’ve figured it out. I changed the vertex shader to say

    gl_Position = gl_ModelViewProjectionMatrix * vec4(a_Vertex,1.0);

    which I didn’t know existed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.