• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Thiatsii

Help with Compilation Error: 0:2

9 posts in this topic

I hate to admit defeat at finding an answer to my problem, but after 6 hours of searching... I realize I better bite the bullet and ask those who know.

 

Background: I'm on Win7 64 using MSVS 2010 pro trying to compile Open GL source from Jorge Rodriquez' Math for Game Developers. Project compiles, windows pop up, disappear, and then spits out...

 

ERROR: 0:2: '' : Declaration must include a precision qualifier or the default precision must have been previously declared. 
ERROR:  compilation errors.  No code generated.  blink.png
 
Any help at all would be greatly appreciated. biggrin.png
0

Share this post


Link to post
Share on other sites
That's an error message from compiling a shader, not the program itself. And one I would expect from an OpenGL ES context, not from a plain OpenGL context. Can you post the shader that is causing this?
0

Share this post


Link to post
Share on other sites

the source is from github here. I tried looking through the files... but so far no luck.

 

All I see for reference is: #include <GL3/gl3w.h>

Edited by Thiatsii
0

Share this post


Link to post
Share on other sites

The line you are quoting appears to be C++ code. As Ohforf sake already said, the error message originates from GLSL though. At some point in your program glCompileShader is called  but fails and the error message you are seeing is retrieved with glGetShaderInfoLog. The problem you are seeing happens because something is wrong with the GLSL source which has been passed to that shader before using glShaderSource. Find out what kind of source has been passed and either fix it yourself or post it here. That should not be complicated to find out using the debugger. 

0

Share this post


Link to post
Share on other sites
That should not be complicated to find out using the debugger.

Seconded.

 

@OP: Here is a how-to (actually done without debugger, but using the debugger would have made investigations even easier; you should try it):

 

1.) With the hints given in above answers, you should be able to find the file within the C++ sources that is used to compile the shaders.

 

2.) If you investigate that CPP, you'll see that shader scripts are assembled into string variables. You'll see further that most of the shader scripts originates from the "content/shaders/" subfolder. Therein are 2 include files functions.si and header.si, a vertex shader pass.vs, and a fragment shader model.fs.

 

3.) Looking into the shader files, you'll see that there is a line "#version 130" which denotes the version of GLSL that the shader compiler should use.

 

4.) Looking at the error text, the keywords mentioned there are "precision" and "default qualifier", which both are missed.

 

5.) With this knowledge you visit www.opengl.org (or alternatively www.khronos.org) and navigate to the OpenGL specifications section. There you locate the GLSL specification that matches "#version 130", which you'll find as GLSLangSpec.Full.1.30.10.pdf. Download it, open it...

 

6.) ... and search for the keyword "precision". You'll find it explained in section 4.5 and especially 4.5.3 "Default Precision Qualifiers". At the end of that section you can read:

 

The vertex language has the following predeclared globally scoped default precision statements:

           precision highp float;
           precision highp int;

The fragment language has the following predeclared globally scoped default precision statement:

           precision mediump int;

The fragment language has no default precision qualifier for floating point types. Hence for float, floating point vector and matrix variable declarations, either the declaration must include a precision qualifier or the default float precision must have been previously declared. 

 

This leads to the conclusion that your fragment shader uses a float type but does not declare any precision for it.

 

7.) So ... going back to model.fs and see "yep, that's actually true".

 

8.) Correct the irregularity and try again.

 

 

Perhaps this isn't the actual solution, but anyway should demonstrate how to attack such a problem.

Edited by haegarr
1

Share this post


Link to post
Share on other sites

Thankyou Ohforf sake, haegarr and BitMaster. I actually managed to get to that page on khronos before I posted here, yet I was still baffled on where to look in the code. Your explanation though, got me right to the model.fs. This Open GL is an entirely different animal which I will have to acquaint myself with. I have to say that the last 2 months has been devoted entirely to DirectX. Yep... noob when it comes to graphics programming. I'm only redeemed in the realms of modeling and animation. Anyhow... this is the file, but I don't have a clue where to fix it. If it wasn't for the awesome video tutorials on math related to graphics programming, I would have thrown in the towel long ago.

[source]

uniform bool bDiffuse = false;

uniform sampler2D iDiffuse;
uniform vec4 vecColor = vec4(1.0, 1.0, 1.0, 1.0);
 
uniform vec3 vecSunlight;
 
uniform float flAlpha;
 
in vec3 vecFragmentPosition;
in vec2 vecFragmentTexCoord0;
in vec3 vecFragmentNormal;
in vec3 vecFragmentColor;
 
uniform mat4 mView;
uniform mat4 mGlobal;
 
void main()
{
// This 3x3 matrix should have the rotation components only. We need it to transform the fragment normals into world space.
mat3 mGlobal3x3 = mat3(mGlobal);
 
// Dot product of the sunlight vector and the normal vector of this surface
float flLightDot = dot(vecSunlight, normalize(mGlobal3x3*vecFragmentNormal));
 
// Remap the light values so that the negative result becomes positive
float flLight = RemapVal(flLightDot, -1.0, 0.0, 0.9, 0.4);
 
// Multiply that by the color to make a shadow
vec4 vecDiffuse = vecColor * flLight;
 
// Add in a diffuse if there is one
if (bDiffuse)
vecDiffuse *= texture(iDiffuse, vecFragmentTexCoord0);
 
// Use that as our output color
vecOutputColor = vecDiffuse;
 
if (vecDiffuse.a < 0.01)
discard;

}[/source]

Edited by Thiatsii
0

Share this post


Link to post
Share on other sites


... but was still baffled on where to look in the code ...

As BitMaster told, look for "glGetShaderInfoLog"; you can use a simple text search function for that. The term occurs in "renderer/shaders.cpp" two times, once for the vertex shader and once for the fragment shader, locates in the CShader::Compile routine. At the beginning of that routine you can see that files inside the "shaders/" sub-directory are opened, read in, and their content appended to string variables, which themselves are passed to the glShaderSource routines.

 


... but I don't have a clue where to fix it.

Well, from a compilers point of view and considering the quoted part of the specification, it should be fixed before the first occurrence of a float, float vector, or float matrix. So you can try and place the fix at the very beginning of the shader script, because already in the 2nd line there is a float vec4 declaration.

 

However, as told earlier, the source that is passed to the shader compiler seems to be assembled from various files. So the above solution (which considers only a single file) may or may not work. Hence the better way would be: Start your debugger, set a breakpoint where the fragment script's glShaderSource is invoked, and check how the entire script (as referred to by pszStr) looks like. Then decide where to place the fix.

0

Share this post


Link to post
Share on other sites

Thanks again for all the help. All I keep seeing is a ridiculous amount of  f  ra   g me  nt ed  fr ag  men ts... and after 13 hours on this I'm just going to give up. Does code REALLY need to be diced into to so many pieces?  wacko.png This isn't even my code!

Edited by Thiatsii
0

Share this post


Link to post
Share on other sites

If that the source you posted is indeed the one causing the problems the important line should be:

uniform vec4 vecColor = vec4(1.0, 1.0, 1.0, 1.0);

Out of the top of my head, add a "#version 330" as the very first line and see if that fixes the problem. You might have to do that for every GLSL code used. Initializing a uniform with a default value was not allowed in GLSL from the start and unless you specify which version to use explicitly, the driver's compiler should use the very first GLSL version.

0

Share this post


Link to post
Share on other sites


add a "#version 330" as the very first line and see if that fixes the problem

 

Nada. Zip. Kaput. Thank you though.

Aside: I am in contact with the author and will post up what the result ends up being.

0

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  
Followers 0