- Timestamp:
- Sep 27, 2005, 12:33:05 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile.am
r5261 r5263 31 31 lib/tinyxml/libtinyxml.a \ 32 32 lib/shell/libORXshell.a \ 33 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 34 33 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \ 34 -lGLEW 35 35 36 36 orxonox_SOURCES = orxonox.cc \ -
trunk/src/Makefile.in
r5261 r5263 292 292 lib/tinyxml/libtinyxml.a \ 293 293 lib/shell/libORXshell.a \ 294 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 294 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \ 295 -lGLEW 295 296 296 297 orxonox_SOURCES = orxonox.cc \ -
trunk/src/defs/glincl.h
r4381 r5263 2 2 \file glincl.h 3 3 \brief This file includes gl Headers. 4 4 5 5 no Class is defined here, but the opengl Headers 6 6 */ … … 10 10 11 11 #ifndef __APPLE__ 12 #include <GL/glew.h> 12 13 #include <GL/gl.h> 13 14 #include <GL/glu.h> 14 15 #else 16 #include <OpenGL/glew.h> 15 17 #include <OpenGL/gl.h> 16 18 #include <OpenGL/glu.h> -
trunk/src/lib/graphics/graphics_engine.cc
r5262 r5263 61 61 this->hwVersion = NULL; 62 62 this->hwExtensions = NULL; 63 64 Shader shader("test.txt");65 shader.debug();66 exit(-1);67 63 } 68 64 … … 267 263 for (unsigned int i = 0; i < this->hwExtensions->getCount(); i++) 268 264 PRINT(4)("%d: %s\n", i, this->hwExtensions->getString(i)); 265 266 267 // inizializing GLEW 268 GLenum err = glewInit(); 269 if (GLEW_OK != err) 270 { 271 /* Problem: glewInit failed, something is seriously wrong. */ 272 PRINTF(1)("%s\n", glewGetErrorString(err)); 273 } 274 PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); 275 276 Shader* shader = new Shader("test.txt"); 277 shader->debug(); 278 delete shader; 279 // exit(-1); 280 269 281 } 270 282 -
trunk/src/lib/graphics/shader.cc
r5262 r5263 18 18 #include "shader.h" 19 19 20 20 21 #include "array.h" 21 22 #include "stdlibincl.h" … … 42 43 this->fragmentShaderSource = NULL; 43 44 this->vertexShaderSource = NULL; 45 this->fragmentShaderLengths = NULL; 46 this->vertexShaderLenghts = NULL; 44 47 this->shaderProgram = 0; 45 48 this->vertexShader = 0; 46 49 this->fragmentShader = 0; 50 51 if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100) 52 this->shaderProgram = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); 47 53 48 54 if (vertexShaderFile != NULL) … … 61 67 this->deleteProgram(SHADER_VERTEX); 62 68 this->deleteProgram(SHADER_FRAGMENT); 63 // DELETE THE PROGRAMS 64 /* this->shaderProgram = 0; 65 this->vertexShader = 0; 66 this->fragmentShader = 0;*/ 69 70 glDeleteObjectARB(this->shaderProgram); 67 71 } 68 72 … … 82 86 } 83 87 Array<char*>* program = new Array<char*>; 88 Array<int>* lengths = new Array<int>; 84 89 if (type == SHADER_VERTEX) 85 90 { … … 87 92 strcpy(this->vertexShaderFile, fileName); 88 93 this->vertexShaderSource = program; 94 this->vertexShaderLenghts = lengths; 89 95 } 90 96 else … … 93 99 strcpy(this->fragmentShaderFile, fileName); 94 100 this->fragmentShaderSource = program; 101 this->fragmentShaderLengths = lengths; 95 102 } 96 103 … … 113 120 } 114 121 program->addEntry(addString); 115 116 printf(lineBuffer); 122 lengths->addEntry(strlen(addString)); 117 123 } 118 124 fclose(stream); 119 125 120 126 program->finalizeArray(); 121 122 123 // this->shaderProgram = glCreateProgramObjectARB(); 124 this->vertexShader =1; 127 lengths->finalizeArray(); 128 129 if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader) 130 { 131 this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); 132 glShaderSourceARB(this->vertexShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray()); 133 glCompileShaderARB(this->vertexShader); 134 glAttachObjectARB(this->shaderProgram, this->vertexShader); 135 } 136 137 if (type == SHADER_FRAGMENT && GLEW_ARB_fragment_shader) 138 { 139 this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); 140 glShaderSourceARB(this->fragmentShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray()); 141 glCompileShaderARB(this->fragmentShader); 142 glAttachObjectARB(this->shaderProgram, this->fragmentShader); 143 } 144 glLinkProgramARB(this->shaderProgram); 125 145 } 126 146 127 147 bool Shader::activateShader() 128 148 { 129 149 glUseProgramObjectARB(this->shaderProgram); 130 150 } 131 151 … … 138 158 deleteArray = this->vertexShaderSource; 139 159 this->vertexShaderSource = NULL; 160 delete this->vertexShaderLenghts; 161 this->vertexShaderLenghts = NULL; 140 162 delete[] this->vertexShaderFile; 141 163 this->vertexShaderFile = NULL; 164 glDeleteObjectARB(this->vertexShader); 165 this->vertexShader = 0; 142 166 } 143 167 else if (type == SHADER_FRAGMENT) 144 168 { 145 169 deleteArray = this->fragmentShaderSource; 170 delete this->fragmentShaderLengths; 171 this->fragmentShaderLengths = NULL; 146 172 this->fragmentShaderSource = NULL; 147 173 delete[] this->fragmentShaderFile; 148 174 this->fragmentShaderFile = NULL; 175 glDeleteObjectARB(this->fragmentShader); 176 this->fragmentShader = 0; 149 177 } 150 178 else -
trunk/src/lib/graphics/shader.h
r5262 r5263 43 43 Array<char*>* fragmentShaderSource; 44 44 Array<char*>* vertexShaderSource; 45 Array<int>* fragmentShaderLengths; 46 Array<int>* vertexShaderLenghts; 45 47 GLenum shaderProgram; 46 48 GLenum vertexShader;
Note: See TracChangeset
for help on using the changeset viewer.