• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=reevezy67;44348998]Playing with OpenGL/GLSL, how do I debug shaders?[/QUOTE] [CODE] //[compile vertexshader] //VertexShader char messages[256]; glGetShaderInfoLog(VertexShaderId, sizeof(messages), 0, &messages[0]); //[compile fragmentshader] //FragementShader char messages[256]; glGetShaderInfoLog(FragmentShaderId, sizeof(messages), 0, &messages[0]); //[link the shader] //program char messages[256]; glGetProgramInfoLog(ProgramId, sizeof(messages), 0, &messages[0]); [/CODE]
[QUOTE=reevezy67;44348998]Playing with OpenGL/GLSL, how do I debug shaders?[/QUOTE] What do you mean? As in debug values as you would with `printf`ing? Then you're probably better off with setting the final colour. Or you can play around [url=http://glsl.heroku.com/]in online editor[/url]. Or you can write so that you know what every thing does, what it returns, where it gets used so you don't need to debug.
rendermonkey from AMD might be usefull ?
I started using AMD's CodeXL tool for my OpenGL stuff, it's pretty good.
[QUOTE=BackwardSpy;44350456]I started using AMD's CodeXL tool for my OpenGL stuff, it's pretty good.[/QUOTE] thx for that tip :) Edit: is it bound to amd hardware ? or does intel and nvidia stuff works too ? Edit 2: It works pretty awesome :)
[QUOTE=vombatus;44350368]Or you can write so that you know what every thing does, what it returns, where it gets used so you don't need to debug.[/QUOTE] What is that supposed to mean? "Hey man, just don't write any bugs."
you guys know any good alternative ( if possible free ) to ms visio ? I want to create some graphs, and diagrams and stuff but my visio is lost after reinstall of OS ...
[QUOTE=Z_guy;44350628]What is that supposed to mean? "Hey man, just don't write any bugs."[/QUOTE] It is possible, but you then don't actually write code until everything else is done before (archihecture, flowcharts and such stuff) And you would use very strongly typed language like F#, which usually runs without bugs if it compiles correctly :) But still not 100%, we are only human [editline]25th March 2014[/editline] [QUOTE=Pappschachtel;44351638]you guys know any good alternative ( if possible free ) to ms visio ? I want to create some graphs, and diagrams and stuff but my visio is lost after reinstall of OS ...[/QUOTE] [url]https://www.lucidchart.com/users/registerLevel[/url] (2 minute googling)
Hey I'm back again with some more OpenGL problems. I finally got my box to render correctly (I was having lots of trouble with the render depth, things were rending on top of things that were in front of them) using this code: [CODE]glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glDepthRange(0.0f, 1.0f); while (!glfwWindowShouldClose(window)) { angle+= 0.01; glfwGetFramebufferSize(window, &width, &height); // ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(angle, 1.0f, 1.0f, .0f); glBegin(GL_QUADS); //The side closest to the camera glColor3f(.0f, 0.0f, 0.5f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(.5f, .5f, -0.1f); glVertex3f(.5f, -.5f, -0.1f); glVertex3f(-.5f, -.5f, -0.1f); glColor3f(.5f, 0.0f, 0.0f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(-.5f, -.5f, 0.1f); glColor3f(.0f, 0.5f, 0.0f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, .5f, -0.1f); // glVertex3f(-.5f, -.5f, -0.1f); glVertex3f(-.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, -0.1f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(-.5f, -.5f, 0.1f); glVertex3f(-.5f, -.5f, -0.1f); glVertex3f(.5f, .5f, -0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, -0.1f); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }[/CODE] My question is, how do I go about displaying an image on one of the faces of the box? I did some research and everyone was talking about texture mapping and buffers and I was having trouble following what they were saying. From what I gathered, I have to get a library to load the image into the graphics buffer, and then call a bunch of OpenGL functions in order to load that buffer as a texture apply that texture to one of the shapes that I am drawing. My main issue if finding a library to load the image, and figuring out the order of the OpenGL functions to call. I already tried using the SOIL library but when I tried to use it something broke inside of the library. Any help or sample code would be a huge aid here. Long term, what I'm working towards is rendering a 3D environment where the camera angles are controlled by the mouse, and I can tell when the camera is looking at a specific object (when the user presses a button, I want the object that he is looking at to change color/texture).
[QUOTE=Killdozer;44354072]//...[/QUOTE] Any reason why you are using Compatibility profile (old OpenGL)? Anyway i still recommend [url]http://www.opengl-tutorial.org/[/url] to people new to openGL.
[QUOTE=Killdozer;44354072]Hey I'm back again with some more OpenGL problems. I finally got my box to render correctly (I was having lots of trouble with the render depth, things were rending on top of things that were in front of them) using this code: [CODE]glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glDepthRange(0.0f, 1.0f); while (!glfwWindowShouldClose(window)) { angle+= 0.01; glfwGetFramebufferSize(window, &width, &height); // ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(angle, 1.0f, 1.0f, .0f); glBegin(GL_QUADS); //The side closest to the camera glColor3f(.0f, 0.0f, 0.5f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(.5f, .5f, -0.1f); glVertex3f(.5f, -.5f, -0.1f); glVertex3f(-.5f, -.5f, -0.1f); glColor3f(.5f, 0.0f, 0.0f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(-.5f, -.5f, 0.1f); glColor3f(.0f, 0.5f, 0.0f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, .5f, -0.1f); // glVertex3f(-.5f, -.5f, -0.1f); glVertex3f(-.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, -0.1f); glVertex3f(-.5f, .5f, -0.1f); glVertex3f(-.5f, .5f, 0.1f); glVertex3f(-.5f, -.5f, 0.1f); glVertex3f(-.5f, -.5f, -0.1f); glVertex3f(.5f, .5f, -0.1f); glVertex3f(.5f, .5f, 0.1f); glVertex3f(.5f, -.5f, 0.1f); glVertex3f(.5f, -.5f, -0.1f); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }[/CODE] My question is, how do I go about displaying an image on one of the faces of the box? I did some research and everyone was talking about texture mapping and buffers and I was having trouble following what they were saying. From what I gathered, I have to get a library to load the image into the graphics buffer, and then call a bunch of OpenGL functions in order to load that buffer as a texture apply that texture to one of the shapes that I am drawing. My main issue if finding a library to load the image, and figuring out the order of the OpenGL functions to call. I already tried using the SOIL library but when I tried to use it something broke inside of the library. Any help or sample code would be a huge aid here. Long term, what I'm working towards is rendering a 3D environment where the camera angles are controlled by the mouse, and I can tell when the camera is looking at a specific object (when the user presses a button, I want the object that he is looking at to change color/texture).[/QUOTE] Could you be more specific on what broke in SOIL, possibly paste some errors? Because IMO it's the best image loading library.
[QUOTE=Pappschachtel;44350355][CODE] //[compile vertexshader] //VertexShader char messages[256]; glGetShaderInfoLog(VertexShaderId, sizeof(messages), 0, &messages[0]); //[compile fragmentshader] //FragementShader char messages[256]; glGetShaderInfoLog(FragmentShaderId, sizeof(messages), 0, &messages[0]); //[link the shader] //program char messages[256]; glGetProgramInfoLog(ProgramId, sizeof(messages), 0, &messages[0]); [/CODE][/QUOTE] I meant logical errors not build errors, I already do that. I guess there is no good way of doing it.
Does anyone have any good resources for understanding variable scope in Python? I'm struggling with it at the moment. Declaring Global variablename everywhere seems really messy and i'm sure there has to be a better way to do it.
[QUOTE=reevezy67;44358146]I meant logical errors not build errors, I already do that. I guess there is no good way of doing it.[/QUOTE] Try CodeXL from AMD as already suggested.
[QUOTE=Pappschachtel;44359362]Try CodeXL from AMD as already suggested.[/QUOTE] I would but my laptop is Intel/Nvidia. I could use my desktop but I don't like developing on it. I prefer programming outside. I'll give the Intel and Nvidia tools a go but I've heard AMD has the best ones.
[QUOTE=reevezy67;44360058]I would but my laptop is Intel/Nvidia. I could use my desktop but I don't like developing on it. I prefer programming outside. I'll give the Intel and Nvidia tools a go but I've heard AMD has the best ones.[/QUOTE] I'm fairly certain CodeXL works on all hardware. It's just gDEBugger except it's developed by AMD now.
Ah great thanks, it does work. Although it's not fully supported on my GPU it looks like most of the features work. [editline]27th March 2014[/editline] I understand it's difficult to achieve but I wish you could step through a shader.
Is making a simple CAS super hard? I've made a infix -> RPN convertor, but it only works with numbers. I'd like it to operations like x*x -> x^2.
[QUOTE=reevezy67;44360113]Ah great thanks, it does work. Although it's not fully supported on my GPU it looks like most of the features work. [editline]27th March 2014[/editline] I understand it's difficult to achieve but I wish you could step through a shader.[/QUOTE] VS 2012/2013 let you do this, but only with Direct3D unfortunately. It's incredibly handy for when I'm doing DirectX work, but all said I done I tend to prefer OpenGL for 3D stuff. v:v:v
[QUOTE=reevezy67;44360113]Ah great thanks, it does work. Although it's not fully supported on my GPU it looks like most of the features work. [editline]27th March 2014[/editline] I understand it's difficult to achieve but I wish you could step through a shader.[/QUOTE] Also already mentioned: [URL="http://developer.amd.com/tools-and-sdks/archive/legacy-cpu-gpu-tools/rendermonkey-toolsuite/"]AMD's RenderMonkey[/URL] EDIT: Found this one too: [url]http://developer.amd.com/tools-and-sdks/graphics-development/gpu-shaderanalyzer/[/url]
Reposing here, I'm having a problem with SFML relating to keeping GUI related stuff in a DLL (stuff not rendering as it should under weird circumstances). [URL="http://en.sfml-dev.org/forums/index.php?topic=14770.0"]http://en.sfml-dev.org/forums/index.php?topic=14770.0[/URL] I'd love any advice.
[QUOTE=Bumrang;44355368]Could you be more specific on what broke in SOIL, possibly paste some errors? Because IMO it's the best image loading library.[/QUOTE] Sorry for the long pause between replies. This is what happens when I try to set up SOIL. [img_thumb]http://puu.sh/7LV28.png[/img_thumb] EDIT: I changed the link order around and now it compiles fine. What is the best way to apply this texture to a polygon? Right now this is my code: To load the image: [CODE]GLuint tex_2d = SOIL_load_OGL_texture ( "img.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT );[/CODE] To "bind" the texture name (i'm not sure what this even does): [CODE]glGenTextures(1, &m_texname); glBindTexture(GL_TEXTURE_2D, m_texname);[/CODE] Drawing the polygon with the texture on it: [CODE]glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-0.5f, -0.5f, 0.0f); glTexCoord2f(1, 0); glVertex3f(-0.5f, 0.5f, 0.0f); glTexCoord2f(1, 1); glVertex3f(0.5f, 0.5f, 0.0f); glTexCoord2f(0, 1); glVertex3f(0.5f, -0.5f, 0.0f); glEnd()[/CODE] This compiles and runs without error, but it doesn't draw the texture onto the quad.
[QUOTE=Killdozer;44374355]Sorry for the long pause between replies. This is what happens when I try to set up SOIL. [img_thumb]http://puu.sh/7LV28.png[/img_thumb][/QUOTE] You need to link to opengl, and possibly glu as well
[QUOTE=Richy19;44374460]You need to link to opengl, and possibly glu as well[/QUOTE] I figured out I had to link in the following order [CODE]libSOIL.a glfw3dll.a libopengl32.a libgdi32.a libglu32.a libglfw3.a[/CODE] [editline]27th March 2014[/editline] Well I suppose the reason why it wasn't doing anything was I forgot to move the image to the new project directory. Now the process just freezes up and crashes when I try to run it. This is the part of my code where the problem seems to be: [CODE] GLuint tex_2d; //Enable texture drawing glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //Set up the texture in opengl glGenTextures(1, &tex_2d); //Load the image into graphics buffer glBindTexture(GL_TEXTURE_2D, tex_2d); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); tex_2d = SOIL_load_OGL_texture ( "img.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT ); //glTexImage2D is not needed when using SOIL_load_OGL_texture //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_INT, &tex_2d);[/CODE] This is the part where I am drawing the polygon: [CODE] while (!glfwWindowShouldClose(window)) { angle+= 0.01; glfwGetFramebufferSize(window, &width, &height); // ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(angle, 1.0f, 1.0f, .0f); glBegin(GL_QUADS); glColor3f(.0f, 0.0f, 0.5f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5f, .5f, -0.1f); glTexCoord2f(1.0f, 1.0f); glVertex3f(.5f, .5f, -0.1f); glTexCoord2f(1.0f, 0.0f); glVertex3f(.5f, -.5f, -0.1f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-.5f, -.5f, -0.1f); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } [/CODE]
I have made a class for all my shared preferences stuff: [code] public static Boolean getSavedBool(String key, Boolean bool){ sharedPrefs = context.getSharedPreferences("AppValues",0); Boolean returnBool = sharedPrefs.getBoolean(key, (Boolean) true <---- thats the part i DONT get. What is that for?); return (Boolean) returnBool; } [/code] The second argument in getBoolean is what I dont get.. Does it return a value if the boolean set in that arguments is true or false? ALl I want to do is call it and have the boolean returned... [editline]27th March 2014[/editline] Jesus christ of hell, all this time it was my logic which was confusing me. Please ignore the ludicrously retarded post [editline]27th March 2014[/editline] Jesus christ of hell, all this time it was my logic which was confusing me. Please ignore the ludicrously retarded post
So why does everyone suggest implementing IDisposable like this: [code] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // dispose of your things } _disposed = true; } } [/code] Why not just do this? [code] public void Dispose() { if (!_disposed) { // dispose of your things _disposed = true; } GC.SuppressFinalize(this); } [/code]
[QUOTE=Goz3rr;44376268]So why does everyone suggest implementing IDisposable like this: [code] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // dispose of your things } _disposed = true; } } [/code] Why not just do this? [code] public void Dispose() { if (!_disposed) { // dispose of your things _disposed = true; } GC.SuppressFinalize(this); } [/code][/QUOTE] Because in the first example you're also supposed to call Dispose from the destructor: [code] ~MyClass() { Dispose(false); } [/code] [editline]27th March 2014[/editline] [url]http://stackoverflow.com/questions/628752/why-call-disposefalse-in-the-destructor[/url]
[QUOTE=Goz3rr;44376268]So why does everyone suggest implementing IDisposable like this: [...][/QUOTE] Also see this: [URL="http://msdn.microsoft.com/en-us/library/ms244737.aspx"]CA1063: Implement IDisposable correctly[/URL] A good deal of the branching is for managed vs. unmanaged resources. Managed resources are invalid when the finalizer runs (with few exceptions), so you [U]must not[/U] use it to dispose of them. (Exceptions in the GC thread are silently ignored, but they still slow down the program.) If you don't have unmanaged resources and some disposable finalized ones, only implement [I]Dispose()[/I] and don't touch the GC. This is to free resources synchronously since there's no RAII in C#/CLR. If you have unmanaged resources, you [U]must[/U] free those at the very least from the finalizer, but it's good practise to also offer a way to free them synchronously. If you have unmanaged resources that must be freed on the same thread, your best bet is to queue them up somewhere if the finalizer runs, since the GC usually runs on a different thread. (I did this in [URL="https://bitbucket.org/Tamschi/ootk/src"]OOTK[/URL], it works well. I [I]probably[/I] should offer [I]IDisposable[/I] too though.)
[QUOTE=Tamschi;44380549] If you have unmanaged resources, you [U]must[/U] free those at the very least from the finalizer, but it's good practise to also offer a way to free them synchronously. [/QUOTE] I'm using OpenTK too, but you can't free them from the finalizer because by that time the graphics context is invalid, what i'm doing right now: [code] public class VertexBuffer : IDisposable { private uint id; public uint ID { get { if(id == 0) GL.GenBuffers(1, out id); return id; } } ~VertexBuffer() { Debug.Assert(id == 0, this + " leaked!"); } public void Dispose() { if(id != 0) { GL.DeleteBuffer(id); id = 0; } } [/code]
[QUOTE=Tamschi;44380549]Also see this: [URL="http://msdn.microsoft.com/en-us/library/ms244737.aspx"]CA1063: Implement IDisposable correctly[/URL] A good deal of the branching is for managed vs. unmanaged resources. Managed resources are invalid when the finalizer runs (with few exceptions), so you [U]must not[/U] use it to dispose of them. (Exceptions in the GC thread are silently ignored, but they still slow down the program.) If you don't have unmanaged resources and some disposable finalized ones, only implement [I]Dispose()[/I] and don't touch the GC. This is to free resources synchronously since there's no RAII in C#/CLR. If you have unmanaged resources, you [U]must[/U] free those at the very least from the finalizer, but it's good practise to also offer a way to free them synchronously. If you have unmanaged resources that must be freed on the same thread, your best bet is to queue them up somewhere if the finalizer runs, since the GC usually runs on a different thread. (I did this in [URL="https://bitbucket.org/Tamschi/ootk/src"]OOTK[/URL], it works well. I [I]probably[/I] should offer [I]IDisposable[/I] too though.)[/QUOTE] Gonna piggy back off of Goz3rr's question here but what are COM objects? Does GC automatically clean them up or do I manually have to release them like unmanaged objects and if so is Marshal.ReleaseComObject really as bad as GC.Collect like I've been hearing?
Sorry, you need to Log In to post a reply to this thread.