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

  • SEARCH
  • Home
  • 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 7037719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:34:44+00:00 2026-05-28T01:34:44+00:00

I am learning about 3D programming with the book Learning Modern 3D Graphics Programming

  • 0

I am learning about 3D programming with the book Learning Modern 3D Graphics Programming, but I am having no luck with the shaders and GLES 2.0 in iOS. I am working from the xcode 4 opengl game template, though with changes to make sense to the first example in the book.

The first shaders in the book will not compile with lots of different errors. The first vertex shader

#version 330

layout(location = 0) in vec4 position;
void main()
{
    gl_Position = position;
}

Complains about the version statement and refuses to allow using layout as a specifier. I finally managed to get this to build.

attribute vec4 position;
void main()
{
    gl_Position = position;
}

Again the first fragment shader refuses to build due to the version, and will not allow the output in a global segment

#version 330
out vec4 outputColor;
void main()
{
   outputColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);
}

With the error

ERROR: 0:10: Invalid qualifiers 'out' in global variable context

Okay so I managed to get the first example ( a simple triangle) to work with the following shaders.

vertex shader

#version 100
void main()
{
    gl_FragColor = vec4(1.0,1.0,1.0,1.0);
}

fragment shader

attribute vec4 position;
void main()
{
    gl_Position = position;
}

So those worked and I tried the first coloured example in the next chapter.

#version 330
out vec4 outputColor;
void main() {
    float lerpValue = gl_FragCoord.y / 500.0f;
    outputColor = mix(vec4(1.0f, 1.0f, 1.0f, 1.0f),
        vec4(0.2f, 0.2f, 0.2f, 1.0f), lerpValue);
}

Even working around the fixed problems from eariler, the version, f’s in floats not being allowed, The shader still refuses to build with this error

ERROR: 0:13: 'float' : declaration must include a precision qualifier for type

Effectively it is complaining about float.

I have tried googling to find an explanation of the differences, but none of these come up. I have also read through the apple docs looking for advice and found no help. I am not sure where else to look, or what I am really doing wrong.

  • 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-05-28T01:34:45+00:00Added an answer on May 28, 2026 at 1:34 am

    add this at the top of the shader: precision mediump float;

    or precision highp float;

    depends on your needs.

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

Sidebar

Related Questions

I'm learning DirectX from a book about game programming, and it uses the following
Having spent a bit of time learning about functional programming, it's becoming more and
I'm reading my Programming Languages book, learning somethings about parameters passing, and a doubt
I'm learning MIPS Assembly by the book MIPS Assembly Language Programming , but my
I'm learning about Win32 programming, and the WinMain prototype looks like: int WINAPI WinMain
I've just been learning about master pages in ASP.NET 2.0. They sound great, but
I have been learning about the basics of C# but haven't come across a
I am taking a principals of programming class right now. We are learning about
I am learning about GLSL in order to manage it in my IOS &
So i'm green as grass and learning programming from How to think like a

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.