• What do you need help with? Version 5
    5,752 replies, posted
In Java for arrays I believe its typename[][] variablename rather than typename variablename[][] when initializing an array.
[QUOTE=darkrei9n;35845927]In Java for arrays I believe its typename[][] variablename rather than typename variablename[][] when initializing an array.[/QUOTE] I don't think so, I've used arrays in the past and have always done it like this, only difference is that they were String arrays rather than Rectangle Arrays
[QUOTE=download;35846017]I don't think so, I've used arrays in the past and have always done it like this, only difference is that they were String arrays rather than Rectangle Arrays[/QUOTE] Check the documentation. Just looked at it, it should be rectangle[][]
[QUOTE=Richy19;35835192]Does anyone have by any chance a sample premake4 script file for creating dynamic libraries?[/QUOTE] [code] solution "SOLUTION" project "PROJ" kind "SharedLib" -- Dynamic Library --kind "StaticLib" -- Static Library --kind "WindowedApp" -- No console window --kind "ConsoleApp" -- Console Window [/code] I assume you know the rest?
[QUOTE=darkrei9n;35846060]Check the documentation. Just looked at it, it should be rectangle[][][/QUOTE] If that was the problem I'll be so fucked off :v: [editline]6th May 2012[/editline] Nope, not working [editline]6th May 2012[/editline] Netbeans won't recognise "rectangle", but it will "Rectangle"
[code] for(int i = 0; i <= window.getSize().x; i++) { int a = window.getSize().y; int b = window.getSize().x; sf::Vertex vertices[] = { sf::Vertex(sf::Vector2f( i, 0), sf::Color::Green, sf::Vector2f( 0, 0)), sf::Vertex(sf::Vector2f( i, a - ((a>b)?b:a / (a<b)?b:a) * i), sf::Color(255 / a * ((a>b)?b:a / (a<b)?b:a), 128, 128), sf::Vector2f( 1, 1)) }; window.draw(vertices, 4, sf::Lines); } window.display(); [/code] For some reason, this only draws 1 line at x=0. When I didn't make it safe for resized windows yet, so 600 instead of a and 800 instead of b it worked for some reason. The point is to make a sort of triangle filling half the screen Don't tell me I can just use 1 triangle, I am planning to be able to control the individual sizes of each line Using SFML if it wasn't obvious enough already
[QUOTE=darkrei9n;35845927]In Java for arrays I believe its typename[][] variablename rather than typename variablename[][] when initializing an array.[/QUOTE] Both work in Java. The Java tutorials on the Oracle website only briefly mention this at the beginning, then they use "Type[] variable" for the rest of the tutorials. I've never seen another tutorial even mention it.
If I have an abstract class and another one publicly inheriting from it, what will the derived class inherit? Public and protected datamembers? Also do I have to implement a constructor for the abstract class?
[QUOTE=Number-41;35853867]If I have an abstract class and another one publicly inheriting from it, what will the derived class inherit? Public and protected datamembers? [/QUOTE] I think public inheriting just means the child class inherits everything as-is. Other sorts of inheritance [url=http://www.parashift.com/c++-faq-lite/private-inheritance.html]are fucking complex[/url].
For some reason if I have a static class inside the class that defines it, its fine [cpp] namespace SOGLF { class WindowSettingsClass { WindowSettingsClass(); public: std::string Title; int Height, Width; short OGLMajor, OGLMinor; short rBits, gBits, bBits, aBits; short depthBufferBits, stencilBufferBits; bool FullScreen; int AntiAliasing; int FramesPerSecond; bool HideMouse; static WindowSettingsClass Settings; }; } [/cpp] but if I have the static class in the namespace directly, it doesnt work. [cpp] namespace SOGLF { class WindowSettingsClass { public: WindowSettingsClass(); std::string Title; int Height, Width; short OGLMajor, OGLMinor; short rBits, gBits, bBits, aBits; short depthBufferBits, stencilBufferBits; bool FullScreen; int AntiAliasing; int FramesPerSecond; bool HideMouse; }; static WindowSettingsClass Settings; } [/cpp] By this I mean for example I change the title but it doesnt take effect, and the title set in the constructor gets used.
I'm trying to use OpenCL -> OpenGL interop, however i have pretty much 0 knowledge of OpenGL. Currently, i'm using SFML to set up the window (there doesn't appear to be anything special needed to make it work with opengl) Unfortunately opencl is telling me that i've allocated my buffer wrong. I don't know what's wrong with it, anyone fancy taking a look? The code goes: [cpp] glGenTextures(1 ,&gltscreen_id); glBindTexture(GL_TEXTURE_2D, gltscreen_id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2048, 2048, 0, GL_RGB, GL_FLOAT, NULL); gscreen_rgb=clCreateFromGLTexture2D(cl::context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, gltscreen_id, &cl::error); [/cpp] Edit: Might be this bug: [url]http://www.opengl.org/wiki/Common_Mistakes#Render_To_Texture[/url] Though i honestly have no idea what texture completeness is Edit 2: Turns out it was the issue of 'texture completeness' (seems rather arbitrary but there you go). Changed the code to: [cpp] glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, 2048,2048,0, GL_RGBA,GL_FLOAT,NULL);[/cpp] Edit 3: I've been trying to work out how on earth i draw a 2d texture to the screen using non immediate mode. Does anyone have any idea how I can do this? Currently I'm trying to see how you might store a quad and then draw that quad textured, but the OpenGL API is obtuse and completely unclear as to how you might do this Edit 4: Going down the FBO route. Turns out the functions don't really exist by default, so you have to import them manually with: [cpp] PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT"); PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT"); PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress("glGenRenderbuffersEXT"); PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT"); PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)wglGetProcAddress("glRenderbufferStorageEXT");[/cpp]
[QUOTE=Richy19;35854489]For some reason if I have a static class inside the class that defines it, its fine <code> By this I mean for example I change the title but it doesnt take effect, and the title set in the constructor gets used.[/QUOTE] You need to create a function to access the static variable. For example: SOGLF.h: [cpp]namespace SOGLF { static WindowSettingsClass Settings; WindowSettingsClass* GetWindowSettings(); }[/cpp] SOGLF.cpp [cpp]WindowSettingsClass* SOGLF::GetWindowSettings(){ return &Settings; }[/cpp] And then use GetWindowSettings() whenever you want to use your Settings variable.
snip
[QUOTE=Naelstrom;35864891]You need to create a function to access the static variable. For example: SOGLF.h: [cpp]namespace SOGLF { static WindowSettingsClass Settings; WindowSettingsClass* GetWindowSettings(); }[/cpp] SOGLF.cpp [cpp]WindowSettingsClass* SOGLF::GetWindowSettings(){ return &Settings; }[/cpp] And then use GetWindowSettings() whenever you want to use your Settings variable.[/QUOTE] Ohh, that gives me the same inconvenence as just having the static variable in the class. I will just keep it as it is
I'm trying to get the angle between 2 lines. So usually I'd go result = secondAngle - firstAngle; However if the second angle is negative, and the first is positive, I get the wrong answer. Eg. -3-5 = -8. In my program it should be 2. [URL]http://blog.lexique-du-net.com/index.php?post/Calculate-the-real-difference-between-two-angles-keeping-the-sign[/URL] This link didn't help :/ My code [CODE]//the horizontal float difference = (angles2.z - angles.z); z = RAD2DEG(difference); weaponAngleOffset.z = z;[/CODE]
[QUOTE=JLea;35869068]I'm trying to get the angle between 2 lines. So usually I'd go result = secondAngle - firstAngle; However if the second angle is negative, and the first is positive, I get the wrong answer. Eg. -3-5 = -8. In my program it should be 2. [URL]http://blog.lexique-du-net.com/index.php?post/Calculate-the-real-difference-between-two-angles-keeping-the-sign[/URL] This link didn't help :/ My code [CODE]//the horizontal float difference = (angles2.z - angles.z); z = RAD2DEG(difference); weaponAngleOffset.z = z;[/CODE][/QUOTE] From your link: [quote] if you only want to know the absolute difference then you can use [code] DEL = PI - ABS(PI - ABS(A - B)) in radians. DEL = 180 - ABS(180- ABS(A - B)) in degrees. [/code] [/quote] I believe that's what you're asking for, no?
Well no, because the final angle offset should range from - (on the left) to positive (on the right). Unless I need to use a dot product? [editline]8th May 2012[/editline] Oh yeah, I just needed to use a dot product to see where I was facing and then multiply the final result based on what I got. Thanks
Well, I have some dumb question. How do I create a vector of Sprites using SFML and vector header? i started the vector like vector<sf::Sprite> test; and Im trying to do a push_back(), but i dont know what i need to put inside the "()". Anyway, my vector will be 41x31, so there is a way t do something like vector<vector<sf::Sprite> > test (41,vector<sf::Sprite>(31,??)) ?
[QUOTE=Mete;35872718]Well, I have some dumb question. How do I create a vector of Sprites using SFML and vector header? i started the vector like vector<sf::Sprite> test; and Im trying to do a push_back(), but i dont know what i need to put inside the "()". Anyway, my vector will be 41x31, so there is a way t do something like vector<vector<sf::Sprite> > test (41,vector<sf::Sprite>(31,??)) ?[/QUOTE] [cpp] vector<sf::Sprite> test; sf::Texture t; t.loadFromFile("foo.png"); sf::Sprite s(t); test.push_back(s); [/cpp] [editline]8th May 2012[/editline] If the size is always going to be 41x31 you are probably better of just using an array. Also if this is just for background have a look at sf::VertexArray [editline]8th May 2012[/editline] If in OpenGL(2.1) I have a scene like the left, therefore the user views the right. Does the cube actually get rendered? [IMG]http://i.imgur.com/T6FK8.png[/IMG] The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?
[QUOTE=Richy19;35872991] If in OpenGL(2.1) I have a scene like the left, therefore the user views the right. Does the cube actually get rendered? [IMG]http://i.imgur.com/T6FK8.png[/IMG] The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?[/QUOTE] The GPU renders exactly what you tell it to, regardless of position. You'd have to devise your own culling method to reduce objects/faces/etc.
[QUOTE=Richy19;35872991]The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?[/QUOTE] So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?
[code] float d; int v; float a; float b; float c; for(int p = 0; p < 1; p++) { v = rand(); a = sin(v); b = cos(v); d = sqrt(pCols*pCols + pRows*pRows); c = (rand() / RAND_MAX) * d - d/2; for(int i = 0; i < pCols * pRows; i++) { if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0) { vertexLoad[i].position.y += 1; } else { vertexLoad[i].position.y -= 1; } } } [/code] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.
[QUOTE=layla;35874570]So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?[/QUOTE] It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them
[QUOTE=darkrei9n;35874815] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.[/QUOTE] Most likely a floating point exception.
[QUOTE=dajoh;35874950]Most likely a floating point exception.[/QUOTE] Access Violation.
[QUOTE=Richy19;35874928]It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them[/QUOTE] No, you're still drawing faces that you don't need, just don't add them.
Is there a standard way in my .NET (C#) application of telling nVidia to use the main graphics card on laptops with both an integrated crap card and main powerful one? I've been doing it manually through the nVidia control panel but it would be nice if users wouldn't have to.
[QUOTE=darkrei9n;35874815][code] float d; int v; float a; float b; float c; for(int p = 0; p < 1; p++) { v = rand(); a = sin(v); b = cos(v); d = sqrt(pCols*pCols + pRows*pRows); c = (rand() / RAND_MAX) * d - d/2; for(int i = 0; i < pCols * pRows; i++) { if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0) { vertexLoad[i].position.y += 1; } else { vertexLoad[i].position.y -= 1; } } } [/code] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.[/QUOTE] Debug it, see what the variables are set to when it throws an error.
[QUOTE=Protocol7;35877398]Debug it, see what the variables are set to when it throws an error.[/QUOTE] Already figured it out. Had some code after it that was causing it. I do not know why it threw the error there though. [code] for(int y = 0; y < pCols*pRows; y++) { vertexLoad[i].color = RED; } [/code] I was using i instead of y.
I am trying to get threads to work, and have a few questions. Firstly, I am trying to get a thread to use a function in a class(the thread is being created in a class as well). How can I get the function to cause the thread to sleep? I have this right now: [cpp]boost::this_thread.sleep(boost::posix_time::millisec(80));[/cpp] But the compiler says that "this_thread" is illegal use of namespace identifier in expression. Secondly, will a thread delete itself once it's finished running a function? And if a thread goes out of scope, will it get deleted even if the thread is still running? If so, what kind of pointer would I use for the thread to exist until it is done running. Edit: I accidentally used .sleep instead of ::sleep. Now, how can I use a function defined in a class to pass to a thread? Do I have to make the function static? I used boost::bind to make it work.
Sorry, you need to Log In to post a reply to this thread.