Color issues when using LineSegs and GeomPoints

Hi,

Adding a LineSegs in a scene that has a GeomPoints in it seems to switch the color format on the GeomPoints from RGBA to BGRA. I’m using Panda1.10.14, here’s some code to reproduce the issue, is this a bug or am I doing something wrong?

#include "pandaFramework.h"
#include "pandaSystem.h"
#include "load_prc_file.h"
#include "geomPoints.h"
#include "lineSegs.h"

int main()
{
	load_prc_file_data( "", "load-display pandagl\n\
								win-origin -2 -2\n\
								win-size 800 600\n\
								fullscreen #f\n\
								framebuffer-hardware #t\n\
								framebuffer-software #f\n\
								depth-bits 1\n\
								color-bits 1 1 1\n\
								alpha-bits 0\n\
								stencil-bits 0\n\
								multisamples 0\n\
								notify-level warning\n\
								default-directnotify-level warning" );

	PandaFramework framework;
	framework.open_framework();

	framework.set_window_title( "Dis be where I test panda" );
	PT(WindowFramework) window = framework.open_window();
	window->setup_trackball();
	window->enable_keyboard();
	PT(GeomVertexData) vData;
	vData = new GeomVertexData("data", GeomVertexFormat::get_v3c4(), Geom::UH_static);
	PT(GeomNode) geomNode = new GeomNode("RGB points");
	GeomVertexWriter vertexWriter(vData, "vertex");
	GeomVertexWriter colorWriter(vData, "color");
	vertexWriter.add_data3(0, 0, 0);
	colorWriter.add_data4(1.f, 0.f, 0.f, 1.f);
	vertexWriter.add_data3(1.f, 0, 0);
	colorWriter.add_data4(0.f, 1.f, 0.f, 1.f);
	vertexWriter.add_data3(2.f, 0, 0);
	colorWriter.add_data4(0.f, 0.f, 1.f, 1.f);

	PT(Geom) geom = new Geom(vData);
	PT(GeomPoints) prim = new GeomPoints(Geom::UH_static);
	prim->add_vertices(0,1,2);
	geom->add_primitive(prim);
	geomNode->add_geom(geom);

	auto pointsNP = window->get_render().attach_new_node(geomNode);

//Adding the following LineSegs makes the order of the points from left to right Blue Green Red instead of Red Green Blue
	LColor color(1, 1, 1, 1);
	LineSegs lines;
	lines.set_color(color);
	
	lines.move_to(LPoint3(0, 0, 1));
	lines.draw_to(LPoint3(1,0,1));
	lines.draw_to(LPoint3(2,0,1));
	
	PT(GeomNode) lineNode = lines.create();
	window->get_render().attach_new_node(lineNode);

	framework.main_loop();
	framework.close_framework();
}

EDIT:
I was kind of in a rush when making the post, I forgot to post screenshot of the scene with/without the LineSegs.
2024-12-05 08_35_36-Dis be where I test panda

2024-12-05 08_34_49-Dis be where I test panda
The only difference in the code between these two screenshots is that the line window->get_render().attach_new_node(lineNode); was commented in the first screenshot.

Hi,

Which video card do you have exactly?

I have an nvidia Quadro P620 and an Intel(R) UHD Graphics 630. I’m assuming that the nvidia one is being used, since I can see its memory go up a tiny bit when I launch the program and the computer is set to “performance” mode, but I’m not certain how to validate this.

The reason I ask is since I suspect a driver bug due to switching color formats. You can get information about the driver by setting notify-level-glgsg debug in Config.prc.

What you could do is switch from float color format to uint8 and see if the problem goes away.

You’re right, it is related to the driver! The problem is only present when I’m using the UHD Graphics 630, it goes away if I force the use of the NVDIA gpu.

Here’s some of the information I got when setting notify-level-glgsg debug:

:display:gsg:glgsg(debug): GL_RENDERER = Intel(R) UHD Graphics 630
:display:gsg:glgsg(debug): GL_VERSION = 4.6.0 - Build 31.0.101.2130
:display:gsg:glgsg(debug): GL_VERSION decoded to: 4.6
:display:gsg:glgsg(debug): GL_SHADING_LANGUAGE_VERSION = 4.60 - Build 31.0.101.2130
:display:gsg:glgsg(debug): Detected GLSL version: 4.60
:display:gsg:glgsg(debug): Using compatibility profile

To switch from float color to uint8, is simply using add_data4i() with regular int good enough? Or do I have to use something a bit lower level than the GeomVertexWriter? I have tried using add_data4i() and the problem did not go away.

Ah, hang on, you’re already using uint8 color. Maybe something else in Panda is enabling BGRA colors on some model. You can try this in Config.prc:

gl-support-vertex-array-bgra false