Jump to content
  • Advertisement

judge dreadz

Member
  • Content count

    142
  • Joined

  • Last visited

Community Reputation

193 Neutral

About judge dreadz

  • Rank
    Member
  1. judge dreadz

    do these functions look correct?

    i need normalised coordinates, ie. in the range 0-1. thats why i divide/multiply by texWidth twice.
  2. i'm having problems trying to implement a GPU sorting algorithm. the data is stored in a texture, i wrote these two functions to convert between normalised texture coordinates and standard array indices. do they look correct to you? its not working properly. float2 convert1dto2d (float index1d, float texWidth) { float2 index2d; index2d.y = (floor(index1d/texWidth))/texWidth; index2d.x = frac(index1d/texWidth); return index2d; } float convert2dto1d (float2 index2d, float texWidth) { float index1d; index1d = (index2d.x + index2d.y * texWidth) * texWidth; return index1d; }
  3. judge dreadz

    what does do?

    ok thanks for that. so 1<<(i+1) is 2^i and 1<<j is 2^(j-1), right?
  4. judge dreadz

    what does do?

    i dont know what the following lines of code do. unfortunately google wont search for << so hopefully one of you can tell me! int stepno = 1 << (i+1); int offset = 1 << j; thanks
  5. judge dreadz

    FBOs and glDrawBuffers

    copied from another forum because i need some help urgently and havent received any replies. i am using FBOs to render to texture from Cg fragment shaders: i have a strange bug in my code. i set my render targets and perform a computation like this: // set render destination GLenum drawBuffers[] = { attachPosition[WRITE], attachVelocity[WRITE] }; glDrawBuffers(2, drawBuffers); //perform computation drawQuad(); i then bind a different fragment shader and perform a different computation: // set render destination glDrawBuffer(attachSort[WRITE]); drawQuad(); the results of the second computation are being written to my position and velocity textures. so the call do glDrawBuffer before the second computation isnt working. i dont know why, i can only think that maybe my sort textures are not attached to the FBO properly. is there a way to query if my glDrawBuffer call was succesful? or to query that my sort textures are attached ok? i have 6 color attachments on my FBO, is that too many? this is how i set up my FBO: GLenum attachPosition[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT }; GLenum attachVelocity[] = { GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT }; GLenum attachSort[] = { GL_COLOR_ATTACHMENT4_EXT, GL_COLOR_ATTACHMENT5_EXT }; glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachPosition[READ], TEX_TARGET, pos[READ], 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachPosition[WRITE], TEX_TARGET, pos[WRITE], 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachVelocity[READ], TEX_TARGET, vel[READ], 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachVelocity[WRITE], TEX_TARGET, vel[WRITE], 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachSort[READ], TEX_TARGET, sort[READ], 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachSort[WRITE], TEX_TARGET, sort[WRITE],0); // check status if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) printf("ERROR - Incomplete FrameBuffer\n"); i dont get any error, but i cant understand where the bug is. have been trying to fix it for 2 days now! any help/suggestions greatly appreciated as always, thanks.
  6. judge dreadz

    which gfx card is better?

    which card is better for gaming? an nVidia quadro fx 3400 or a 7800 GTX. i read that the quadro cards are not optimised for gaming, why are they so much more expensive?
  7. judge dreadz

    openGL viewport

    Quote:Original post by jamba In the gluPerspective call in the second block of code, the glutGet functions will return ints, so you're doing an integer divide. (So something like 4/3 will equal 1) Cast one of those glutGet results to a GLfloat. yeah thanks that looks right now. Quote: But why do you need to "redefine the viewport in the display method before drawing anything"? It looks like you're setting it to the same value you're using in reSizeWindow. Just set the viewport and projection matrix in reSizeWindow. heh i knew someone would ask me that. the brief answer is that i have to set a different perspective in another part of the program to do a texture read in the GPU before every display.
  8. judge dreadz

    openGL viewport

    the perspective in my GLUT window is wrong. when i draw a circle, it looks slightly oval shaped. not really sure how this all works, hoping someone can tell me what the problem might be. here is the code that initialises the window: void reSizeWindow(int width, int height) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glViewport(0,0,width,height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye[0], eye[1], eye[2], 0.0f, 3.0f, 0.0f, upvec[0], upvec[1], upvec[2]); } i also need to redefine the viewport in the display method before drawing anything. i use the following code: glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f,glutGet(GLUT_WINDOW_WIDTH)/glutGet(GLUT_WINDOW_HEIGHT),0.1f,100.0f); glViewport(0,0,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT)); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye[0], eye[1], eye[2], 0.0f, 3.0f, 0.0f, upvec[0], upvec[1], upvec[2]);
  9. judge dreadz

    packing half values into float

    Quote:Original post by Xai you would not pack them into a float anyway ... well most of your post went over my head, but on this point, since i am storing the values in floating point textures, and since Cg has inbuilt functions pack_2half and unpack_2half which specifically pack and unpack half values into floats, i'm pretty sure i want to pack them into a float.
  10. judge dreadz

    packing half values into float

    ok not to worry. i am using Cg functions to pack and unpack half values on the GPU. i wanted to initialise the data on the CPU before beginning the simulation. i can work around it by initialising on the GPU, though it will be a bit messy.
  11. judge dreadz

    packing half values into float

    do you not have halfs in c++? what i need is two 16 point floats packed into one 32 point float value.
  12. how do i pack two halfs into a float value in c++?
  13. judge dreadz

    transformation matrix

    not sure i follow you. do you mean when i do: float2 rotatedCoords = mul(transformMatrix, texCoords).xy; i assume its using a column vector or it would give a compile error? its Cg shader code btw.
  14. judge dreadz

    transformation matrix

    i'm trying to transform normalised texture coordinates. i dont seem to have the transformation matrix right. obviously i need to rotate the coords about the ponint (0.5,0.5) not the origin. this is what i have: float3x3 translate = { 1, 0, -0.5f, 0, 1, -0.5f, 0, 0, 1 }; float3x3 rotate = { cos(angle), -sin(angle), 0, sin(angle), cos(angle), 0, 0, 0, 1 }; float3x3 untranslate = { 1, 0, 0.5f, 0, 1, 0.5f, 0, 0, 1 }; float3x3 transformMatrix = mul(untranslate, (mul(rotate, translate)));
  15. judge dreadz

    Cg texture sampling

    depends what you mean, exactly what do you want to do and why?
  • 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!