I am learning OpenGL these days, and I tried to compile the example code on the book(OpenGL SuperBible)
The code likes this: first use glEnable(GL_LINE_STIPPLE) to open the GL_LINE_STIPPLE, and then glLineStipple(2, (GLushort)0x00ff), last I draw some lines, but when executed, it just displayed the normal lines. (in Ubuntu)
However, I compiled the same code in windows, it worked!!
Why? Are there any different details between Windows and Linux?
#include <QtGui>
#include "GLWidget.h"
GLWidget::GLWidget(QWidget *parent)
: QGLWidget(parent)
{
setFormat(QGLFormat(QGL::DoubleBuffer));
}
GLWidget::~GLWidget()
{
}
void GLWidget::initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glEnable(GL_LINE_STIPPLE);
}
void GLWidget::resizeGL(int w, int h)
{
if(h == 0)
h = 1;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100, 100, -100, 100, -1, +1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
drawLine();
}
void GLWidget::drawLine()
{
GLint factor = 1;
GLushort pattern = 0x00ff;
glColor3f(1.0f, 1.0f, 1.0f);
for(GLfloat i = -90.0f; i < 90.0f; i += 20.0f)
{
glLineStipple(factor, pattern);
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex2f(-80.0f, i);
glVertex2f(+80.0f, i);
glEnd();
factor++;
}
}
I’ve seen from your comment answer to @Lefteris that you’re using the Mesa3D/DRI based “radeon” driver. I suggest you download AMD’s propritary driver (fglrx) fron their website, install that and try again.