Member

142

193 Neutral

• Rank
Member
1. ## do these functions look correct?

i need normalised coordinates, ie. in the range 0-1. thats why i divide/multiply by texWidth twice.
2. ## do these functions look correct?

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. ## what does do?

ok thanks for that. so 1<<(i+1) is 2^i and 1<<j is 2^(j-1), right?
4. ## 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

6. ## 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. ## 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. ## 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. ## 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. ## 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. ## 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. ## packing half values into float

how do i pack two halfs into a float value in c++?
13. ## 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. ## 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. ## Cg texture sampling

depends what you mean, exactly what do you want to do and why?