Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

154 Neutral

About BionicBytes

  • Rank
  1. BionicBytes

    Drawing border around objects in 3d

    I think the simplest solution is to: (a) render the scene as per normal (b) Render the objects using lines. That is use glBegin(GL_LINES) and ensure your lines have some thickness to them, glLineWidth(4.0) and disable depth testing glDisable (GL_DEPTH_TEST) (c) restore previous opengl state
  2. BionicBytes

    brightness shader question

    A couple of thoughts stuck me on this one: first - if you really do mean controlling the brightness, the simply modulating the current RGB values by a scalar is not good enough. You really need to convert the RGB values to HSB, alter the required brightness and convert back to RGB. A quick google on HSB to RGB should work. Second - can you break the rendering into two phases, a textured phase and a non-textured phase. If you can't. What about - defining -1 for the [st] coordinates for the non-textured polygons, that way you can test for this value in the shader. Currently, I expect your non-textured fragments have an undefined ST coordinate.
  3. BionicBytes

    [OpenGL + CG] Ignored cgSetParameter

    did my last post solve the issue?
  4. The OpenGL depth buffer is not a linear. I think its log linear. Basically, most of the precision is first portion of the depth range. So - what you can do is for the closeup objects, specify appropriate values for the camera's near and far planes, and also look at glDepthRange (near,far) this should also help with the depth problem.
  5. BionicBytes


    Nothing in 3D graphics is easy or free. You will need to invest some time/effort into creating a camera class of sorts. I have different camera classes to allow for different things - eg. one for tracking a player - one for following a spline curve and a basic one for UI work etc... I would suggest defining a camera class interface and then have all camera class instances adhere to this interface. That way later on, regardless of the specific camera class used to interact with the world - you can always call on a standard virtual interface method.
  6. BionicBytes

    Help! Code Interpretation...

    Your problem lies in this code area: [source lang=c#] .... from the Display() routine if (needRedisplay) glutPostRedisplay(); Currently - the way its setup the code will only redraw when a key has been pressed - since in turn this called the glutPostDisplay message. Solution: remove the if statement and simply call the glutPostDisplay() method at the end of the drawing loop
  7. BionicBytes

    Modify data stored in GLuint

    I suggest you use glReadPixels() to obtain a copy of the current back buffer and store it in a memory array. Then you can change/modify the memory array and use it as the source to update a texture object. Then you can simply draw the texture object to the screen. So - read the data from back buffer with: int size = 4 * Width * Height; // RGBA Buffer byte [] buffer = new byte [size]; Gl.glReadPixels (x, y, Width, Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, buffer); Then to copy this to a dynamic texture with: Gl.glBindTexture(Gl.GL_TEXTURE_2D,image.TextureID); Gl.glCopyTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, 0, 0, Width, Height, 0); Finally, render this texture to the framebuffer as a full screeb quad.
  8. BionicBytes

    [OpenGL + CG] Ignored cgSetParameter

    okay - i need to be quick because the international rugby is on. So ... within a BEGIN/END block any call to Cg.cgSetParameter1f(param,0.8f); is invalid. Resulting in two black quads. Placing the Cg.cgSetParameter1f(param,0.8f); outside of a BEGIN/END block is valid and results in RED rects. (of course both the same color). So ... rule is must set Cg params outside of BEGIN/END blocks. And for the second point - never set additional cg params as a parameter to main.
  9. BionicBytes

    FBO with stencil test

    Also - check and display how many stencil bits you actually have. Gl.glStencilMask(0xFFFFFFFF); Gl.glGetIntegerv (Gl.GL_STENCIL_BITS, out _iStencilBits);
  10. BionicBytes

    Terrain + Multitexturing and VBOs

    If your terrain is going to be deformable then you have a second issue. The VBO contains fixed geometry. How are you going to arrange the source data to make it deformable? One possible solution if to generate the original and deformable data in a one massive VBO as triangles. Then generate multiple index sets. One index set presenting the non-deformed terrain, and then where the terrain is deformable alternative sets of indices. When rendering you need to tracks whats what, but you can in principle now render the entire terrain or the modified parts or both.
  11. BionicBytes

    Offscreen rendering

    You don't even need to use an FBO. Standard GL functionality should be more than sufficient, unless you're drawing zillions of polygons and performance really matters.
  12. BionicBytes

    GLSL float texture

    Sorry to say this, but to me at least, it not really very clear what you are trying to do. Still, I shall try to read-between the lines. By C++ buffer - do you just mean an array of data of some sort? Anyway - I think you really want to look at OpenGL FrameBufferObjects (FBO) objects. Using a FBO allows you to attach a texture as a drawable surface. So you could simply create a texture -from a RGBA filled C++ array. Then attach this texture as a COLOR texture to the FBO. You can also do this with the DEPTH texture as well. Once the FBO is attached with the COLOR and DEPTH - it becomes the current receiver of all rendering operations until the FBO unbound. Best of all these buffers can be specified as floats.
  13. BionicBytes

    [OpenGL + CG] Ignored cgSetParameter

    One other thing -- I compile my code using: // vertex cgc.exe -profile vp40 //frag cgc.exe -profile fp40 I am running cg 2.0.0015 on a windows XP environment using C# and Tao framework. I have however, also, run similar type of code in a Windows with c++ environment.
  14. BionicBytes

    [OpenGL + CG] Ignored cgSetParameter

    Sorry for the lateness in my reply. I've had a bad cold and couldn't face starring at a PC screen for any length of time. Anyway better now. So - I've set up a simple shader test case. The test case is: Can I draw two different rectangles in two different colors by changing the value of one shader parameter (t) twice whilst a single shader is bound. If the test is successful two rect's are draw in different shades of red. // the vp shader struct vp_in { float3 Position : POSITION; }; struct vp2fp { float4 HPos : POSITION; }; vp2fp main(vp_in IN) { vp2fp OUT; float4 pos=float4 (IN.Position.xyz,1.0); OUT.HPos=mul(glstate.matrix.mvp,pos); return OUT; } // now the fragment shader struct vp2fp { float4 HPos : POSITION; }; // Two interesting variations of the same thing. Here we have declared // a uniform float param, and in the second case param t is a function param. #if 1 uniform float t; void main( vp2fp IN,out float4 color : COLOR) { color = float4 (t,0,0,1); } #else void main( vp2fp IN,in float t,out float4 color : COLOR) { color = float4 (t,0,0,1); } #endif Here is the main render loop where the rects are drawn. // my lib code to get a shader reference Shader aShader = aMaterial.GetBaseShader(); // Get a named Cg parameter System.IntPtr param = Cg.cgGetNamedParameter(aShader.GetFragmentProgram(),"t"); aMaterial.Bind(); // my lib code to grab and activate the above shader Cg.cgSetParameter1f(param,0.8f); Gl.glRectf (10,10,100,100); Cg.cgSetParameter1f(param,0.4f); Gl.glRectf (10,110,100,210); aMaterial.Unbind(); Gl.glColor3f (1,1,1); And the result is TWO different colored RED rectangles on the screen. Now, if I change the shader code and make the #if 1 to a #if 0, and re-run the test the result is 2 BLACK rectangles. So... I think in this second case the parameter t is being ignored. But ... in the debugger the named Cg param is still valid - meaning (from what I know about Cg etc) is that the param was found in the list of enumerated Cg parameters. If the param was invalid the param value would have been 0. I have no explanation for the t param when its specified as part of the main function. B.T.W if i go back to the Uniform param t version, if i remove the uniform keyword, the test still works as expected and 2 red rects are displayed. Does this help?
  15. BionicBytes

    [OpenGL + CG] Ignored cgSetParameter

    tell you want - I'll write a simple test shader that takes a parameter and change it several times a begin/end block and see what it does on my environment. I guess as long as the variable was not marked as a uniform then it should be valid to change at any time. What version of Cg are you running ? Just a thought - but there is a new Cg Version 2.1 out now.
  • 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!