• What do you need help with? Version 5
    5,752 replies, posted
So I've had this one bug that's pretty much stopped my development of anything for the last month or so. What it is: I have some drawing code for opengl that I created all in main.cpp, to be put into a class later. When I put it in a class it stopped drawing. Nothing could be seen on the screen besides a faint, nearly invisible white box covering the top right corner. More information about it can be found in my [url=http://stackoverflow.com/questions/13226515/code-in-main-cpp-works-but-when-i-put-it-in-a-class-it-doesnt]StackOverflow post.[/url] I assumed this was a problem with my drawing code so I tried doing the same thing in SFML, surely it would be fixed there? Nope. Right when I put it in a class, it once again, stopped drawing. This time there is no faint box, there is absolutely nothing. [url=https://github.com/Bumrang/PongOut/tree/master/src]Here is the code for the OpenGL version.[/url] Mainly look at Ball.cpp, Ball.hpp, and main.cpp. If anybody wants to see it I can upload the SFML version as well.
Having trouble using SOIL... [cpp]Error 3 error LNK2019: unresolved external symbol _SOIL_load_image referenced in function _main C:\Visual Studio\Projects\OpenGL\main.obj OpenGL [/cpp] When I google it, people say to compile the library, I don't know what that means.
I haven't programmed on Windows in forever but from what I remember you need to open the visual studio project that comes with SOIL and press the green compile button at the top, which should give you the required files. [editline]20th November 2012[/editline] well that's what I did to fix it
[QUOTE=laylay;38524819]This is all you need really, simple stuff. Much better than a single sheet and you wont run into any artifacts. [URL="http://www.opengl.org/wiki/Array_Texture"]http://www.opengl.org/wiki/Array_Texture [/URL] So you'll still be able to draw different textured blocks with a single draw call, each vertex will need a texture id though, which isn't a big deal.[/QUOTE]You could still do something like putting it in a 16x16 block sheet and scaling the texcoords in the frag shader and then getting the x,y of it. Then you do like int i = x_width * y + x; to get the id and then just get the correct texture
If you work out the texcoords in shader by using a texcoord lookup then you don't need to pass in texcoords. You'll just need an int for texcoord lookup and an int for texture id. It's still the same amount of memory though but I think it's a nicer way of doing it.
Is there a way to execute python script on a computer without python installed without using py2exe? I use pygal in my script and it doesn't work with py2exe or py2installer for some reason [editline]21st November 2012[/editline] -edit- Nevermind, I just shoved all the modules I need into a portable python installation and it seems to work fine
[QUOTE=Bumrang;38533566]So I've had this one bug that's pretty much stopped my development of anything for the last month or so. When I put it in a class it stopped drawing.[/QUOTE] I've had a cursory glance through your code and while I'm not certain the cause is the same as an issue I was having or not, it's certainly something to consider. You're using globals - I'd strongly recommend against that. At this stage, you should be able to create everything in the Main function and pass everything around (as references) to the constructors of other objects that need it. Later on you'll probably need to decouple more but this will work for now. Given you're using globals (and objects), you might run into problems with the [url=http://www.parashift.com/c++-faq-lite/static-init-order.html]static initialisation order fiasco[/url]. This was a problem in my case - the way I'd set up my objects meant that sometimes OpenGL functions were being called before OpenGL was actually initialised or ready for them. I fixed my problem by initialising the object later using a pointer with new, but your case may be different. Something to look for, anyway - for now, try moving all of the opengl setup stuff from engine::engine into main and see if that fixes anything
Anyone know if its posible to use GLFW in the same way as you do SFML events? ie: being able to ask the system if the button has been pressed instead of is the button pressed?
[QUOTE=laylay;38536081]If you work out the texcoords in shader by using a texcoord lookup then you don't need to pass in texcoords. You'll just need an int for texcoord lookup and an int for texture id. It's still the same amount of memory though but I think it's a nicer way of doing it.[/QUOTE] I thought about this. And maybe it's possible to simplify this even further. Wouldn't it be possible to just have VertexPositions, VertexColor, and then another array with that just specifies one byte per vertex (the block id). And then you have a special shader that knows the texturesize and blocksize (size of the sub-textures) already - as hardcoded values. Then the shader could map the correct texture on that block just with the information of position, color and blockid. Would that work? Also wouldn't that suffer from the same problem (strange lines at the borders) ? Would texelFetch(...) instead of texture2d(...) help there? Would it even be possible to use textelFetch with mipmaps (while not provoking that "bleeding" problem) ? So many questions :( [editline]21st November 2012[/editline] [QUOTE=Richy19;38539243]Anyone know if its posible to use GLFW in the same way as you do SFML events? ie: being able to ask the system if the button has been pressed instead of is the button pressed?[/QUOTE] I don't get the last sentence. Whats the deifference you're looking for? Maybe a code sample would help...
[QUOTE=Felheart;38539392] I don't get the last sentence. Whats the deifference you're looking for? Maybe a code sample would help...[/QUOTE] Basically if Iuse IsKeyPressed() then I get true every loop that the key is held down, but I only want it to return true the first time, and only with some keys. Im going to try using callbacks and bool aray, but I cant figure out how many keys GLFW supports so I dont know how big to make my array
For some reason a file in my solution always gets skipped when I compile, even when I make changes to it: [cpp]1>------ Build started: Project: water game, Configuration: Debug Win32 ------1> objects.cpp 1> Skipping... (no relevant changes detected) 1> water game.cpp 1> water game.vcxproj -> \water game\Debug\water game.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========[/cpp] I may comment the entire file out, it'll still say that there are "no relevant changes detected". I have to use "Clean Solution" every time I make any changes to the objects.cpp file. What's going on? [editline]21st November 2012[/editline] This is VS2010 Express, by the way.
I made a keyboard class such as: [cpp] #include <GL/glfw.h> namespace KeyBoard{ enum KeyState { KEY_PRESSED, KEY_RELEASED, UNKNOWN }; class Keyboard { public: Keyboard(); ~Keyboard(); bool IsKeyPressed(int key); bool keys[GLFW_KEY_LAST]; private: }; static Keyboard keyboard; void SetCallBack(int key, int state); }[/cpp] [cpp]#include "Keyboard.hpp" KeyBoard::Keyboard::Keyboard() { for(int i = 0; i < GLFW_KEY_LAST; i++) { keys[i] = false; } } KeyBoard::Keyboard::~Keyboard() { //dtor } void KeyBoard::SetCallBack(int key, int state) { if(key >= GLFW_KEY_LAST) return; if(state == GLFW_PRESS) KeyBoard::keyboard.keys[key] = true; else if(state == GLFW_RELEASE) KeyBoard::keyboard.keys[key] = false; } bool KeyBoard::Keyboard::IsKeyPressed(int key) { return keys[key]; }[/cpp] I then set the function as: [cpp]glfwSetKeyCallback(KeyBoard::SetCallBack); [/cpp] However when I try to test it: [cpp] if(KeyBoard::keyboard.IsKeyPressed(GLFW_KEY_ESC)) Close(); [/cpp] Nothing
[QUOTE=Richy19;38539483]Basically if Iuse IsKeyPressed() then I get true every loop that the key is held down, but I only want it to return true the first time, and only with some keys. Im going to try using callbacks and bool aray, but I cant figure out how many keys GLFW supports so I dont know how big to make my array[/QUOTE] I did the same thing (minus the callbacks, because i don't want keys to change mid-frame!). In SFML.net I used: [B](int)Keyboard.Key.KeyCount;[/B] for the size. And every frame I iterate from 0 to KeyCount and call IsKeyPressed((Keyboard.Key)i); GLFW's IsPressed also method has to take some kind of argument (most likely a enum), so your arraysize should be known. [editline]21st November 2012[/editline] Is your SetCallBack even called? Set a breakpoint and watch the "key" argument. It should work the way you posted it.
[QUOTE=Felheart;38540098]I did the same thing (minus the callbacks, because i don't want keys to change mid-frame!). In SFML.net I used: [B](int)Keyboard.Key.KeyCount;[/B] for the size. And every frame I iterate from 0 to KeyCount and call IsKeyPressed((Keyboard.Key)i); GLFW's IsPressed also method has to take some kind of argument (most likely a enum), so your arraysize should be known. [editline]21st November 2012[/editline] Is your SetCallBack even called? Set a breakpoint and watch the "key" argument. It should work the way you posted it.[/QUOTE] The callback is never called. I have hack a different method so it does now work but its not as good performance wise
[QUOTE=Richy19;38540391]The callback is never called. I have hack a different method so it does now work but its not as good performance wise[/QUOTE] This is from the [URL="http://content.gpwiki.org/index.php/GLFW:Tutorials:Basics"]gpwiki GLFW page[/URL]: [code] void GLFWCALL My_Key_Callback(int key, int action) { if (key == GLFW_KEY_ESC && action == GLFW_PRESS) quit_the_program = 1; else if (key == 'A' and action == GLFW_PRESS) printf("A was pressed"); } // And somewhere in the init code glfwSetKeyCallback(My_Key_Callback); [/code] If you need the constants you can look in glfw.h
[QUOTE=ahdge;38541142]This is from the [URL="http://content.gpwiki.org/index.php/GLFW:Tutorials:Basics"]gpwiki GLFW page[/URL]: [code] void GLFWCALL My_Key_Callback(int key, int action) { if (key == GLFW_KEY_ESC && action == GLFW_PRESS) quit_the_program = 1; else if (key == 'A' and action == GLFW_PRESS) printf("A was pressed"); } // And somewhere in the init code glfwSetKeyCallback(My_Key_Callback); [/code] If you need the constants you can look in glfw.h[/QUOTE] It doesnt work, I just tried adding the GLFWCALL as dnt put that the first time but still didnt work
[code] // Shader sources const char* vertexSource = "#version 150\n" "in vec2 position;" "in vec3 color;" "out vec3 Color;" "void main() {" " Color = color;" " gl_Position = vec4( position, 0.0, 1.0 );" "}"; [/code] How come this is valid C++
Adjacent string literals are concatenated. [editline]21st November 2012[/editline] That piece of code is just specifying a string which contains some GLSL code.
I see, but how come it's of data type char, but you don't declare it with [], but instead with a *
It's a C string; the "string variable" is just a pointer to the first character in the string, and the string ends in a null character.
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
Apparently Lua is relatively easy to embed with some wrappers but I've never personally used any
[QUOTE=ThePuska;38543206]It's a C string; the "string variable" is just a pointer to the first character in the string, and the string ends in a null character.[/QUOTE] Im more intreaged with how the string can just stop and then continue? [cpp] "#version 150\n" <---- nothing specifying the string continues "in vec2 position;" [/cpp] [editline]21st November 2012[/editline] [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] Simple lua binder is meant to be easy to use, however It wouldnt compile last time I tried and it apparently doesnt allow you to do something or other which I cant remember but mehh [url]http://code.google.com/p/slb/[/url]
[QUOTE=Richy19;38543347]Im more intreaged with how the string can just stop and then continue? [cpp] "#version 150\n" <---- nothing specifying the string continues "in vec2 position;" [/cpp][/QUOTE] There's nothing specifying that the expression terminates after the first line, so the next line of code is just continuation to the last one. The two strings are adjacent and thus concatenated.
[QUOTE=Richy19;38543347]Im more intreaged with how the string can just stop and then continue? [cpp] "#version 150\n" <---- nothing specifying the string continues "in vec2 position;" [/cpp][/QUOTE] The string doesn't "stop" since there is nothing that ends the statement, eg. a semicolon or an operator. [editline]22nd November 2012[/editline] Basically that's just [cpp]"#version 150\n" "in vec2 position;"[/cpp] [editline]22nd November 2012[/editline] And because of how C and C++ work that automagically turns into [cpp]"#version 150\nin vec2 position;"[/cpp]
-snip- Didnt read the question right
At the moment I'm writing my Spotify API so that it's async, all methods that make a request to Spotify's servers return their result via a callback function. But in some instances, it'd be nice to use these in a synchronous way. I'm thinking the best way to do this would be some kind of wrapper that takes an async method, runs it and waits for it to call it's callback, and then returns the result. You could have a generic class that does this for any method. I'd have thought it'd have been done before, but having Google'd it a bit, I can't find one. Can anyone recommend an implementation for this? This is in Python, by the way.
[QUOTE=mechanarchy;38536808]I've had a cursory glance through your code and while I'm not certain the cause is the same as an issue I was having or not, it's certainly something to consider. You're using globals - I'd strongly recommend against that. At this stage, you should be able to create everything in the Main function and pass everything around (as references) to the constructors of other objects that need it. Later on you'll probably need to decouple more but this will work for now. Given you're using globals (and objects), you might run into problems with the [url=http://www.parashift.com/c++-faq-lite/static-init-order.html]static initialisation order fiasco[/url]. This was a problem in my case - the way I'd set up my objects meant that sometimes OpenGL functions were being called before OpenGL was actually initialised or ready for them. I fixed my problem by initialising the object later using a pointer with new, but your case may be different. Something to look for, anyway - for now, try moving all of the opengl setup stuff from engine::engine into main and see if that fixes anything[/QUOTE] 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]
For those of you that have experience with matlab/simulink/xPC, could you look at this post and see if you can help me? [URL="http://facepunch.com/showthread.php?t=1207850&p=38541376&viewfull=1#post38541376"]http://facepunch.com/showthread.php?t=1207850&p=38541376&viewfull=1#post38541376[/URL]
How would I go about embedding multiple SWFs in one page without making it terribly slow? I have [URL="http://bluishhh.com/steering-behaviors-seek-flee-and-arrival/"]this[/URL] and it contains 3 SWFs. On my desktop it isn't that much slower but on my laptop it's pretty resource intensive and sluggish...
Sorry, you need to Log In to post a reply to this thread.