• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Cittidel;33668391]I spent around two hours today with C (admittedly not very long), during that time I was thinking about how confusing it is in comparison to C++, like the differences between cin and scanf.[/QUOTE] I dunno, I find C to be infinitely simpler than C++. I think it's really just an issue of familiarity. Anyway, C and Objective C are entirely different things, just like C++ is entirely different than C and C# is entirely different than C, and Javascript is entirely different than Java. Language developers just love to make up misleading names.
[QUOTE=ROBO_DONUT;33668431] Anyway, C and Objective C are entirely different things[/QUOTE] How odd, when I had googled 'Objective C tutorial' [url=http://cocoadevcentral.com/d/learn_objectivec/]this was the first result for me[/url], which told me to go learn C. Can you recommend a tutorial? [url=http://objectivectutorial.org/operators-in-objective-c]This is what the next result is for me[/url], which looks promising, but if you have personal experience I'd much rather hear that.
[QUOTE=Tukimoshi;33661507][url]http://developer.android.com/guide/index.html[/url] [url]http://hackaday.com/2010/07/12/android-development-101-%E2%80%93-a-tutorial-series/[/url] [url]http://www.ibm.com/developerworks/opensource/library/os-android-devel/[/url] Google is your friend.[/QUOTE] Well I didn't know if they were good or not :v:
[QUOTE=Cittidel;33668514]How odd, when I had googled 'Objective C tutorial' [url=http://cocoadevcentral.com/d/learn_objectivec/]this was the first result for me[/url], which told me to go learn C. Can you recommend a tutorial? [url=http://objectivectutorial.org/operators-in-objective-c]This is what the next result is for me[/url], which looks promising, but if you have personal experience I'd much rather hear that.[/QUOTE] developer.apple.com has extensive documentation and examples. you may have to register, but it's free to get access to the articles and there are thousands of them.
I'm looking in to the lua c api but i'm not really sure how to do it "right". At the moment i've got a couple of functions working and run the script with luaL_dofile, and can get global variables back, but that's all. I don't know if this is a stupid question or not but i'm wondering how to use this in the greater sense of a game, like gmod style. I've tried searching but I can't find info on anything more advanced than what i've got. A bit vague I know. Also is it a good idea to dual use lua for things like config files?
Working on terrain at the moment. So far, this is what I have: [img]http://i1110.photobucket.com/albums/h456/capsup/Screenshot-2011-12-11_162413.png[/img] I just can't really figure out how to make the triangles wrap seamlessly. This is the code that I am using to generate my vertexes: [url]http://pastebin.com/kHRVpSC4[/url] The array vertexterrain is an array of floats that has been seeded with 25 y values generated from the diamond square algorhitm. I use glDrawArrays to draw that piece of code, so I need to generate the useless 2 extra vertexes. EDIT: Great, I JUST managed to post this then discovered the error once again. :D I had swapped around the yval2 and yval3 in the first 3 vertexes. [img]http://i1110.photobucket.com/albums/h456/capsup/Screenshot-2011-12-11_163024.png[/img]
Creating terrain like that is silly, use four triangles per quad and it'll look somewhat more natural.
In C++, I have a method that is supposed to return the string representation of an object. [cpp] const char *triomino::toString() const { const char c[] = {'(', corners[0] + '0', ',', corners[1] + '0', ',', corners[2] + '0', ')', '\0'}; return c; } [/cpp] That seems to work, since Visual Studio 2010 gives me the address and the string I'm expecting. However, when I print it to cout, all I get is rubbish (stuff like "&#9568;&#9568;&#9568;&#9568;&#9617;¸0", which I think is the address, since it changes every time I start). The code I'm using to print it is the following, where toString() is the method above. [cpp]cout << trStart->toString() << endl;[/cpp] What am I doing wrong?
Are you even allowed to initialize a constant array with a non-constant expression? (I believe array accesses are never constant.) [editline]11th December 2011[/editline] First try to change that array to char c[]
[QUOTE=esalaka;33673289]Are you even allowed to initialize a constant array with a non-constant expression? (I believe array accesses are never constant.) [editline]11th December 2011[/editline] First try to change that array to char c[][/QUOTE] Doesn't help. What I didn't notice before was the warning "returning address of local variable or temporary' (C4172). I'm guessing that the 'string' I'm returning could be deallocated by the time it's being printed. I'm not sure how to work around this, though.
Return a smart pointer to it and createu is using new?
You could mark it static. Using C++ you could also use std::string instead of c-style strings. And you could also instead [url=http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/]overload the operator<< for std::ostream[/url].
[QUOTE=ZeekyHBomb;33674484]You could mark it static. Using C++ you could also use std::string instead of c-style strings. And you could also instead [url=http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/]overload the operator<< for std::ostream[/url].[/QUOTE] I went with overloading the << operator, so thanks for that. I tried that before but I must've fucked up something.
How would someone make a sidescrolling platfomer game(to the style of mario)? My current idea is to draw the level, then add collision with the boxes that i've drawn and add jumping, etc. It doesn't handle vertical transitioning, however. I'm going to be coding this game in love btw. My second idea is to use [url]http://mapeditor.org[/url] in order to make the map, but I'm not sure how to implement it once it's created.
Does anyone know why playing sounds through LOVE's audio system makes the sound clip 24/7? I'm assuming it has something to do with the fact the audio is streaming, but trying to set it to load all at once freezes up my game.
[QUOTE=nick10510;33681668]Does anyone know why playing sounds through LOVE's audio system clips 24/7? I assume it has something to do with the fact the audio is streaming but trying to set it to load all at once freezes up my game.[/QUOTE] That first sentence sounds incomplete.
I'm curious as to what the algorithm is called that changes something like image 1 into something like image 2. Basically instead of rendering many separate squares, there'll only be a few squares of a repeated texture to render. [img]http://i.imgur.com/eH1rm.png[/img] [img]http://i.imgur.com/vmTU3.png[/img]
Quadtree.
[QUOTE=ROBO_DONUT;33681788]That first sentence sounds incomplete.[/QUOTE] Looking for programming advice, not grammatical advice, but I tried my best to fix whatever was bugging you.
Beginner's java question here: How do I initiate a dynamic method from the main method? I keep getting the following error: "non-static method cannot be referenced from a static context". I would change the referenced method to static as well but as it in turn references to a method that has to be dynamic that really isn't an option.
[QUOTE=Jookia;33681851]Quadtree.[/QUOTE] I should've known that from the pattern. Thanks.
[QUOTE=Cheezy;33681952]Beginner's java question here: How do I initiate a dynamic method from the main method? I keep getting the following error: "non-static method cannot be referenced from a static context". I would change the referenced method to static as well but as it in turn references to a method that has to be dynamic that really isn't an option.[/QUOTE] You can't call non static method from static methods. Either throw the dynamic methods into a class and make an object in the main method or make the method static. Another solution is in main() make a copy of the class it is in and call the non static methods from there. Like so: [code] public class StaticMain { public void nonStatic(){ System.out.println("Not static"); } public static void main(String[] args) { StaticMain example = new StaticMain(); example.nonStatic(); } } [/code]
[QUOTE=thrawn2787;33682153] [code] public class StaticMain { public void nonStatic(){ System.out.println("Not static"); } public static void main(String[] args) { StaticMain example = new StaticMain(); example.nonStatic(); } } [/code][/QUOTE] Wow, thanks! That example did the trick!
How would you "easily" find the directory that the executable is located within in C#? I've tried many different ways, all of which (according to the guides) got some kinda flaw and doesn't work in some cases.
Can anyone point me in the direction of a GUI toolkit fulfilling all (or most) of these requirements? - Cross platform - Light weight - Native look and feel I've used Qt, and I would use it again except for licensing issues and the fact that you can't just "use Qt in your program"... you have to use qt AS your program -- you have to build your project with their tools, and it's a massive bloated toolkit and a whole pain in the ass. FLTK meets the requirements for cross-platform and lightweight, but it looks ugly as sin. wxWidgets I have yet to use but I've always kinda considered using it, not exactly light-weight though. Any suggestions? I was considering using Gwen but that's designed more for games and I'd need to pick a renderer to link it with, etc.. [editline]12th December 2011[/editline] [QUOTE=Donkie;33684077]How would you "easily" find the directory that the executable is located within in C#? I've tried many different ways, all of which (according to the guides) got some kinda flaw and doesn't work in some cases.[/QUOTE] Try System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule); ?
[QUOTE=mechanarchy;33684129]Can anyone point me in the direction of a GUI toolkit fulfilling all (or most) of these requirements? - Cross platform - Light weight - Native look and feel I've used Qt, and I would use it again except for licensing issues and the fact that you can't just "use Qt in your program"... you have to use qt AS your program -- you have to build your project with their tools, and it's a massive bloated toolkit and a whole pain in the ass. FLTK meets the requirements for cross-platform and lightweight, but it looks ugly as sin. wxWidgets I have yet to use but I've always kinda considered using it, not exactly light-weight though. Any suggestions? I was considering using Gwen but that's designed more for games and I'd need to pick a renderer to link it with, etc..[/QUOTE] Gtk+ might fit the bill, I don't know if it has a native look and feel on windows though.
[QUOTE=Donkie;33684077]How would you "easily" find the directory that the executable is located within in C#? I've tried many different ways, all of which (according to the guides) got some kinda flaw and doesn't work in some cases.[/QUOTE] If it is a Windows Forms application, you can use Application.StartupPath (in System.Windows.Forms). If not, try what mechanarchy posted.
I need help getting motivation, I look at the WAYWO and get super duper motivation strike, open IDE - bam it's gone.
fixed, i had shader stuff in the constructor before the shader had been initialised. [code] Quad::Quad() { vertexList[0] = 0.5f; vertexList[1] = 0.5f; vertexList[2] = 0.0f; vertexList[3] = -0.5f; vertexList[4] = 0.5; vertexList[5] = 0.0f; vertexList[6] = -0.5f; vertexList[7] = -0.5f; vertexList[8] = 0.0f; vertexList[9] = 0.5f; vertexList[10] = 0.5; vertexList[11] = 0.0f; vertexList[12] = -0.5f; vertexList[13] = -0.5f; vertexList[14] = 0.0f; vertexList[15] = 0.5f; vertexList[16] = -0.5f; vertexList[17] = 0.0f; UVList[0] = 1.0f; UVList[1] = 0.0f; UVList[2] = 0.0f; UVList[3] = 0.0f; UVList[4] = 0.0f; UVList[5] = 1.0f; UVList[6] = 1.0f; UVList[7] = 0.0f; UVList[8] = 0.0f; UVList[9] = 1.0f; UVList[10] = 1.0f; UVList[11] = 1.0f; // Generate 1 buffer, put the resulting identifier in vertexbuffer glGenBuffers(1, &vertexbuffer); // The following commands will talk about our 'vertexbuffer' buffer glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); // Give our vertices to OpenGL. glBufferData(GL_ARRAY_BUFFER, sizeof(vertexList), vertexList, GL_STATIC_DRAW); glGenBuffers(1, &uvbuffer); glBindBuffer(GL_ARRAY_BUFFER, uvbuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(UVList), UVList, GL_STATIC_DRAW); glGenTextures(1, &texturebuffer); } Quad::Quad(glm::vec3 *eVertexList) { vertexList[0] = eVertexList[0].x; vertexList[1] = eVertexList[0].y; vertexList[2] = eVertexList[0].z; vertexList[3] = eVertexList[1].x; vertexList[4] = eVertexList[1].y; vertexList[5] = eVertexList[1].z; vertexList[6] = eVertexList[2].x; vertexList[7] = eVertexList[2].y; vertexList[8] = eVertexList[2].z; vertexList[9] = eVertexList[3].x; vertexList[10] = eVertexList[3].y; vertexList[11] = eVertexList[3].z; vertexList[12] = eVertexList[4].x; vertexList[13] = eVertexList[4].y; vertexList[14] = eVertexList[4].z; vertexList[15] = eVertexList[5].x; vertexList[16] = eVertexList[5].y; vertexList[17] = eVertexList[5].z; } Quad::~Quad() { // Cleanup VBO and shader glDeleteBuffers(1, &vertexbuffer); glDeleteBuffers(1, &uvbuffer); glDeleteTextures(1, &texturebuffer); } void Quad::CreateShader(const std::string &vertFile,const std::string &fragFile) { shader.LoadFromFiles(vertFile, fragFile); MatrixID = glGetUniformLocation(shader.shaderID, "MVP"); positionID = glGetAttribLocation(shader.shaderID, "Position"); TextureID = glGetUniformLocation(shader.shaderID, "myTexture"); UVID = glGetAttribLocation(shader.shaderID, "UV"); } void Quad::Draw() { glUseProgram(shader.shaderID); glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texturebuffer); glUniform1i(TextureID, 0); // 1rst attribute buffer : vertices glEnableVertexAttribArray(positionID); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer( positionID, // attribute 0. No particular reason for 0, but must match the layout in the shader. 3, // size GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); // 2nd attribute buffer : UVs glEnableVertexAttribArray(UVID); glBindBuffer(GL_ARRAY_BUFFER, uvbuffer); glVertexAttribPointer( UVID, // attribute. No particular reason for 1, but must match the layout in the shader. 2, // size : U+V => 2 GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); // Send our transformation to the currently bound shader, // in the "MVP" uniform // For each model you render, since the MVP will be different (at least the M part) // Draw the triangle ! glDrawArrays(GL_TRIANGLES, 0, 6); // Starting from vertex 0; 3 vertices total -> 1 triangle glDisableVertexAttribArray(UVID); glDisableVertexAttribArray(positionID); } void Quad::SetImage(sf::Image *eImage) { image = eImage; glBindTexture(GL_TEXTURE_2D, texturebuffer); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, image->GetWidth(), image->GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image->GetPixelsPtr() ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); }[/code] I also get a segfault from the quad draw function when i close my application, but i think thats a driver issue
[QUOTE=Richy19;33685543]fixed, i had shader stuff in the constructor before the shader had been initialised. [code] code [/code] I also get a segfault from the quad draw function when i close my application, but i think thats a driver issue[/QUOTE] Hey Richy, I'm trying to get textures to work myself, and see that your code does about the same as mine do. I believe mine is setup correct, but the textures are still black. Could I get to see your shader that you use with that code?
Sorry, you need to Log In to post a reply to this thread.