LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: OpenGL Error 1282 + 1280  (Read 240 times)

Ostridge

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
OpenGL Error 1282 + 1280
« on: August 14, 2017, 14:00:21 »

Hello! I am using lwjgl 3 to make a game engine and im following a c++ tutorial and trying to convert it to java. I also have version OpenGL: 4.4.0 - Build 21.20.16.4550. I keep running into the OpenGL error 1280 while rendering my quads. I am trying to use textures and render them but im just getting a black screen. So after putting glGetError() in my code I found that I am also getting the OpenGL error 1282. My code where im getting the error and my shaders are below:

Code: [Select]
public void flush() {

for (int i = 0; i < m_TextureSlots.size(); i++) {
glActiveTexture(GL_TEXTURE + i); //<---- This is where I am getting the error 1282 from.
System.out.println(glGetError());
glBindTexture(GL_TEXTURE_2D, i);
}

glBindVertexArray(m_VAO);
m_IBO.bind();

glDrawElements(GL_TRIANGLES, m_IndexCount, GL_UNSIGNED_INT, 0);

m_IBO.unbind();
glBindVertexArray(0);

m_IndexCount = 0;
}

Code: [Select]
#version 330 core

layout (location = 0) out vec4 color;

uniform vec4 colour;
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.0 / 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);
//texColor = vec4(tid, 0, 0, 1);
}

color = texColor * intensity;
}

Code: [Select]
#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;
}

The glActiveTexture is what is giving me the 1282 error. I found that by stepping through my code. After that and its rendering i keep getting the 1280 error. I am not really sure whats causing either of those errors. Any help on where I should be looking or how to figure out what is causing it would be helpful.
Logged

Kai

  • Guest
Re: OpenGL Error 1282 + 1280
« Reply #1 on: August 14, 2017, 14:39:48 »

It is not glActiveTexture(GL_TEXTURE + i);
It is: glActiveTexture(GL_TEXTURE0 + i);

On top of that, if you want to find the source of your other OpenGL errors, please use LWJGLX/debug (follow the steps under "How").
Logged

Ostridge

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Re: OpenGL Error 1282 + 1280
« Reply #2 on: August 15, 2017, 09:57:49 »

I have fixed the 1280 error problem, but the same line of code is giving me the 1282 code. I have switched it to the GL_TEXTURE0. Any other ideas?

I also tried to run that debug jar and it kept giving me errors and wouldn't launch my program. Any help would be appreciated.
Logged

Kai

  • Guest
Re: OpenGL Error 1282 + 1280
« Reply #3 on: August 15, 2017, 11:11:47 »

Quote
I also tried to run that debug jar and it kept giving me errors and wouldn't launch my program.
That is exactly the whole point of the lwjglx-debug.jar. To unveil/uncover your errors in your code so that you can fix them.
It does not fix them by itself, though. That part is still left for you to do.

It'd also be nice of you if you could tell what error it is giving you. No one can help you when all you say is "it kept giving me errors".


EDIT:
Sorry, in case you saw this error:
Code: [Select]
Error occurred during initialization of VM
agent library failed to init: instrument
Failed to find Premain-Class manifest attribute in lib/lwjglx-debug-1.0.0.jar
there was an error in the build process in case you downloaded it on the lwjgl.org/download site.
Please re-download and that error should be resolved now.

Also, please run your program with the lwjglx-debug-1.0.0.jar in the following way:
  -javaagent:lwjglx-debug-1.0.0.jar=t;o=trace.log
and attach the produced trace.log file to this thread.

Quote
but the same line of code is giving me the 1282 code.
According to this documentation, glActiveTexture cannot produce the 1282 (invalid operation) error. It must be a GL call before that which produced it. But please re-download the lwjglx-debug thingy and try again. It should output the offending line.
Logged