• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Chryseus;40656769][t]http://u.cubeupload.com/Chryseus/1TBs7I.png[/t] Any suggestions on managing code and class layout, I keep ending up losing track of where I am.[/QUOTE] The way I have it set up for shaders/programs/textures/etc is that the constructor calls glGen* and does the initialization, and the destructor (technically Dispose, since I'm working in C#) calls glDelete. You'd have to make sure your context doesn't get deleted before the destructor is called though, but the benefit of not having to check the *_loaded or *_compiled is worth it IMO. Additionally, most of the time my constructors are private and I expose public static methods for initialization (ie Texture.FromFile, Texture.FromBitmap, Texture.FromRawData).
[QUOTE=Darkwater124;40656144][code]local clock = os.clock function sleep(n) -- seconds local t0 = clock() while clock() - t0 <= n do end end ... while true do ... sleep(0.02) end [/code] I guess[/QUOTE] That's not sleeping, that's busy waiting - simply wasting all processing power on doing nothing! Sleeping needs an OS-level function.
[QUOTE=Darkwater124;40656736]By the way, does anyone know anything about [url=http://terralang.org/]Terra[/url]? Is it usable? Could I remake the server in this?[/QUOTE] It doesn't support Windows. Other than that it is perfectly usable and you could create anything you wanted to, really. It's basically C/C++ that looks like and integrates tightly with Lua. [editline]15th May 2013[/editline] Also, [url]http://lua-users.org/wiki/SleepFunction[/url]
Someone could help me how to install Boost C++ to my Code::Blocks(MinGW)? I tried to use the bjam but it says that are a incompatible "kernel" (something like that, don't remember exactly...mismatches). If you can help me, you will save me. Thanks.
im using slick 2d for a little java game but im stuck on a sprite sheet thing [code] @Override public void init(GameContainer container) throws SlickException { int x; int y; player = new Animation(); player.setAutoUpdate(true); SpriteSheet sheet = new SpriteSheet("res/Actor_grn_R.png",50,50); int tX = 0; int tY = 0; for (int row=1;row<1;row++) { tX = 1; for(int col=4;col<5;col++){ tX++; player.addFrame(sheet.getSprite(tX,tY), 1); System.out.println("Tx: "+tX+", Ty: "+tY); } tY++; }[/code] When I run this the game crashes with this [code]Wed May 15 22:57:18 EDT 2013 ERROR:Index: 0, Size: 0 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at org.newdawn.slick.Animation.getWidth(Animation.java:446) at org.newdawn.slick.Animation.draw(Animation.java:331) at rogue.Map.render(Map.java:122) at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:703) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at rogue.Map.main(Map.java:40) Wed May 15 22:57:18 EDT 2013 ERROR:Game.render() failure - check the game code. org.newdawn.slick.SlickException: Game.render() failure - check the game code. at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:706) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at rogue.Map.main(Map.java:40) BUILD SUCCESSFUL (total time: 1 second)[/code] Its a 400 x 50 sprite sheet with 50 x 50 sprites and theres 4 of them on one row. What am I doing wrong?
I am learning c++ and for some reason it does not let me create a class [code] //main.cpp #include <iostream> #include "character.h" #include "character.cpp" //Threw an error when I included the header without the actual cpp file using namespace std; int main() { character test; return 0; }[/code] [code] //Character.h #ifndef CHARACTERINCLUDED #define CHARACTERINCLUDED class character { public: character(); ~character(); void test(); }; #endif [/code] [code] //Character.cpp #include "character.h" character::character() { } character::~character() { } character::test() { } [/code] [code] //Error In file included from C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\main.cpp:3:0: C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.cpp:12:17: error: ISO C++ forbids declaration of 'test' with no type [-fpermissive] C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.cpp:12:1: error: prototype for 'int character::test()' does not match any in class 'character' In file included from C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\main.cpp:2:0: C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.h:10:7: error: candidate is: void character::test() [Finished in 0.2s with exit code 1] [/code]
[QUOTE=superstepa;40660581]I am learning c++ and for some reason it does not let me create a class [code] //main.cpp #include <iostream> #include "character.h" #include "character.cpp" //Threw an error when I included the header without the actual cpp file using namespace std; int main() { character test; return 0; }[/code] [code] //Character.h #ifndef CHARACTERINCLUDED #define CHARACTERINCLUDED class character { public: character(); ~character(); void test(); }; #endif [/code] [code] //Character.cpp #include "character.h" character::character() { } character::~character() { } character::test() { } [/code] [code] //Error In file included from C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\main.cpp:3:0: C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.cpp:12:17: error: ISO C++ forbids declaration of 'test' with no type [-fpermissive] C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.cpp:12:1: error: prototype for 'int character::test()' does not match any in class 'character' In file included from C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\main.cpp:2:0: C:\Users\Superstepa\Dropbox\Programming projects\C++\Prototype\character.h:10:7: error: candidate is: void character::test() [Finished in 0.2s with exit code 1] [/code][/QUOTE] [CODE]//main.cpp #include <iostream> using namespace std; class character { public: character(); ~character(); void test() {} }; character::character() { } character::~character() { } int main() { character test; system("PAUSE"); return 0; }[/CODE] This seems to work for me [editline]15th May 2013[/editline] [QUOTE=superstepa;40660581]I am learning c++ and for some reason it does not let me create a class [code] //main.cpp #include <iostream> #include "character.h" #include "character.cpp" //Threw an error when I included the header without the actual cpp file using namespace std; int main() { character test; return 0; }[/code] [code] //Character.h #ifndef CHARACTERINCLUDED #define CHARACTERINCLUDED class character { public: character(); ~character(); void test(); }; #endif [/code] [code] //Character.cpp #include "character.h" character::character() { } character::~character() { } character::test() { } [/code] [/QUOTE] Also when you defined void test, you forgot to enter the data type that it will be returning. In your case it isn't returning anything so we use void like so: void character::test() { }
[QUOTE=superstepa;40660581]I am learning c++ and for some reason it does not let me create a class [code] //code [/code][/QUOTE] What the guy above me said + you generally don't include cpp files. You add it to your project or makefile and the build-system takes care of linking each file together. [editline]16th May 2013[/editline] [QUOTE=DesolateGrun;40660510]im using slick 2d for a little java game but im stuck on a sprite sheet thing [code]//code[/code] When I run this the game crashes with this [code]//error[/code] Its a 400 x 50 sprite sheet with 50 x 50 sprites and theres 4 of them on one row. What am I doing wrong?[/QUOTE] [code]for (int row=1;row<1;row++)[/code] That condition will never be true. [editline]16th May 2013[/editline] [QUOTE=Cesar Augusto;40659328]Someone could help me how to install Boost C++ to my Code::Blocks(MinGW)? I tried to use the bjam but it says that are a incompatible "kernel" (something like that, don't remember exactly...mismatches). If you can help me, you will save me. Thanks.[/QUOTE] Did you follow [url=http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef]this guide[/url]? Just note that the current stable version is 1.53, not 1.47.
[quote] Also when you defined void test, you forgot to enter the data type that it will be returning. In your case it isn't returning anything so we use void like so: void character::test() { }[/QUOTE] Thank you so much, I assumed that you didn't need to put the data type in because it was defined in the header [QUOTE=ZeekyHBomb;40661149]What the guy above me said + you generally don't include cpp files. You add it to your project or makefile and the build-system takes care of linking each file together. [/QUOTE] I tried just including the header but it gave me this error [code] C:\Users\SUPERS~1\AppData\Local\Temp\ccAlMm10.o:main.cpp:(.text+0x16): undefined reference to `character::character()' C:\Users\SUPERS~1\AppData\Local\Temp\ccAlMm10.o:main.cpp:(.text+0x21): undefined reference to `character::test()' C:\Users\SUPERS~1\AppData\Local\Temp\ccAlMm10.o:main.cpp:(.text+0x45): undefined reference to `character::~character()' C:\Users\SUPERS~1\AppData\Local\Temp\ccAlMm10.o:main.cpp:(.text+0x56): undefined reference to `character::~character()' [/code] Is there an easy way to link them without including the c++ file if I am just using sublime text + g++?
i've always done it by just including class.h and methods.cpp, but it seems like from what Zeek's saying that that's inefficient
If Sublime Text has built-in support for code projects then it should just do when adding the files and hitting build. Otherwise you'll have to decide on a build-system. If you have g++, chances are you also have gnumake on the system. Something like that should do: [code]#compiler flags CFLAGS:=-Wall -Wextra -pedantic CPPFLAGS:=-std=c++11 #tell make how to build the executable #right of the : are the files required to link it my-project: main.o character.o $(LINK.o) $(OUTPUT_OPTION) $^ #general rule how to make .o files #not sure if required or gnumake has this built-in %.o: src/%.cpp $(COMPILE.cc) $(OUTPUT_OPTION) $< #removes the built files #*.o is kinda cheap clean: $(RM) *.o my-project rebuild: clean all[/code] You might need to read some make instructions to understand this completely. Save this in a file names Makefile (no extension) and execute make in the directory. This won't properly re-build the required files if you change a header-file though; You'd need to execute make rebuild for that. Here's a more advanced makefile I used, which also migrates the problem: [code]CFLAGS:=-Wall -Wextra -pedantic CPPFLAGS:=-std=c++11 OBJPREFIX:=.objs/ DEPPREFIX:=.deps/ RMDIR=$(RM) -r debug: my-project somedebug: my-project release: my-project all: debug -include Makefile.custom debug: CFLAGS:=-ggdb3 -O0 $(CFLAGS) somedebug: CFLAGS:=-ggdb -O $(CFLAGS) release: CPPFLAGS:=-DNDEBUG $(CPPFLAGS) release: CFLAGS:=-O3 $(CFLAGS) release: LDFLAGS:=-Wl,-s,-O1,--as-needed $(LDFLAGS) my-project: $(OBJPREFIX)main.o $(OBJPREFIX)character.o $(LINK.o) $(OUTPUT_OPTION) $^ -include $(patsubst src/%.c,$(DEPPREFIX)%.d,src/*.c) $(OBJPREFIX)%.o: src/%.c @ mkdir -p $(dir $@ $(DEPPREFIX)$*) @ $(CPP) -MM -MF "$(DEPPREFIX)$*.d" -MT "$(DEPPREFIX)$*.d $@" -c $(CPPFLAGS) $< $(COMPILE.c) $(OUTPUT_OPTION) $< clean: $(RM) $(OBJPREFIX)*.o $(DEPPREFIX)*.d my-project $(RMDIR) $(dir $(OBJPREFIX) $(DEPPREFIX)) rebuild: clean all[/code] The Makefile.custom is there so you can keep this makefile in a repository and can customize compiler-options in a Makefile.custom that you only keep locally. Although now I use CMake, a Makefile-generator. But this should work for now :) [editline]16th May 2013[/editline] Also, you could just compile "by-hand": g++ -Wall -Wextra -pedantic -std=c++11 -o my-project main.cpp character.cpp (or if you're lazy *.cpp); you can also put that in a shell-script.
How can I use glm::lookAt to look down 45 degrees, while still being able to move the camera? Something like [cpp]camera = glm::lookAt( position, position + rotation, glm::vec3(0.f, 1.f, 0.f) );[/cpp] where rotation is a 45 degree down rotation. I am not sure how to achieve this, as I'm not sure how the whole rotation system works (I got this from a tutorial). Edit: I figured it out. Make the rotation a vector to the location of where you want to look. For me, at 45 degrees, it would be 0, -1, -1.
My object class does not seem to be working and I cannot see why, all the data appears fine when I look at it with the debugger yet I'm not seeing anything of the screen. [cpp] Object* Object::create_object(float *data) { Log *err = Log::defaultLog; Object *tmp = new Object; tmp->vertex_data = data; // Debug: check the data is ok std::cout << sizeof(data) << std::endl; for(int i = 0; i <= sizeof(data); i++) { std::cout << data[i]; } std::cout << std::endl; glGenVertexArrays(1, &tmp->VAO); glBindVertexArray(tmp->VAO); glGenBuffers(1, &tmp->VAO); glBindBuffer(GL_ARRAY_BUFFER, tmp->VAO); glBufferData(GL_ARRAY_BUFFER, sizeof(tmp->vertex_data), tmp->vertex_data, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); if (glGetError() != GL_NO_ERROR) { err->write("error",glGetError()); exit(-1); } return tmp; } void Object::render() { this->program->use_program(); glDrawArrays(GL_TRIANGLES, 0, 3); }[/cpp] [cpp] void Engine::mainLoop() { shadermanager = ShaderManager::get_shader_manager(); ShaderProgram *prog1 = shadermanager->add_shader_program(); prog1->add_shader("shaders/vertex.glsl", GL_VERTEX_SHADER); prog1->bind_attrib(1, "position"); prog1->add_shader("shaders/fragment.glsl", GL_FRAGMENT_SHADER); prog1->attach_all(); prog1->load_program(); prog1->use_program(); GLint pos = glGetAttribLocation(prog1->get_program_GLID(), "position"); GLint view = glGetUniformLocation(prog1->get_program_GLID(), "view"); GLint proj = glGetUniformLocation(prog1->get_program_GLID(), "proj"); // glm::mat4 proj_matrix = glm::perspective(75.0f, (float)res_x/res_y, 0.1f, 1000.0f); // glm::mat4 view_matrix = glm::lookAt(glm::vec3(0.0,0.0,-10), // glm::vec3(0.0,0.0,0.0), // glm::vec3(0.0,1.0,0.0)); // glUniform4fv(view, 1, glm::value_ptr(view_matrix)); // glUniform4fv(proj, 1, glm::value_ptr(proj_matrix)); float data[] = { 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; Object* ob1 = objectmanager->create_object(data); ob1->set_shader_program(prog1); glVertexAttribPointer(pos, 3, GL_FLOAT, GL_FALSE, 0, 0); while( glfwGetWindowParam(GLFW_OPENED) && !glfwGetKey(GLFW_KEY_ESC) ) { check_window_resized(); glClearColor(0.0f, 0.0f, 0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ob1->render(); glfwSwapBuffers(); } }[/cpp] Vertex shader [cpp]#version 150 in vec4 position; in vec4 color; out vec4 frag_color; uniform mat4 proj; uniform mat4 view; uniform mat4 model = mat(1.0); uniform float time; void main() { vec4 pos = vec4 (position.x, position.y, position.z , 1.0); gl_Position = pos; }[/cpp] Fragment shader [cpp]#version 150 in vec4 frag_color; out vec4 out_color; void main() { out_color = vec4(1.0, 0.0, 0.0f, 1.0); }[/cpp] It's probably something stupid I've forgot but my brain is fried. [QUOTE=WTF Nuke;40666621]How can I use glm::lookAt to look down 45 degrees, while still being able to move the camera?[/quote] I'm not entirely sure if it would work but maybe you could change the up vector ?
[QUOTE=ZeekyHBomb;40661149] [editline]16th May 2013[/editline] Did you follow [url=http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef]this guide[/url]? Just note that the current stable version is 1.53, not 1.47.[/QUOTE] Yes, I noticed, but I can't use the new version? I must use Visual C++?
Someone want to help me with my database homework? I need to put: Client First Name, Client Last Name, Client Phone Number, Client email address, Date of Workout, Start Time, End Time, Length of Workout, Weight, Upper Body Exercises Done, Core Exercises Done, Lower Body Exercises Done, Goal Weight, Date of Birth, Age, Medical Conditions, Emergency Contact Name, Emergency contact Phone Number, and Hourly Rate. Into a database. Fully 3NF normalized I can only see a Client entity with all the following columns: Client ID ,Client First Name, Client Last Name, Client Phone Number, Client email address, Goal Weight, Date of Birth, Age, Medical Conditions, Emergency Contact ID, Hourly Rate A Workout entity with the following columns: Client ID, Workout Number, Date of Workout, Start Time, End Time, Length of Workout, Weight, Upper Body Exercises Done, Core Exercises Done, Lower Body Exercises Done And an Emergency Contact entity with the following columns: Emergency Contact ID, Emergency Contact Name, Emergency contact Phone Number I gotta do some queries too but I can do that no problem. It's just for a final homework assignment, 3 entities seems like a lot, but it's logically coherent as far as I know and splitting it up any further would basically mean splitting it for the sake of splitting it. I'm just using IDs to make foreign keys easy, but even then everything only has one primary key, which is more or less the definition of a fully normalized DB...
[QUOTE=Protocol7;40669827]Someone want to help me with my database homework? I need to put: Client First Name, Client Last Name, Client Phone Number, Client email address, Date of Workout, Start Time, End Time, Length of Workout, Weight, Upper Body Exercises Done, Core Exercises Done, Lower Body Exercises Done, Goal Weight, Date of Birth, Age, Medical Conditions, Emergency Contact Name, Emergency contact Phone Number, and Hourly Rate. Into a database. Fully 3NF normalized I can only see a Client entity with all the following columns: Client ID ,Client First Name, Client Last Name, Client Phone Number, Client email address, Goal Weight, Date of Birth, Age, Medical Conditions, Emergency Contact ID, Hourly Rate A Workout entity with the following columns: Client ID, Workout Number, Date of Workout, Start Time, End Time, Length of Workout, Weight, Upper Body Exercises Done, Core Exercises Done, Lower Body Exercises Done And an Emergency Contact entity with the following columns: Emergency Contact ID, Emergency Contact Name, Emergency contact Phone Number I gotta do some queries too but I can do that no problem. It's just for a final homework assignment, 3 entities seems like a lot, but it's logically coherent as far as I know and splitting it up any further would basically mean splitting it for the sake of splitting it. I'm just using IDs to make foreign keys easy, but even then everything only has one primary key, which is more or less the definition of a fully normalized DB...[/QUOTE] Which DBMS and what exactly do you need help with?
MySQL, and I just want someone to double check to make sure I know how to normalize. I can set up a DB fine with the Workbench and I've already implemented all the entities I listed, complete with FKs and proper column flags.
[QUOTE=Protocol7;40670720]MySQL, and I just want someone to double check to make sure I know how to normalize. I can set up a DB fine with the Workbench and I've already implemented all the entities I listed, complete with FKs and proper column flags.[/QUOTE] Nevermind then, I have no idea what this 'normalization' is about. Sorry.
I should mention it's not the actual final homework assignment in that it's a final, just that it's the last homework assignment of the year (not counting the actual take home final which was piss easy.)
I mean I could check it over but I have no way of telling you whether it's properly normalized or not as I have no idea what that is or what it would translate to (in regards to my own uni classes where afaik the subject has never come up).
Well I'm being a bad DBA by not planning it out like she wants us to, but that's mostly because we were given all the columns we need to deal with. Honestly I think this is fine, it's probably at least a C and the relevant bits are all really the queries and a shitty frontend to display the info, which is probably what's going to take the most time.
[QUOTE=Protocol7;40670814]Well I'm being a bad DBA by not planning it out like she wants us to, but that's mostly because we were given all the columns we need to deal with. Honestly I think this is fine, it's probably at least a C and the relevant bits are all really the queries and a shitty frontend to display the info, which is probably what's going to take the most time.[/QUOTE] If you were given all the columns, what is there left to design? :v:
I was given all the columns as they are used in an Excel spreadsheet, not a DB. I just split them so there's a table for the clients and their info, the workouts, and the client's emergency contacts. I might split off contact info into its own table and point each record to the ClientID or Emergency Contact ID.
[QUOTE=Cesar Augusto;40669513]Yes, I noticed, but I can't use the new version? I must use Visual C++?[/QUOTE] Most Boost libraries are header-only (i.e. they work without compiling). If you're not using a library that must be compiled, don't bother. Just move the Boost headers into the proper place. Otherwise, here's how I build Boost for MinGW. This works for the most recent version of Boost, and will probably work for any future versions that use the same build system. You must use MSYS for this. You need to have gcc available in your PATH variable (either CLI variable or system variable through Windows stuff). Start up MSYS and cd to wherever you extracted Boost. Run this (assuming you want to install Boost to C:\MinGW\lib and C:\MinGW\include, otherwise change the prefix): ./bootstrap.sh --prefix=/c/mingw --wth-toolset=mingw Also: ./bootstrap.sh --help Look at the options for static libs, building only specific libs, etc. Look at individual Boost libraries for compile options. Now you need to edit the project-config.jam file it created, and change the lines that say you're using the mingw toolset to gcc. Finally, simply run b2.exe You might have to manually move the headers and stuff to the proper folder (look in bin.v2 for libs). I forget if you really need to, but I remember doing it once for some reason.
How do you write to a resource file in c#? Heres my code: [code] if (!DictOfSyndicates.Contains(syndicateNumberTextBox.Text)) { try { var resxWriter = new ResXResourceWriter(@".\Syndicates.resx"); resxWriter.AddResource("test", syndicateNumberTextBox.Text); resxWriter.Close(); MessageBox.Show(@"Sydicate "+syndicateNumberTextBox.Text +@" Added Successfully."); } catch (FileNotFoundException caught) { MessageBox.Show(@"Source: " + caught.Source + @" Message: " + caught.Message); } } else { MessageBox.Show(@"Syndicate already exists"); } } [/code] The DictofSyndicates shows the things in the resource file however resxWriter isn't adding anything. What do I have to do?
-snip- [editline]17th May 2013[/editline] Small Lua problem [url]https://gist.github.com/CptAsgard/89feb1d04d7531923d31[/url] Shouldn't OhDearImDying.lua load in all the functions from Health.lua once OhDearImDying.lua is read? It can't seem to find the HEALTH table that contains the functions. It's for a Firefall addon. Haven't really done Lua before.
[QUOTE=Over-Run;40675535]How do you write to a resource file in c#? Heres my code: The DictofSyndicates shows the things in the resource file however resxWriter isn't adding anything. What do I have to do?[/QUOTE] Try calling Generate() before Close()?
Can I check with Lua if the required file loaded correctly?
[QUOTE=SteveUK;40676141]Try calling Generate() before Close()?[/QUOTE] Tried it, still no luck :S any other suggestions?
[QUOTE=Asgard;40676219]Can I check with Lua if the required file loaded correctly?[/QUOTE] Just a quick note: the require function will only load a module once and set package.loaded[module_name] to the return value of module, from then on require will just return that. So you don't need to manually check it in health.lua.
Sorry, you need to Log In to post a reply to this thread.