• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Bumrang;38545132]I moved all of the gl init into main, everything that did not need opengl are still in the classes. I also did this with sfml where I just made a pointer for sf::RenderWindow. But still, nothing is being drawn. Also I made an sfml branch, maybe that one will be easier to read and debug: [url=https://github.com/Bumrang/PongOut/tree/sfml/src]https://github.com/Bumrang/PongOut/tree/sfml/src[/url][/QUOTE] I tried compiling it but you're using SFML 2.0, which I don't have. (as a sidenote, why would Laurent change the naming scheme for every function in SFML) The code looks fine to me so I don't really know why it doesn't work. In the meantime, cut it back some more - don't update the ball position at all, just draw it in the same location every frame. Play around with that position a few times and see if you can get it on the screen. I couldn't compile it but I see you have text - is that visible? I'd also recommend you change all of your positions and sizes to floats instead of integers. If I recall correctly everything in SFML1.6 was using floats, but that might have changed for 2.0. I've had problems in the past with conversions from floats to ints or vice versa - that was more with OpenGL though and some really stupid pointer casts.
[QUOTE=mechanarchy;38546310]I tried compiling it but you're using SFML 2.0, which I don't have. (as a sidenote, why would Laurent change the naming scheme for every function in SFML) The code looks fine to me so I don't really know why it doesn't work. In the meantime, cut it back some more - don't update the ball position at all, just draw it in the same location every frame. Play around with that position a few times and see if you can get it on the screen. I couldn't compile it but I see you have text - is that visible? I'd also recommend you change all of your positions and sizes to floats instead of integers. If I recall correctly everything in SFML1.6 was using floats, but that might have changed for 2.0. I've had problems in the past with conversions from floats to ints or vice versa - that was more with OpenGL though and some really stupid pointer casts.[/QUOTE] Commented out update code (which worked in main), the ball is still nowhere to be seen. Yes the text does display. I added a sf::RectangleShape to see if that would draw, and it in-fact does, leading me to believe this is a problem with textures. This is what it currently looks like (text and rectangle (which is inside of the Ball class) being displayed but the ball isn't): [img]http://screencloud.net/img/screenshots/71ef91af8106dc748dbd4117e94e966d.png[/img] Also yes my positions are floats.
[QUOTE=Bumrang;38546611]Commented out update code (which worked in main), the ball is still nowhere to be seen. Yes the text does display. I added a sf::RectangleShape to see if that would draw, and it in-fact does, leading me to believe this is a problem with textures.[/QUOTE] So you don't see any errors about the texture not being loaded in the terminal? Try changing the line to std::cout << "Could not load the ball texture." << std::endl; to force the cout buffer to be flushed to the screen. That should fix it showing up (if the real error is the texture isn't being loaded). If that's the case move the texture file to the project root directory or into the bin directory; wherever the current directory is when you run it.
oh and the branch has been updated with the new changes [editline]21st November 2012[/editline] merge [editline]21st November 2012[/editline] No errors about the texture being loaded incorrectly
[QUOTE=Bumrang;38546735]No errors about the texture being loaded incorrectly[/QUOTE] Change the order of your draw sprite and draw rect lines, the rectangle will be on top of the sprite (if it's loaded) [editline]22nd November 2012[/editline] And change the filename for the texture to something that for sure doesn't exist, check it's erroring properly
It's erroring correctly, and the ball is supposed to be drawn at the center and the box is at (0,0). [editline]21st November 2012[/editline] Also on the opengl version glGetError() reports 1281, if that helps
I don't know if I should be posting here, but do you know a good book for learning C++. I already know C# and other programming languages so I don't want to start from zero. Also any libraries that are very popular and used every day for C++ would be nice. Thanks!
I'd recommend Boost to be used with C++. It's like the STL we've never had.
Is this snippet of GLSL [cpp]#version 120 attribute vec4 coord; varying vec2 texcoord; void main(void) { gl_Position = vec4(coord.xy, 0, 1); texcoord = coord.zw;[/cpp] Compatible with OpenGL 3.2? I'm pretty sure the latest is 150. I got this code on a tutorial for text rendering, and I wasn't sure what the "attribute" and "varying" types are so I couldn't just convert it to version 150.
I got a problem using sfml, I'm trying to make a map that stores the position in a key and an entity class in the container. I keep getting "no match for operator<", and I'm getting some "instantiated from" errors. [code] public: void AddToStack(Entity ENT) { EntityP Store( ENT.GetPosition() , ENT ); Stack.insert(Store); } private: typedef pair< const sf::Vector2f, Entity> EntityP; typedef map< const sf::Vector2f, Entity> Emap; [/code] that's not the full code but it's the bit that is giving me the problem please help.
[QUOTE=Meatpuppet;38550701]Is this snippet of GLSL [cpp]#version 120 attribute vec4 coord; varying vec2 texcoord; void main(void) { gl_Position = vec4(coord.xy, 0, 1); texcoord = coord.zw;[/cpp] Compatible with OpenGL 3.2? I'm pretty sure the latest is 150. I got this code on a tutorial for text rendering, and I wasn't sure what the "attribute" and "varying" types are so I couldn't just convert it to version 150.[/QUOTE] Attribute/varying are now replaced with in/out. If the data is coming into the vertex or fragment shader, it should be 'in'. If the variable is going out of the vertex or fragment shader, it should be 'out' For example, in your vertex shader "coord" would have an "in" before it, and your texcoord would have an "out" before it. Similarly, your fragment shader should have "texcoord" as an "in" and whatever your out color variable is marked as "out" (and then anything extra such as textures). So your fixed vertex shader would look like this: [cpp]#version (insert what version you want to use here) in vec4 coord; out vec2 texcoord; void main(void) { gl_Position = vec4(coord.xy, 0, 1); texcoord = coord.zw; }[/cpp] And the fragment shader would be something like this (assuming that you're not doing anything extra): [cpp]#version (same version) in vec2 texcoord; out vec4 outColor uniform sampler2D texture; void main(void) { outColor = texture2D (texture, texcoord); }[/cpp] [editline]22nd November 2012[/editline] please correct me if I am wrong with anything, this is just what I have from memory
-snip-
Need some help. This program is breaking and telling me it's an access violation. Can someone please look through my code and tell me what I'm doing wrong? Main.cpp: [url]http://pastebin.com/xSKcct9z[/url] Text.h: [url]http://pastebin.com/rRvsUuTS[/url] Text.cpp: [url]http://pastebin.com/a23ABPvT[/url] I'm probably doing something terribly wrong. If anyone would take the time to just look at this, it would be greatly appreciated. [editline]22nd November 2012[/editline] I know the problem lies in the text class, because when the program breaks, it goes to the FT source.
[QUOTE=Meatpuppet;38553554]Need some help. This program is breaking and telling me it's an access violation. Can someone please look through my code and tell me what I'm doing wrong? Main.cpp: [URL]http://pastebin.com/xSKcct9z[/URL] Text.h: [URL]http://pastebin.com/rRvsUuTS[/URL] Text.cpp: [URL]http://pastebin.com/a23ABPvT[/URL] I'm probably doing something terribly wrong. If anyone would take the time to just look at this, it would be greatly appreciated. [editline]22nd November 2012[/editline] I know the problem lies in the text class, because when the program breaks, it goes to the FT source.[/QUOTE] You should make a use case. Remove all the code you can, any code that doesn't make the issue disappear.
[QUOTE=gparent;38554274]You should make a use case. Remove all the code you can, any code that doesn't make the issue disappear.[/QUOTE] Use case? [editline]22nd November 2012[/editline] I assume you mean switch case, but with what?
[QUOTE=Meatpuppet;38554286]Use case? [editline]22nd November 2012[/editline] I assume you mean switch case, but with what?[/QUOTE] keep commenting things out until the problem disappears, then work out\ask us what was wrong with it
Well, first of all, [cpp] FT_Face face; if(FT_New_Face(ft, fontName, 0, &face)) { debug.Print("Could not load font: "); debug.Print(fontName); }[/cpp] This function isn't finding the file. I've put arial.ttf in the directory where the project and exe is, but according to my debug.txt it can't find the file?
What's your debug.txt say? Exactly what your code says? How do you know it's not something other than finding the file?
[QUOTE=Jookia;38554557]What's your debug.txt say? Exactly what your code says? How do you know it's not something other than finding the file?[/QUOTE] Because most of the code after the function depends on it. Such as [cpp]FT_Set_Pixel_Sizes(face, sizex, sizey); FT_GlyphSlot glyph = face->glyph; const char *p; for(p = text; *p; p++) { if(FT_Load_Char(face, *p, FT_LOAD_RENDER)) continue;[/cpp]
No, I mean you're not checking what FreeType is saying the error is.
[QUOTE=Jookia;38554663]No, I mean you're not checking what FreeType is saying the error is.[/QUOTE] What do you mean?
[QUOTE=Meatpuppet;38554715]What do you mean?[/QUOTE] You're going 'if FreeType failed, THEN IT MUST BE THAT IT COULDN'T OPEN THE FILE', not 'if FreeType failed, check its return statement and see what the error is'
Stupid blackjack assignment always keeps returning something along the lines of, "&#65533;` &#65533;@" and other combinations of Gibberish in the output. I sense the main problem is trying to randomly decide on the subscript of the p1values and p1suits arrays. [cpp]void game(int player) { char suits[4] = { 'H', 'D', 'S', 'C' }; // All the suits, &#9829;, &#9830;, &#9824;, & &#9827;. char faces[13] = { 'A', '2', '3', '4', '5', '6', '7', '8', '9', '&#9361;', 'J', 'Q', 'K' }; // &#9361; is an individual character. time_t qTime; time(&qTime); srand(qTime); switch(player) { case 1: // All values SHOULD be refreshed with new ones when we reieterate. char p1values[5]; for (int i = 0; i < 5; i++) { // Immediately create all five possible values. p1values[i] = faces[rand()%13]; // Had to include all numbers AND faces, so int is out of the question. } char p1suits[5]; for (int i = 0; i < 5; i++) { // Immediately create all five possible suits - to go with p1values[]. p1suits[i] = suits[rand()%4]; } case 1: if (p1wallet == 0) { // Checking if the player has blown all of his and/or money on our silly little game. system("clear"); cout << "WALLET EMPTY - GAME OVER - GO HOME, MAN!"; cout << "\n\nPress ENTER to return to the menu."; cin.clear(); cin.ignore(10000, '\n'); cin.get(); break; } cout << "Enter your bet (out of $" << p1wallet << "): > "; cin >> p1bet; while (p1bet > p1wallet || p1bet <= 0) { cout << "Nice try. Enter a wager less than or equal to your wallet, but over zero.\n\t> "; cin >> p1bet; } p1wallet -= p1bet; // Yoink! We just sto-I mean accepted our victim's wager into this scam. system("clear"); if (p1wallet == 0) { cout << "Going full out? Hope you know what you're doing.\n"; } int p1ccount = 2; // Player 1's amount of cards drawn. Two. cout << "Player 1: $" << p1wallet << "\tBet: $" << p1bet << endl; cout << "Hand: "; for (int i = 0; i < p1ccount; i++) { cout << p1values[i] << p1suits[i] << " "; //p1ccount++; } cin >> haushand; } } [/cpp]
You're not initializing your values. Put those loops above the switch statement.
[QUOTE=Jookia;38554732]You're going 'if FreeType failed, THEN IT MUST BE THAT IT COULDN'T OPEN THE FILE', not 'if FreeType failed, check its return statement and see what the error is'[/QUOTE] How would I go about doing that?
[QUOTE=Jookia;38554795]You're not initializing your values. Put those loops above the switch statement.[/QUOTE] Can't believe the answer was this simple. Now I feel sheepish.
[QUOTE=Meatpuppet;38554796]How would I go about doing that?[/QUOTE] [url=http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_New_Face]FT_New_Face[/url] returns a [url=http://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Error]FT_Error[/url]. Since you're using FreeType, good luck finding out what the error corresponds to. Anyway, have you tried using a full path?
[QUOTE=SupahVee;38543232]Has anybody got some experience with embedding a scripting language in C++? I'm trying to use scripting to make users create their own Open Hexagon patterns. I tried AngelScript but it was too complex for what I want and didn't like it at all. If anyone has done anything similar, I'd love some help[/QUOTE] Try JSON.
I'm trying to make a simple 2d side scroller, and i'm working on collision with a square. [code] // Bounding box collision if (playerPos.X + player.Width < wallPos.X || playerPos.X > wallPos.X + wall.Width || playerPos.Y + player.Height < wallPos.Y || playerPos.Y > wallPos.Y + wall.Height) { } else { } [/code] The code is right and works but i'm trying to figure out how to make it so the player collides with the edges. I can make it so one side works but not the others. [code] //Movement keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.D)) { playerPos.X += speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.A)) { playerPos.X -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.W)) { playerPos.Y -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.S)) { playerPos.Y += speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } [/code]
[QUOTE=SupahVee;38543232]Has anybody got some experience with embedding a scripting language in C++? I'm trying to use scripting to make users create their own Open Hexagon patterns. I tried AngelScript but it was too complex for what I want and didn't like it at all. If anyone has done anything similar, I'd love some help[/QUOTE] If you just have to store text, patterns and/or attributes just use JSON. For "scripts" I'd use XML. With XML you can just define a few tags and be done with it. If you really need computation and not just scripts, then you could load up a CLR environment and compile .cs files at runtime. That would be pretty easy to implement and extensible without end. [editline]22nd November 2012[/editline] [QUOTE=elih595;38555389]I'm trying to make a simple 2d side scroller, and i'm working on collision with a square. [code] // Bounding box collision if (playerPos.X + player.Width < wallPos.X || playerPos.X > wallPos.X + wall.Width || playerPos.Y + player.Height < wallPos.Y || playerPos.Y > wallPos.Y + wall.Height) { } else { } [/code] The code is right and works but i'm trying to figure out how to make it so the player collides with the edges. I can make it so one side works but not the others. [code] //Movement keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.D)) { playerPos.X += speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.A)) { playerPos.X -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.W)) { playerPos.Y -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (keyState.IsKeyDown(Keys.S)) { playerPos.Y += speed * (float)gameTime.ElapsedGameTime.TotalSeconds; } [/code][/QUOTE] With the edges? I think you just have to replace < by <= and > by >=
Sorry, you need to Log In to post a reply to this thread.