• What do you need help with? Version 1
    5,001 replies, posted
Do you want me to upload the whole source? It's not a problem but I don't know if you want to look through it all.
[QUOTE=Darwin226;24732913]Do you want me to upload the whole source? It's not a problem but I don't know if you want to look through it all.[/QUOTE] If you don't mind, that would probably help. Also, try installing [url=http://sourceforge.net/projects/bugle/]bugle[/url]. OpenGL doesn't throw messages or exceptions when it errors unless you manually check after each call, which can make debugging really difficult. Bugle will tell you when something goes wrong and allow you to inspect the state of the GL context.
[QUOTE=ROBO_DONUT;24733159]If you don't mind, that would probably help. Also, try installing [url=http://sourceforge.net/projects/bugle/]bugle[/url]. OpenGL doesn't throw messages or exceptions when it errors unless you manually check after each call, which can make debugging really difficult. Bugle will tell you when something goes wrong and allow you to inspect the state of the GL context.[/QUOTE] :O This is pretty cool. Thanks for posting this.
[URL="http://anyhub.net/file/2src.rar"]Here it is.[/URL] Didn't include one class that is useless and the image that is loaded but the loading works correctly so that's not the issue. I know you don't do C# but since the OpenTK bindings are the same as the C API you shouldn't have a problem. Thanks in advance
[QUOTE=Darwin226;24733522][URL="http://anyhub.net/file/2src.rar"]Here it is.[/URL] Didn't include one class that is useless and the image that is loaded but the loading works correctly so that's not the issue. I know you don't do C# but since the OpenTK bindings are the same as the C API you shouldn't have a problem. Thanks in advance[/QUOTE] Ok, thanks for the source. My internet went out though so it might be a while before I can take a look at it (posting from phone).
Oh also, tell me everything you think is wrong, not just with OpenGL. Things like bad coding practices or just stupid stuff.
Hey, I've been working on a Source model decompiler and I have a little problems. Whenever I start writing to a file using fwrite with file paths I opened using fopen like this: "../parts/dmx/engineer_high.dmx.smd" or even "parts\dmx\football_helmet.dmx.smd" my application crashes. (the parts\dmx\ folders don't exist yet) Files in the root folder work like intended. I tried opening the file without writing to it and that didn't seem to crash. Here's some code similar to what I'm using: [code] printf( "Exporting to .smd: %s \n", "../parts/dmx/engineer_high.dmx.smd" ); smdfile = fopen( "../parts/dmx/engineer_high.dmx.smd" , "w" ); fprintf( "../parts/dmx/engineer_high.dmx.smd", "version %d\n", 1 ); //it crashes here [/code] Any ideas?
Making a little collaboration painting program, and I want to show people's info in a info box, I made a tcp connection and send this : [cpp] streamWriter.WriteLine("getName"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("name", streamReader.ReadLine()); else returnData.Add("name", "none"); streamWriter.WriteLine("getUsername"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("username", streamReader.ReadLine()); else returnData.Add("username", "none"); streamWriter.WriteLine("getAge"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("age", streamReader.ReadLine()); else returnData.Add("age", "none"); [/cpp] for some reason sometimes they don't arrive or not in the correct order, I always thought tcp was a secure/reliable connection :S any help ?
[QUOTE=Daimao;24736666]Hey, I've been working on a Source model decompiler and I have a little problems. Whenever I start writing to a file using fwrite with file paths I opened using fopen like this: "../parts/dmx/engineer_high.dmx.smd" or even "parts\dmx\football_helmet.dmx.smd" my application crashes. (the parts\dmx\ folders don't exist yet) Files in the root folder work like intended. I tried opening the file without writing to it and that didn't seem to crash. Here's some code similar to what I'm using: [code] printf( "Exporting to .smd: %s \n", "../parts/dmx/engineer_high.dmx.smd" ); smdfile = fopen( "../parts/dmx/engineer_high.dmx.smd" , "w" ); fprintf( "../parts/dmx/engineer_high.dmx.smd", "version %d\n", 1 ); //it crashes here [/code] Any ideas?[/QUOTE] You're trying to print to a string here. I think you want [cpp]printf( "%s is at version %d\n", "../parts/dmx/engineer_high.dmx.smd", 1 );[/cpp] [editline]11:00PM[/editline] Anyone know how to get a numeric type (char, short, int, long) that corresponds to the size of an enum? I tried a templated solution, like [cpp]IntForSize<sizeof(MyEnumType)>::Type[/cpp] Which would accordingly typedef Type to char, short, ..., but this would be a problem for platforms in which types are of the same size.
[QUOTE=ZeekyHBomb;24736977]You're trying to print to a string here. I think you want [cpp]printf( "%s is at version %d\n", "../parts/dmx/engineer_high.dmx.smd", 1 );[/cpp] [/QUOTE] I'm writing to a file, it's a model file header defining nodes such as this: [code] version 1 nodes 0 "static_prop" -1 end [/code] Oh and that printf in the first rule is just a console output so I can see what it's processing.
fprintf(FILE*, char*, ...) Well, that FILE* there is set to "../parts/dmx/engineer_high.dmx.smd" which will pretty much result in a mess. Now I see what you meant though. [cpp]fprintf( smdfile, "version %d\nnodes %d \"%s\"\t%d\nend", 1, 0, "static_prop", -1 );[/cpp]
Nevermind, I already fixed my problem. [code] void EnsureFileDirectoryExists( const char *pFilename ) { char dirName[MAX_PATH]; Q_strncpy( dirName, pFilename, sizeof( dirName ) ); Q_FixSlashes( dirName ); char *pLastSlash = strrchr( dirName, CORRECT_PATH_SEPARATOR ); if ( pLastSlash ) { *pLastSlash = 0; if ( _access( dirName, 0 ) != 0 ) { char cmdLine[512]; Q_snprintf( cmdLine, sizeof( cmdLine ), "md \"%s\"", dirName ); system( cmdLine ); } } } [/code] I used that to ensure the directory was in place before I started writing and now everything works perfectly. Thanks anyways!
[QUOTE=ROBO_DONUT;24734011]Ok, thanks for the source. My internet went out though so it might be a while before I can take a look at it (posting from phone).[/QUOTE] Oh, changed the render function to: [cpp] public void Render () { GL.Clear( ClearBufferMask.ColorBufferBit ); GL.ActiveTexture( TextureUnit.Texture0 + 0 ); GL.BindTexture( TextureTarget.Texture2D, Textures[ (int)TextureNames.Blank ].ID ); GL.Uniform1( Program.Locations[ "texture" ], 0 ); GL.EnableClientState( ArrayCap.VertexArray ); GL.BindBuffer( BufferTarget.ArrayBuffer, testBuffer.ID ); GL.VertexAttribPointer( Program.Locations[ "position" ], 4, VertexAttribPointerType.Float, false, 6 * sizeof( float ), 0 ); GL.VertexAttribPointer( Program.Locations[ "texcoord" ], 2, VertexAttribPointerType.Float, false, 6 * sizeof( float ), 4 * sizeof( float ) ); GL.EnableVertexAttribArray( Program.Locations[ "position" ] ); GL.EnableVertexAttribArray( Program.Locations[ "texcoord" ] ); GL.BindBuffer( BufferTarget.ElementArrayBuffer, elementBuffer.ID ); GL.DrawElements( BeginMode.Triangles, 4, DrawElementsType.UnsignedInt, 0 ); GL.DisableVertexAttribArray( Program.Locations[ "position" ] ); GL.DisableVertexAttribArray( Program.Locations[ "texcoord" ] ); SwapBuffers(); }[/cpp] It now draws, but only a half of the rectangle. The other triangle isn't drawn. I'll try and fix it later.
[QUOTE=ZeekyHBomb;24736977]Anyone know how to get a numeric type (char, short, int, long) that corresponds to the size of an enum? I tried a templated solution, like [cpp]IntForSize<sizeof(MyEnumType)>::Type[/cpp] Which would accordingly typedef Type to char, short, ..., but this would be a problem for platforms in which types are of the same size.[/QUOTE] I worked around it by using a switch(sizeof(MyEnumTyoe)) and case sizeof(char), case sizeof(short), ... But I do have a new problem concerning inherited operators: [cpp]class A { public: A& operator++(); }; class B : public A { }; void func() { B b1, b2 = ++b1; /* error: no viable conversion from 'A' to 'class B' B b1, b2 = ++b1; ^ ~~~~ note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A' to 'class B const' for 1st argument class B : public A ^ */ }[/cpp] I could write an operator++ into the class B, which simply calls the operator++ of class A, but that's kinda tedious. Anyone know a more beautiful solution?
No, but congrats on goldie :v:
[QUOTE=Chris220;24752350]No, but congrats on goldie :v:[/QUOTE] bleh Thanks. It's like an early birthday present :)
I am trying to edit data at a specific address. Reading seems to work fine. But when I edit it it seems to crash. But when using a memory editor it seems to work fine. [cpp] unsigned char *Addy1 = (unsigned char *)dllbase + X + 0; unsigned char *Addy2 = (unsigned char *)dllbase + X + 1; unsigned char *Addy3 = (unsigned char *)dllbase + X + 2; *Addy1 = 144; *Addy2 = 144; *Addy3 = 144; [/cpp] EDIT: And yes this injected in to the process
[QUOTE=quincy18;24736686]Making a little collaboration painting program, and I want to show people's info in a info box, I made a tcp connection and send this : streamWriter.WriteLine("getName"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("name", streamReader.ReadLine()); else returnData.Add("name", "none"); streamWriter.WriteLine("getUsername"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("username", streamReader.ReadLine()); else returnData.Add("username", "none"); streamWriter.WriteLine("getAge"); streamWriter.Flush(); Thread.Sleep(100); if (networkStream.DataAvailable) returnData.Add("age", streamReader.ReadLine()); else returnData.Add("age", "none"); for some reason sometimes they don't arrive or not in the correct order, I always thought tcp was a secure/reliable connection :S any help ?[/QUOTE] Quoting my question from the last page
[QUOTE=Darwin226;24739605]-[/QUOTE] Check SetupUniforms(). You're using GetUniformLocation for the vertex attributes "position" and "texcoord", when you should be using GetAttribLocation. Also, you've got four vertexes defined, one for each corner of a square. You cannot render this as GL_TRIANGLES, as this mode renders a triangle for every three verts and the fourth vert is ignored. You must use GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, or GL_QUADS.
But I render using the element array. Can't I do 0 1 2 2 3 0 so it uses the same vertex more than once? And I fixed the attribute thing, didn't even know there was glGetError :)
[QUOTE=Darwin226;24760084]Can't I do 0 1 2 2 3 0 so it uses the same vertex more than once?[/QUOTE] Better to use a triangle strip, so that the shared vertices don't have to be issued twice. If you make a triangle strip with vertices 1 0 2 3, you get triangles 1 0 2 and 0 2 3. (There's also GL_QUAD, but that's deprecated in current OpenGL versions.)
Ok, changed the element array to 1 0 2 3 and set the draw to triangle stip. Doesn't work and still doesn't explain why the last solution didn't work. I must be doing something else wrong, any ideas? Is there like a most common reason that only half the triangles are drawn? [editline]10:03PM[/editline] Quad doesn't work either.
[QUOTE=Darwin226;24760820]Ok, changed the element array to 1 0 2 3 and set the draw to triangle stip. Doesn't work and still doesn't explain why the last solution didn't work. I must be doing something else wrong, any ideas? Is there like a most common reason that only half the triangles are drawn? [editline]10:03PM[/editline] Quad doesn't work either.[/QUOTE] I believe the triangles have to be drawn in clockwise vertex order, but even so it wouldn't explain why half of them are visible :|
I'm going to try making a more complex mesh to see what happens.
[QUOTE=Darwin226;24760084]But I render using the element array. Can't I do 0 1 2 2 3 0 so it uses the same vertex more than once?[/QUOTE] Yeah, my bad. I was in a bit of a rush and ignored that you were drawing by index. It might be that it's exploding because you set position.w to zero. The w-component is used for perspective division. A very simple projection matrix might look something like this: [code] [1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 1 0] [/code] When you multiply a vector by this matrix, the w-component is set to the z-component. So if you put in <x, y, z, w>, you get out <x, y, z, z>. OpenGL automatically divides all the components by the w-component, so that objects appear smaller at a distance. The end result is <x/z, y/z, z/z, z/z>. If w is set to zero and you don't use a projection matrix like the one described above, then you get <x/0, y/0, z/0, 0/0>, which obviously causes problems. It's good practice to set w=1 as the default value.
[cpp] testMesh.Vertices = new Vertex[ 5 ] { new Vertex( 0, 0, 0, 0, 0 ), new Vertex( 1, 0, 0, 1, 0 ), new Vertex( 1, 1, 0, 1, 1 ), new Vertex( 0, 1, 0, 0, 1 ), new Vertex(-1, 0.5F, 0, 0, 0) }; testMesh.IndexArray = new uint[ 5 ] { 0, 1, 2, 3, 4 };[/cpp] Draws the whole quad but not the last vertex, that is supposed to stick out to the left... Thinking it's just not drawing the last point. Would anyone mind making something more complex than that and posting it here? I'm not really that good at making a mesh just by typing numbers yet. [editline]10:48PM[/editline] Setting w to 1 didn't help. Can't say more since I never understood the w coordinate, I think I'm missing some crucial math behind it seeing as I only recently thought my self how to multiply matrices with vectors.
[QUOTE=esalaka;24761010]I believe the triangles have to be drawn in clockwise vertex order, but even so it wouldn't explain why half of them are visible :|[/QUOTE] Culling is disabled by default, so that wouldn't be a problem. That doesn't stop it from being bad practice though.
So guys, any other ideas? [editline]12:24AM[/editline] Ok, so I made a loop that generates a circle and it again, renders all but the last triangle. Very strange... Edit: Disregard that, I increased the circles resolution and now the last 4 or 5 triangles aren't drawn. [editline]12:29AM[/editline] [cpp] double i = 0; while ( i < 2 * Math.PI ) { list.Add( new Vertex( (float)Math.Cos( i ), (float)Math.Sin( i ), 0, (float)Math.Cos( i ), (float)Math.Sin( i ) ) ); list2.Add( (uint)list2.Count ); i += Math.PI / 1000; }[/cpp] Anything wrong with this? It looks like the last, I don't know, 1/8 of the circle isn't drawn. If I set the loop to 3*Math.PI then it draws the whole thing. [editline]12:38AM[/editline] Yeah... fixed it. It was a typo thing. [editline]01:26AM[/editline] Ok, there's one more thing. How do I get the correct texcoord for every fragment? I can set the texcoords for vertices but how and where are the fragments in between them calculated?
The first TabPage of my TabControl isn't drawing properly, but does when put it in a different order, any ideas why?
[QUOTE=Darwin226;24763278]Ok, there's one more thing. How do I get the correct texcoord for every fragment? I can set the texcoords for vertices but how and where are the fragments in between them calculated?[/QUOTE] The "varying" qualifier specifies that values are automatically interpolated before they are passed to the fragment shader. You create a value "varying vec2 texcoord" and set it in the vertex shader, then read it in the fragment shader.
Sorry, you need to Log In to post a reply to this thread.