OpenGL programming, Nvidia error

Soldato
Joined
8 Jan 2012
Posts
2,802
So my game engine throws an exception of,

Exception thrown at 0x5DCD92B3 (nvoglv32.dll) in Engine-Core.exe: 0xC0000005: Access violation reading location 0x00000000.

which is great, it also shows up a "Nvoglv32.pdb" not loaded message so I can't debug through the Nvidia DLL that the error relates to.

As far as I have been able to figure out the issue relates to me attempting to set the colour/texture of a sprite within my fragment shader. I was following some tutorials on youtube on how to do it and the person who made the tutorials had no such error when he wrote the code.

Heres my fragment/vertex shader,

Code:
#version 330 core

layout (location = 0) out vec4 color;



uniform vec4 col;
uniform vec2 light_pos;

in DATA
{
	vec4 position;
	vec2 uv;
	float tid;
	vec4 color;
} fs_in;

uniform sampler2D textures[32];

void main()
{
	float intensity = 1.0f / length(fs_in.position.xy - light_pos);
	vec4 texColor = fs_in.color;
	if(fs_in.tid > 0.0)
	{
		int tid = int(fs_in.tid + 0.5);
		texColor = texture(textures[tid], fs_in.uv);
	}

	color = texColor  * intensity;
}

And my vertex shader,

Code:
#version 330 core

layout (location = 0) in vec4 position;
layout (location = 1) in vec2 uv;
layout (location = 2) in float tid;
layout (location = 3) in vec4 color;

uniform mat4 pr_matrix;
uniform mat4 vw_matrix = mat4(1.0);
uniform mat4 ml_matrix = mat4(1.0);

out DATA
{
	vec4 position;
	vec2 uv;
	float tid;
	vec4 color;

} vs_out;


void main()
{
	gl_Position = pr_matrix * vw_matrix * ml_matrix * position;
	vs_out.position = ml_matrix * position;
	vs_out.uv = uv;
	vs_out.tid = tid;
	vs_out.color = color;
}

I'm using a batchrenderer to draw the sprites that sets up the texture IDs/sampler stuff for the shaders.

Any suggestions would be greatly appreciated as I haven't been able to find any answers on the web other then possible "glDrawElement" call issues which this is definitely not an error from that.
 
Well have you allocated and bound your buffers correctly, copied the uniforms etc? Whenever I do an OpenGL operation I like to check the status after to make sure it's correct and worked i.e. after uploading a shader, then compiling. Are you not doing that? Saves headaches. It's probably something in the setup and then when you call the shader, it fails.
 
As an aside out of interest what happens here:

"float intensity = 1.0f / length(fs_in.position.xy - light_pos);" if length is 0 ?

(Aware its a float but not sure how division by zero is handled in the context of a shader).
 
Last edited:
Well have you allocated and bound your buffers correctly, copied the uniforms etc? Whenever I do an OpenGL operation I like to check the status after to make sure it's correct and worked i.e. after uploading a shader, then compiling. Are you not doing that? Saves headaches. It's probably something in the setup and then when you call the shader, it fails.

Rendering prior to attempting to setup batch texturing via my renderer works fine. And nothing insofar as that has changed so to speak. And I haven't been checking errors unfortunately on every operation. :/
 
As an aside out of interest what happens here:

"float intensity = 1.0f / length(fs_in.position.xy - light_pos);" if length is 0 ?

(Aware its a float but not sure how division by zero is handled in the context of a shader).

I'd imagine that the light wouldn't work. Nothing too major. :p
 
textures[tid] from "texColor = texture(textures[tid], fs_in.uv);" - have you checked tid is actually valid for every access?
 
textures[tid] from "texColor = texture(textures[tid], fs_in.uv);" - have you checked tid is actually valid for every access?

As far as I can see, it is 1.0f though tid supposedly expects a const int. But I'm unsure on that. Thats mainly because I only have the one texture currently. It also does it if I use texColor = vec4(tid, 0, 0, 0); where tid is 1. Which should work? I really wish I could find the nvoglv32.pdb file for the debugging symbols but it seems like a red herring to me.
 
Okay, so I attempted to use Nsight last night to no particular avail. It decided that it couldnt start a session or something. However, I made it so that my main program spawns one sprite and I manually colour it. It happily does this. Meaning my uniforms, and rendering/drawcalls etc. A okay. I attempted to do the same thing using tid as the value for red to colour the sprite. Program loses its mind. Comes up with an "Out of frame" error.

Logically speaking, this points me towards the fact something is up with the value in tid?

However, the value in tid seems fine. The textures are properly setup for use in a sampler. so I'm a bit at a loss. :/
 
Last edited:
Back
Top Bottom