Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About arczev

  • Rank
  1. arczev

    glsl problem

    Hmm, according to what you said, the launch code from the orange book appears to be completely wrong, because it leaves uniform mat4 MVMatrix; uniform mat4 MVPMatrix; uniform mat3 NormalMatrix; uninitialized. I mean those declarations occur in vertex shader source, but in the launch code they aren't initialized at all. Example function that prepare brick shader does only glUniform3f(getUniLoc(brickProg, "BrickColor"), 1.0, 0.3, 0.2); glUniform3f(getUniLoc(brickProg, "MortarColor"), 0.85, 0.86, 0.84); glUniform2f(getUniLoc(brickProg, "BrickSize"), 0.30, 0.15); glUniform2f(getUniLoc(brickProg, "BrickPct"), 0.90, 0.85); glUniform3f(getUniLoc(brickProg, "LightPosition"), 0.0, 0.0,4.0); but If i understood it right, it should also do sth like: glGetFloatv(GL_MODELVIEW_MATRIX,mvmatrix); . . . glUniform3fv(getUniLoc(brickProg, "MVMatrix"),16,mvmatrix); etc. I dont know what's going on
  2. arczev

    glsl problem

    Shaders compile fine, however in the fragment part i get warning: Fragment shader was successfully compiled to run on hardware. WARNING: 0:3: warning(#239) Declaration should include a precision qualifier or the default precision should have been previously declared I find the launch code problematic though. Because in 3rd edition there are 3 additional lines compared to 2nd version: . . . . . glAttachShader(brickProg,brickVS); glAttachShader(brickProg,brickFS); glBindVertexAttrib(brickProg,1,"MCvertex"); // <-this glBindVertexAttrib(brickProg,2,"MCnormal"); //<-this glBindFragData(brickProg,0,"FragColor") ;// <-and this . . . . . There are no such functions in OGL, I suppose... I googled it and found that i should replace them and use glBindAttribLocation and glBindFragDataLocation instead, and it compiles now, but still nothing can I see on the screen. And how the glsl compiler knows that for example uniform mat4 MVMatrix refers to the modelview matrix? [Edited by - arczev on November 1, 2010 4:24:29 AM]
  3. Hi, Im new to GLSL and i learn from shader examples from orange book. I've tried to compile a brick shader from 3rd edition and I failed. Then I took the code from the previous edition(2nd) and everything displayed fine. Those two versions of the brick shader differ slightly. For example the 3rd edition code declares: uniform mat4 MVMatrix uniform mat4 MVPMatrix and so on for modelview and projection matrices. The 2rd edition code skips this, and uses gl_ModelViewMatrix, gl_NormalMatrix etc. instead. another difference: 2nd uses "varying", 3rd uses "in" and "out". I thought 3rd edition code is more up to date and I should use this, but as I mentioned before, I simply can't make it running properly. I have OGL 3.1 Hope you can help me:)
  4. Hi, I've been writing a simple game engine and I want to handle mouse input in it. I want my OnMouseDown() code to be performed ONLY once no matter how long i hold the mouse button. I've tried to use WM_LBUTTONDOWN message, but I noticed that my procedure is called multiple times even If i once click on the game screen. Here is a testing code that may explain u what I mean: int test=0; . . . . . . . . . . . . . case WM_LBUTTONDOWN: test++; break; return 0; case WM_KEYDOWN: sprintf(msgbuf,"%i",test); MessageBox(0,msgbuf,"",0); break; return 0; . . . . . . . . . . . . . . When I run the program and press any key, test=0. Than, if I once click my mouse, test=206.After second click test=423 etc,etc.. Can u possibly tell my why it is like that instead of test=1,test=2... thank u:)
  5. I knew because when I normally use non-object version of window procedure, this code makes the screen black and than I can draw in opengl mode. Ok, problem solved, The last parameter of CreateWindowEx(...) should be (void*)this, I had NULL
  6. First, tkanks for response. Unfortunately, adding return true after SetWindowLong(...) doesnt change the situation. The problem is that there is no error message, just OpenGL doesnt initialize, application behaves as if there was no initializing code(GetDC, SetupPixelFormat,etc.)
  7. Hi, recently I've been writing an object wersion of opengl window, and i have a problem. The most important parts of my code: LRESULT CALLBACK WndProc(HWND hwnd,UINT message, WPARAM wParam,LPARAM lParam){ if (message == WM_NCCREATE) { LPCREATESTRUCT cs = (LPCREATESTRUCT) lParam; SetWindowLong(hwnd, GWL_USERDATA, (long) cs->lpCreateParams); } COGLWindow *window = (COGLWindow *) GetWindowLong(hwnd, GWL_USERDATA); if (window) return window->OGLWndProc(hwnd, message, wParam, lParam); else return DefWindowProc(hwnd, message, wParam, lParam); } LRESULT COGLWindow::OGLWndProc(HWND hwnd,UINT message, WPARAM wParam,LPARAM lParam){ switch(message){ case WM_CREATE: hDC = GetDC(hwnd); g_HDC = hDC; SetupPixelFormat(hDC); wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); break; . . . With this code(copied from tutorials) i managed to use window procedure as a class method, but Opengl initialization code simply doesnt work now. Does anybody know how to solve it? thx 4 response
  8. Hi, Picking procedure from my game looks like this(i had copied it from tut) . . . hits= glRenderMode (GL_RENDER); if (hits != 0) { ptr = (GLuint *) buffer; minZ = 0xffffffff; for (i = 0; i < hits; i++) { names = *ptr; ptr++; if (*ptr < minZ) { numberOfNames = names; minZ = *ptr; ptrNames = ptr+2; } ptr += names+2; } ptr = ptrNames; Process(numberOfNames,ptr); . . . This procedure returns names of objects which are "on the top". Do anyone know how to change it to return all names? thx 4 respons
  9. Hi, I have my picking proc associated with WM_LBUTTONDOWN message like this: case WM_LBUTTONDOWN: PickingProc(...); break; When i click on the screen, PickingProc() is called 2-4 times at once. It looks like one mouse click generates a few messages instead of one. Is it normal and how to fix it? thx 4 reesponse
  10. Hi, how can I gain selection for multiple objects? I'd like to have it like in RTS games: I make a rectangle with cursor and those object which are inside it are picked. Thx 4 response :)
  11. Hi, I'm gonna to write an simple RTS game and I have a question: Is there any reliable method of unit movement interpolation? I have list of nodes like this point path[...]; I need to gain interpolation which additionally provides 1. change of unit direction(destination path) while unit is on the move 2.Collision avoidance for multiple units. It can just be that: unit A stops for a while until unit B passes or unit A searches for a new path. Thx 4 respond!
  12. arczev

    vertex arrays problem

    Yea, I've used 1D array and my model works fine. But how to call glNormalPointer then? I store normals in array float normals[...] and their order in unsigned int norord[..] array if I call glDrawElements(GL_TRIANGLES,facesCount,GL_UNSIGNED_INT,faces) normals will be defined by vertex order like vertices instead of normal order. How to define them using norord array?
  13. arczev

    vertex arrays problem

    V-man, I count my vertices and faces from 1 not from zero but I provede to glVertexPointer() and glDrawElements() pointer to initial vertex and face (&vertex[1][0] and &faces[1]) I use 2D array because one dimension is a list of vertices and another one stores x,y,z coordinates (4 example vertex[1][0] - x coordinate of the first vertex) How can it be done with 1D array? Brother Bob, "but in the immediate mode example you're indexing it form the first." As far as I can see in both examples I count from the 1 to x(from second element) but provide to glVertexPointer() and glDrawElements() pointers to those second elements. I tried to add and subtract 1 to those pointers, but no matter what I do my model is still drawn incorrectly :/ Meybe u can possibly show me how should I call those functions properly?
  14. Hi I'm trying to draw my models using vertex arrays but i have a problem. Sth does not work. I store my data like this: float vertex[...][3]; // vertices begin from index 1 unsigned int faces[...]; // faces start from 1 too first I have: glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3,GL_FLOAT,0,&vertex[1][0]); and then in the game loop i use glDrawElements(GL_TRIANGLES,facesCount,GL_UNSIGNED_INT,&faces[1]); but as a result it draws only two strange triangles. If I draw my model normally glBegin(GL_TRIANGLES); for(i=1;i<=facesCount;i++) glVertex3fv(vertex[faces]); glEnd(); everything is ok. Thanks 4 response!
  15. Hi I'm wiriting application which use picking and I have a problem. Whenever I pick something, my processing function is called twice. thx 4 response
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!