Hi,
I'm not sure what causes it unfortunately, but sometimes the GL state is messed up so 1-pixel lines are drawn as 2-pixels.
The problem can only occur with 255 alpha.
COpenGLDriver::draw2DLine calls setRenderStates2DMode(color.getAlpha() < 255, false, false);
If the first parameter (alpha) is true, the problem does not occur.
If it is false, then the problem can *sometimes* occur.
Sorry I can't provide an example to replicate it... drawing the line with 254 alpha is an acceptable workaround for now...
[fixed]OpenGL draw2DLine sometimes draws 2-pixel-thick line
I have had similar problems. When I have antialiasing disabled in device creation parameters lines are drawn like with 2 pixels. I have to disable antialiasing to each material manually to fix this. When antialiasing is enabled in device creation everything looks ok. Interesting it is that if I disable the antialiasing only to one of the materials - it desn't make any effect. I have to disable antialiasing to all nodes. I'll try to create an example today or tomorrow to reproduce this.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ah, could be that the line anti-aliasing (which does not require the multisampling of the device) is not properly disabled and state checked. Maybe your gfx card does handle lina anti-aliasing also different when multi-sampling is enabled, which could explain the better results when the device has AA enabled. I'll try to check all state changes, but the example would still help a lot.
Ok. I had free time so I made an example. Very simple one.
My application is more complex so I don't really now why and when this happens. The above code works corectly because of this lines:
the result is:
If I remove those lines or only one of them the result is:
If I remove this line:
then everything renders ok.
It also looks like "mat.Thickness = 5;" doesn't work. Makes no difference if it 0,1,2,3...
In my application I render to 4 different view ports and this happens only on one of them - the first one I render. It also happens when I render to only one viewport.
PS:The above results was on the computer here at work with a very old Radeon(9550) video. I tried to enable antialias to device creation and all materials. It also renders fine as it does home but the result is as if the video card desn't support antialiasing.
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
SIrrlichtCreationParameters params;
params.AntiAlias = 0;
params.Bits = 16;
params.Fullscreen = false;
params.WindowSize = dimension2d<u32>(640, 480);
params.DriverType = video::EDT_OPENGL;
IrrlichtDevice *device = createDeviceEx(params);
if (!device)
return 1;
device->setWindowCaption(L"OpenGL Lines Test");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh){
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
SMaterial mat;
mat.Thickness = 5;
mat.AntiAliasing = 0;
node->getMaterial(0).AntiAliasing = 0;
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
driver->draw3DBox(node->getBoundingBox(), SColor(0,255,0,0));
driver->setMaterial(mat);
driver->draw2DLine(position2di(10,10), position2di(100,100), SColor(255,0,0,0));
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
mat.AntiAliasing = 0;
node->getMaterial(0).AntiAliasing = 0;
If I remove those lines or only one of them the result is:
If I remove this line:
Code: Select all
driver->draw2DLine(position2di(10,10), position2di(100,100), SColor(255,0,0,0));
It also looks like "mat.Thickness = 5;" doesn't work. Makes no difference if it 0,1,2,3...
In my application I render to 4 different view ports and this happens only on one of them - the first one I render. It also happens when I render to only one viewport.
PS:The above results was on the computer here at work with a very old Radeon(9550) video. I tried to enable antialias to device creation and all materials. It also renders fine as it does home but the result is as if the video card desn't support antialiasing.
Thanks for the test case, I've added the bug to the tracker