Jump to content
  • Advertisement

ThunderFart

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

115 Neutral

About ThunderFart

  • Rank
    Member
  1. ThunderFart

    How to use gluUnProject()?

    naa this is fine I just needed a head start in the right direction so these are equations for calculating [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][background=rgb(250, 251, 252)]screen coordinates of the pixel demension of a quad?[/background] [/font]
  2. ThunderFart

    How to use gluUnProject()?

    I don't know how to calculate screen cordinates for the corners of the quad I'm not a math person by nature thats why I was asking for help in the begining anyways.
  3. ThunderFart

    How to use gluUnProject()?

    so render the quad in orthographic then select the quad which would happen automatically since I would already have left clicked then unproject after rendered how would I do the two unprojections per quad corner code? also how would opengl know of the corners? when using glVertex3f();
  4. ThunderFart

    How to use gluUnProject()?

    Okay here is a full explanation for your pleasure What I'm trying to do is mouse selection in a different way then doing ray collision checking/color picking/index object picking/selection mode. I'm doing my own mouse selection which I would like to call Area Selection Translation how this works is : 1.) position a quad at the mouse cursor position 2.) When I left click display a quad with a texture that has a border In the texture and colorkey the center using a fragment shader. 3.) Then when you left click and drag the quad whatever is under the quad is translated with it making for a very simple way of doing mouse selection and skipping out any complexities that might come along with that Now the problem is I do not know how to position the quad under the mouse cursor even using gluUnproject doesn't provide me with the results I need which is the above step by step ^^ I hope you understand better. I'm using WIN32 to get the mouse cursor position OpenGL 3.0 to draw the quad GLSL to colorkey the center part of the quads texture here is a image that might help you understand better here what I got so far obviously there is still a texture problem which I will fix later but -> http://pastebin.com/5eQjfTFP
  5. ThunderFart

    How to use gluUnProject()?

    So what do you think I should do to make this work otherwise I'm almost totally stumped?
  6. ThunderFart

    GLUT, OpenGL & mouse coordinates

    hey your like me wanting to program for fun and not have to do all the technical crap how awesome atleast there are other people out there who like to program for idea rather then the technical crap that comes with it ! woot inspires me to make tools that can get rid of technicality as much as possible and focus more on creativity and fun programming experiences but still keep technical around for those who like it and are passionate about it as well! user atmosphere experience should be a choice not a enforcement no matter what your doing! rule number 1 in good api design technical creative or any other genre should be a choice not an enforcement
  7. ThunderFart

    How to use gluUnProject()?

    So its actually impossible to convert cordinates without selecting one of the dots along a z line is what your saying? I'm confused "wait!" are you saying I need to enable depth?
  8. ThunderFart

    How to use gluUnProject()?

    Now that I think about it the problem really is converting mouse cordinates to opengl world cordinates and then passing that to glTranslatef(); if someone could tell me that I would be very grateful because there obviously is a way to do it.
  9. ThunderFart

    How to use gluUnProject()?

    Thank you for calling out the problem still if I render the quad then snap it to the mouse it will look silly because the quad will show then snap so that means that the solution that I came up with, which was to basically get the opengl cordinates from mouse cordinates and glTranslatef(); the quad is now going to be annoying and right now with this current code will not work so I need to figure out another way to snap the quad to the mouse position and that is going to be an annoying and crappy huge challenge as always... but thank you for like giving out the information about this very good info there! if you have any solutions or ideas please do let me know .
  10. ThunderFart

    How to use gluUnProject()?

    I've made some must needed changes to that question I had no idea must have been when I tried to align the code in the full editor on gamedev what a load of tut that was XD. Thank you for pointing that out. I hope you can help me now tho lol.
  11. ThunderFart

    How to use gluUnProject()?

    I relize I've made some mistakes with my texturing and also forgot to put the main while loop for this application in the above question , but to answer your actual question gluUnProject is being called in that function above. if your asking me the exact location about half-way through the source file there is a while loop which looks exactly like this : // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); display(); } return Msg.wParam; } I hope that answers your questions and helps you towards helping me solving my problem.
  12. I'm a decent programmer I'd like to think but when it comes to mathematical problems I mostly fail and this is one of those cases : I want to be able to draw a quad right in middle of the mouse cursor position so I tried searching around for answers and found NeHe tutorials which I followed mostly but changed around abit and this code below is what I have now I will show declarations/initializations of all variables used in this code below : void display() { glClearColor(0.0,0.0,0.0,1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); for(std::vector<GLuint>::iterator I = cube.begin(); I != cube.end(); ++I) { glCallList(*I); } if(DrawArea == true) { // winX = (float)mouse.x; // winY = (float)mouse.y; // winY = (float)viewport[3] - winY; glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ); cerr << winZ << endl; glGetDoublev(GL_MODELVIEW_MATRIX, modelview); glGetDoublev(GL_MODELVIEW_MATRIX, projection); glGetIntegerv(GL_VIEWPORT, viewport); gluUnProject(winX, winY, winZ , modelview, projection, viewport, &posX, &posY, & posZ); glBindTexture(GL_TEXTURE_2D, DrawAreaTexture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, DrawAreaSurface->w, DrawAreaSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, DrawAreaSurface->pixels); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, DrawAreaTexture); glTranslatef(posX , posY, posZ); glBegin(GL_QUADS); glTexCoord2f (0.0, 0.0); glVertex3f(0.5, 0.5, 0); glTexCoord2f (1.0, 0.0); glVertex3f(0, 0.5, 0); glTexCoord2f (1.0, 1.0); glVertex3f(0, 0, 0); glTexCoord2f (0.0, 1.0); glVertex3f(0.5, 0, 0); glEnd(); } SwapBuffers(hDC); //FOR SPAMMING 1/0 // cerr << DrawArea << endl; } Here is the declarations/initializations : GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; GLfloat winX, winY, winZ; GLdouble posX, posY, posZ; bool DrawArea = false; When I run this code I have problems one the quad flickers black and winZ returns 1 whatever that means which is not what it should be doing... and I don't know why? I'm using WIN32 API C++ OpenGL 3.0
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!