BladeWise

Member
  • Content count

    73
  • Joined

  • Last visited

Community Reputation

128 Neutral

About BladeWise

  • Rank
    Member
  1. Vertex Buffer with C#

    Have you used the extension laoder provided in the Tao package (I supposed you are using TAO framework)? If you are using your own custom structures to store your geometry, than it's better to create your custom bindings to OpenGl functions... if you need more infos (I'm not a guru, but since a couple of months I'm working with TAO), contact me via ICQ (19283749) or e-mail (dany2222@gmail.com)... or post here again! :P
  2. Mouse Picking

    If you are calling about Selection (as far as I know it's different from picking, but maybe I'm wrong), you need to associate a "name" to your objects, using glPushName and glPopName, so you'll be able to read that data into the selection buffer, as specified in the tutorial... names are integer values...
  3. OpenGL Please help

    Same error for me :P
  4. I solved this problem using custom bindings with ref Vector*F instead of Vector*F[]... anyway, can anybosy explain me why is it so? ^^
  5. Hi all, I'm using vertex arrays in C#, with Tao.OpenGl, since my vertex data are stored in a Vector*F[] (the Vector*F, Vector3F and Vector2F if you prefer, struct is taken from Sharp3D.Math library), I decided to create a custom binding to pass directly my data (the Vector*F[]) to gl*Pointer function... unfortunally I have some problems: even if geometry is drawn correctly, normals and texture data are messed up... if I copy that data in a float[], everithing is fine... this is the code used to create my custom bindings: using System; using Sharp3D.Math.Core; using System.Runtime.InteropServices; using System.Security; [assembly: CLSCompliantAttribute(true)] namespace VoidGl { #region VGl class /// <summary> /// Class used to create OpenGL bindings. /// </summary> [CLSCompliantAttribute(true)] public sealed class VGl { #region Static members #region m_UseVGl member /// <summary> /// Test... /// </summary> public static bool m_UseVGl=false; #endregion #endregion #region Private constructor /// <summary> /// This class doesn't need to be instantiated. /// </summary> private VGl() { } #endregion #region Static methods #region glColorPointer functions /// <summary> /// Override used to support color array with ColorF elements. /// </summary> /// <param name="size">Number of components per color (must be 4).</param> /// <param name="type">Specifies the data type of each color component in the array.</param> /// <param name="stride">Specifies the byte offset between consecutive colors.</param> /// <param name="colors">Array of colors.</param> [DllImport("opengl32.dll", EntryPoint="glColorPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glColorPointer(int size, int type, int stride, ColorF[] colors); #endregion #region glTexCoordPointer functions /// <summary> /// Override used to support texture coordinates array with Vector2F elements. /// </summary> /// <param name="size">Number of components per color (must be 2).</param> /// <param name="type">Specifies the data type of each texture coordinates component in the array.</param> /// <param name="stride">Specifies the byte offset between consecutive texture coordinates.</param> /// <param name="coords">Array of texture coordinates.</param> [DllImport("opengl32.dll", EntryPoint="glTexCoordPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glTexCoordPointer(int size, int type, int stride, Vector2F[] coords); #endregion #region glNormalPointer functions /// <summary> /// Override used to support normals array with Vector3F elements. /// </summary> /// <param name="type">Specifies the data type of each normal component in the array.</param> /// <param name="stride">Specifies the byte offset between consecutive normals.</param> /// <param name="normals">Array of normals.</param> [DllImport("opengl32.dll", EntryPoint="glNormalPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glNormalPointer(int type, int stride, Vector3F[] normals); #endregion #region glVertexPointer functions /// <summary> /// Override used to support texture coordinates array with Vector3F elements. /// </summary> /// <param name="size">Number of components per color (must be 3).</param> /// <param name="type">Specifies the data type of each vertex component in the array.</param> /// <param name="stride">Specifies the byte offset between consecutive vertices.</param> /// <param name="vertices">Array of vertices.</param> [DllImport("opengl32.dll", EntryPoint="glVertexPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glVertexPointer(int size, int type, int stride, Vector3F[] vertices); #endregion #endregion } #endregion } This is the code used to render my geometry: #region Render function /// <summary> /// Renders the mesh. /// </summary> public virtual void Render() { if(this.m_Normals!=null) { if(!VGl.m_UseVGl) { float[] array=new float[this.m_Normals.Length*3]; for(int i=0; i<array.Length; i+=3) { array[i]=this.m_Normals[i/3].X; array[i+1]=this.m_Normals[i/3].Y; array[i+2]=this.m_Normals[i/3].Z; } Gl.glNormalPointer(Gl.GL_FLOAT,0,array); } else VGl.glNormalPointer(Gl.GL_FLOAT,0,this.m_Normals); } else Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY); if(!VGl.m_UseVGl) { float[] vert=new float[this.m_Vertices.Length*3]; for(int i=0; i<vert.Length; i+=3) { vert[i]=this.m_Vertices[i/3].X; vert[i+1]=this.m_Vertices[i/3].Y; vert[i+2]=this.m_Vertices[i/3].Z; } Gl.glVertexPointer(3,Gl.GL_FLOAT,0,vert); } else VGl.glVertexPointer(3,Gl.GL_FLOAT,0,this.m_Vertices); Gl.glDrawArrays(this.m_FaceMode,0,this.m_Vertices.Length); if(this.m_Normals==null) Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY); } #endregion VoidGl.m_UseVGl is used to switch between my custom bindings and Tao bindings (is used for testing purpose in my project)... Every Vector*F struct has a sequental layout... does anybody can spot something wrong? Am I doing a mistake somewhere? Thanks in advance... ^^ [Edited by - BladeWise on June 27, 2005 12:44:07 PM]
  6. Multitexturing problem

    Are you using vertex arrays? If so, you miss the glEnableClientState call... since you never spoke about VA, anyway I suppose you don't... this is the code I use in a test project to enable and use multitexturing... (it's C#) for(int i=0; i<this.m_TextureCount; i++) { Gl.glActiveTexture(Gl.GL_TEXTURE0+i); Gl.glBindTexture(Gl.GL_TEXTURE_2D,this.m_Textures[i].ID); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glClientActiveTexture(Gl.GL_TEXTURE0+i); //This is required if using VertexArrays } I do it for each object... obviusly it's not the best way, since for each object I need to enable and disable (if not textured) all units, but since it's a mere test, it's ok... a good way, AFAIK, is to sort your 3D entities depending on the texture they use... maybe can be useful to sort by tot textures *and* texture ID... so you could sort object from the one with less textures to the one with more ones, in every group, you can order by Texture ID... maybe there are better solutions though! :P
  7. Multitexturing problem

    The first unit should be GL_TEXTURE0_ARB, is there a meaning in enabling GL_TEXTURE1_ARB instead GL_TEXTURE1_ARB... Rememebr that, using multitexturing, means enabling (or disabling) every unit, that is needed (or not needed but active)... so, if you draw an object with 2 textures, and later you'll need only one, you must disable the corrispective texture unit... but maybe you just knew that :P Moreover, the skybox is rendered after the whole scene or before? (What I wanted to know is if the texture unit for the skybox is enabled beofre others, or after... in the second case, if the texture is messed up, it's possibloe that there is a not needed texture unit active... Hopes this help...^^'
  8. If you look at the examples folder, in the TAO sources, you'll find some NeHe examples translated in C#/TAO... there you'll see how to avoid using the Application.Run(new Form1()); method (that enables GDI main loop), using a custom application loop that, if I have understood, is what you need... you'll se that it's exactly like C++ examples... :D
  9. Please test my little demo

    That worked for me, really amusing! :D 40<FPS<80 P4 3.GHz 1GB RAM Radeon 9600 256MB
  10. multiple viewports

    I simply use glViewport, that works with no scissoring (as far as I know)... I suppose it's not applicable to your case, so what are these multiple viewports for?
  11. Vertex Array Format

    This is useful for me too! :P I had the same question, and this answer suits perfectly! :D Just tested it out... there is a good performance boost, in this way (and moreover it's the correct way! :D)
  12. Hi all, I am using TAO framework to create my OpenGL 3D engine, but I have a *little* problem with my custom binding to gl*Pointer functions... since I'm using Sharp3D library structures to store Vertices/Normals/TexCoord/Color data, I thought about creating a binding for this kind of data, avoiding pinning or else... but something is wrong, since even if my vertices are drawn correctly, normals and texture coords are not correct at all... copying data into a double[] and using gl*Pointer functions in the TAO binding, shows a correct result, so data is correct, but OpenGL receives messed up data... Just to add more, Vector*F and ColorF structures (the ones used in Sharp3D library) have a serial layout (I downloaded and rebuilt sources to make me sure about it)... I'll provide a snippet from my render cycle, and my bindings... hope someone could enlight me :( BINDINGS: [DllImport("opengl32.dll", EntryPoint="glVertexPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glVertexPointer(int size, int type, int stride, Vector3F[] vertices); [DllImport("opengl32.dll", EntryPoint="glTexCoordPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glTexCoordPointer(int size, int type, int stride, Vector2F[] coords); [DllImport("opengl32.dll", EntryPoint="glColorPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glColorPointer(int size, int type, int stride, ColorF[] colors); [DllImport("opengl32.dll", EntryPoint="glNormalPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)] public static extern void glNormalPointer(int type, int stride, Vector3F[] normals); RENDER: public virtual void Render() { if(this.m_Normals!=null) { Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY); VGl.glNormalPointer(Gl.GL_FLOAT,0,this.m_Normals); } else Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY); Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY); VGl.glVertexPointer(3,Gl.GL_FLOAT,0,this.m_Vertices); Gl.glDrawArrays(this.m_FaceMode,0,this.m_Vertices.Length); } Thnx in advance for every help :P
  13. OpenGL Materials

    Now it's clearer, so, It means that if I need two objects with the same color, but with different materials, I should switch glColorMaterial to the desidered one... let's say I have a "steel" red cube and a "plastic" red sphere... before rendering the second element, I need to change the glColorMaterial... but, if I have different objects with the same color and the same material, I can avoid glColorMaterial calling, is it right? Or better, I could initialize all my materials at the beginning associating them to a color, and then I could simply draw the scene with the correct color... am I right?
  14. OpenGL Materials

    I need some clarifications about materials in OpenGL... what is the difference between glColorMaterial and glMaterial? As far as I understand, the first is somehow "lighter", and binds materials properties to a color (am I wrong?)... so, I think setting a color, means setting a material, if GL_COLOR_MATERIAL is enabled... if so, glMaterial needs instead to be called every time I have to switch a material... is it so? I am a bit confused about this... :( Maybe too many infos in too few days! :P
  15. Multple ViewPorts

    I have made a C# implementation to support multiple viewports... it's a testing part fopr my simple 3D engine... I create a viewport class, and for each viewport object I associated a Camera object, everytime I render all the stuff, I simply set the viewport, the Camera view/projection, and then render the scene... Since I supposed every viewport could have a different backcolor, could use or not backface culling, textures and lights, I set these informations every time I render it... obviusly you could avoid the context refresh, if it's not needed! :D