GradientFill problem
Jul 27, 2012 at 1:33pm UTC
Hi! I'm testing the gradientfill function but the compiler doesn't seem to recognize it or GRADIENT_FILL_TRIANGLE that is used as the last parameter.
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
void draw_triangle(HWND hwnd, HDC hdc, camera c1, triangle t1){
POINT* result;
TRIVERTEX vertex[3];
GRADIENT_TRIANGLE gvertex;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
result = project_triangle(c1, rotate_triangle(c1, t1));
gvertex.Vertex1 = 0;
gvertex.Vertex2 = 1;
gvertex.Vertex3 = 2;
vertex[0].x = result[0].x;
vertex[0].y = result[0].y;
vertex[0].Red = t1.color[0][0];
vertex[0].Green = t1.color[1][0];
vertex[0].Blue = t1.color[2][0];
vertex[1].x = result[1].x;
vertex[1].y = result[1].y;
vertex[1].Red = t1.color[0][1];
vertex[1].Green = t1.color[1][1];
vertex[1].Blue = t1.color[2][1];
vertex[2].x = result[2].x;
vertex[2].y = result[2].y;
vertex[2].Red = t1.color[0][2];
vertex[2].Green = t1.color[1][2];
vertex[2].Blue = t1.color[2][2];
GradientFill(hdc, vertex, 3, &gvertex, 1, GRADIENT_FILL_TRIANGLE);
EndPaint(hwnd, &ps);
This code is in a headerfile so maybe there is something I need to declare first. I don't know. What did I do wrong?
Jul 27, 2012 at 2:50pm UTC
Always check the documentation of the Windows functions:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd144957(v=vs.85).aspx .
Near the end of the page, before any community additions you'll find the two pieces of information that you need to use the function: The header and the library.
#include the header and add the library to the list of additional libraries for the linker. The linker can also be taught by code using
#pragma comment(lib, "theLibNameHere")
.
Jul 27, 2012 at 5:41pm UTC
I think you need to define WINVER first to target minimum windows 2000.
Topic archived. No new replies allowed.