diff options
Diffstat (limited to 'linden/indra/llrender/llvertexprogramgl.cpp')
-rw-r--r-- | linden/indra/llrender/llvertexprogramgl.cpp | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/linden/indra/llrender/llvertexprogramgl.cpp b/linden/indra/llrender/llvertexprogramgl.cpp deleted file mode 100644 index 9f25582..0000000 --- a/linden/indra/llrender/llvertexprogramgl.cpp +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | /** | ||
2 | * @file llvertexprogramgl.cpp | ||
3 | * @brief LLVertexProgramGL base class | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2003-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | // This file contains the definition of LLVertexProgramGL, | ||
33 | // for purposes of running vertex programs on GL hardware. | ||
34 | |||
35 | #include "linden_common.h" | ||
36 | |||
37 | #include "llvertexprogramgl.h" | ||
38 | |||
39 | #include "llglheaders.h" | ||
40 | |||
41 | LLVertexProgramGL::LLVertexProgramGL() | ||
42 | { | ||
43 | mVertexProgramID = 0; | ||
44 | } | ||
45 | |||
46 | LLVertexProgramGL::~LLVertexProgramGL() | ||
47 | { | ||
48 | glDeleteProgramsARB(1, (GLuint*) &mVertexProgramID); | ||
49 | } | ||
50 | |||
51 | BOOL LLVertexProgramGL::load(const char * filename) | ||
52 | { | ||
53 | FILE *fp = fopen(filename, "r"); | ||
54 | if (!fp) | ||
55 | { | ||
56 | llwarns << "Unable to open vertex program " << filename << llendl; | ||
57 | return FALSE; | ||
58 | } | ||
59 | |||
60 | fseek(fp,0,SEEK_END); | ||
61 | S32 file_size = ftell(fp); | ||
62 | fseek(fp,0,SEEK_SET); | ||
63 | |||
64 | char *text_buffer = new char[file_size + 1]; | ||
65 | |||
66 | S32 num_read = (S32)fread(text_buffer, sizeof(char), file_size, fp); | ||
67 | |||
68 | if (ferror(fp) || num_read == 0) | ||
69 | { | ||
70 | llwarns << "Unable to read vertex program " << filename << llendl; | ||
71 | fclose(fp); | ||
72 | delete[] text_buffer; | ||
73 | return FALSE; | ||
74 | } | ||
75 | text_buffer[num_read] = '\0'; | ||
76 | fclose(fp); | ||
77 | |||
78 | //Send program string to OpenGL | ||
79 | glGenProgramsARB(1, (GLuint*) &mVertexProgramID); | ||
80 | glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mVertexProgramID); | ||
81 | glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, num_read, text_buffer); | ||
82 | |||
83 | const GLubyte * program_error_string = glGetString(GL_PROGRAM_ERROR_STRING_ARB); | ||
84 | |||
85 | GLint error_pos; | ||
86 | glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_pos); | ||
87 | |||
88 | if(error_pos!=-1) | ||
89 | { | ||
90 | glGetError(); | ||
91 | S32 line_num = 1; | ||
92 | char *next_token = strchr(text_buffer, '\n'); | ||
93 | while(NULL != next_token && next_token < (text_buffer + error_pos)) | ||
94 | { | ||
95 | next_token++; | ||
96 | line_num++; | ||
97 | next_token = strchr(next_token, '\n'); | ||
98 | } | ||
99 | char bad_code[11]; | ||
100 | strncpy(bad_code, text_buffer + error_pos, 10); | ||
101 | bad_code[10] = '\0'; | ||
102 | |||
103 | llerrs << filename << "(" << line_num << "): Vertex Program Error: " | ||
104 | << program_error_string << " at (" << bad_code<< ")" | ||
105 | << llendl; | ||
106 | // clean up buffer | ||
107 | delete[] text_buffer; | ||
108 | return FALSE; | ||
109 | } | ||
110 | |||
111 | // clean up buffer | ||
112 | delete[] text_buffer; | ||
113 | return TRUE; | ||
114 | } | ||
115 | |||
116 | void LLVertexProgramGL::bind() | ||
117 | { | ||
118 | glEnable(GL_VERTEX_PROGRAM_ARB); | ||
119 | glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mVertexProgramID); | ||
120 | } | ||
121 | |||
122 | void LLVertexProgramGL::unbind() | ||
123 | { | ||
124 | glDisable(GL_VERTEX_PROGRAM_ARB); | ||
125 | } | ||