summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/state_tracker/state_line.c
blob: ef4a3b4a9ba33c9c07146ccae812569fc11be6a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* Copyright (c) 2001, Stanford University
 * All rights reserved
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#include <stdio.h>
#include "state.h"
#include "state/cr_statetypes.h"
#include "state_internals.h"

void crStateLineInit (CRContext *ctx)
{
	CRLineState *l = &ctx->line;
	CRStateBits *sb = GetCurrentBits();
	CRLineBits *lb = &(sb->line);

	l->lineSmooth = GL_FALSE;
	l->lineStipple = GL_FALSE;
	RESET(lb->enable, ctx->bitid);
	l->width = 1.0f;
	RESET(lb->width, ctx->bitid);
	l->pattern = 0xFFFF;
	l->repeat = 1;
	RESET(lb->stipple, ctx->bitid);
	/*
	 *l->aliasedlinewidth_min = c->aliasedlinewidth_min; 
	 *l->aliasedlinewidth_max = c->aliasedlinewidth_max; 
	 *l->aliasedlinegranularity = c->aliasedlinegranularity; 
	 *l->smoothlinewidth_min = c->smoothlinewidth_min; 
	 *l->smoothlinewidth_max = c->smoothlinewidth_max; 
	 *l->smoothlinegranularity = c->smoothlinegranularity; */

	RESET(lb->dirty, ctx->bitid);
}

void STATE_APIENTRY crStateLineWidth(GLfloat width) 
{
	CRContext *g = GetCurrentContext();
	CRLineState *l = &(g->line);
	CRStateBits *sb = GetCurrentBits();
	CRLineBits *lb = &(sb->line);

	if (g->current.inBeginEnd)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLineWidth called in begin/end");
		return;
	}

	FLUSH();

	if (width <= 0.0f) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLineWidth called with size <= 0.0: %f", width);
		return;
	}

	l->width = width;
	DIRTY(lb->width, g->neg_bitid);
	DIRTY(lb->dirty, g->neg_bitid);
}

void STATE_APIENTRY crStateLineStipple(GLint factor, GLushort pattern) 
{
	CRContext *g = GetCurrentContext();
	CRLineState *l = &(g->line);
	CRStateBits *sb = GetCurrentBits();
	CRLineBits *lb = &(sb->line);

	if (g->current.inBeginEnd)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
			"glLineStipple called in begin/end");
		return;
	}

	FLUSH();

	if (factor < 1) factor = 1;
	if (factor > 256) factor = 256;

	l->pattern = pattern;
	l->repeat = factor;
	DIRTY(lb->stipple, g->neg_bitid);
	DIRTY(lb->dirty, g->neg_bitid);
}