• What do you need help with? Version 5
    5,752 replies, posted
Can anyone recommend some good starter tutorials for LWJGL? Or OpenGL in general? I've googled around but I'm just wondering what you guys use/used.
[QUOTE=DarkCybo7;39072954]You're attempting to set a char to a dereferenced char array.[/QUOTE] But is'nt [code] header[18] [/code] The same as [code] *(header+18) [/code] So both sides of the equation "header[18] = *hexwidth" are of char type. In which case I don't understand what I am doing wrong.
Still need help making a drawing class. Here's what I have for a quad: [cpp]void Draw::Rect(float x, float y, float w, float h) { glBegin(GL_QUADS); glVertex3f(x, y, 0.0f); // Top Left glVertex3f(x+w, y, 0.0f); // Top Right glVertex3f(x+w, y-h, 0.0f); // Bottom Right glVertex3f(x, y-h, 0.0f); // Bottom Left glEnd(); }[/cpp] Why doesn't this work [editline]3rd January 2013[/editline] Here's my loop in main [cpp] do{ // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw.Rect(-1, 1, 0.5, 0.5); // Swap buffers glfwSwapBuffers(); } // Check if the ESC key was pressed or the window was closed while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS && glfwGetWindowParam( GLFW_OPENED ) );[/cpp]
Could anyone help me find a formula / algorithm for converting 32bit A8R8G8B8 images to 16bit A4R4G4B4. I have been hard pressed on google for awhile now and the closest I can find is A8R8G8B8 to A1R5G5B5.
[QUOTE=freakadella;39072900]Well here I am, after reading through many pointer and bitmap tutorials, still fighting with this problem i have been having for hours. The problem is, I want to create a bitmap file. After some fiddling, I have a working header and it all works. But now I came across the problem, that I need to be able to create an array of length which must be defined during runtime. No problem, pointers. Or so I thought. In the header part of a bitmap file, the size must be specified. Which means I need to change individual bytes of the char pointer. Should be simple and I feel pretty stupid for struggling with this. I would be greatful if somebody could help me out here: [code] #include <iostream> #include <fstream> using namespace std; unsigned int width = 400; unsigned int height = 400; int datasize = width * height * 4; int main() { fstream file("test.bmp", fstream::out | ios::binary); char * header; header = new char [56]; header = "BM" "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x36\x00\x00\x00" "\x28\x00\x00\x00" "\x10\x00\x00\x00" "\x00\x00\x00\x00" "\x01\x00" "\x20\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00"; char* hexwidth; hexwidth = new char [10]; sprintf(hexwidth, "%X", width % 256); cout << hexwidth; header[18] = *hexwidth; sprintf(hexwidth, "%X", width / 256); cout << hexwidth << "\n"; header[19] = *hexwidth; sprintf(hexwidth, "%X", height % 256); cout << hexwidth; header[22] = *hexwidth; sprintf(hexwidth, "%X", height / 256); cout << hexwidth; header[23] = *hexwidth; char * data; data = new char [datasize]; file.write(header, 56); delete[] header; file.write(data, datasize); delete[] data; file.close(); } [/code] the problem comes here : header[18] = *hexwidth; Unfortuanatelly, the error message is in German; here is a loose translation : "Access violation while writing at Position 0xblahblahblah"[/QUOTE] Header points to unwritable memory because you've initialized it as a string literal. [cpp]header = new char[header_len]; header[0] = 'B'; header[1] = 'M'; /* Other fields... */[/cpp] Or you could use something more appropriate than char arrays for that. Create a bitmap header struct or something. [cpp]struct bmp_header { char signature [2]; .... }; bmp_header header; header.signature[0] = 'B'; header.signature[1] = 'M';[/cpp]
[cpp] int x = 1; do{ try{ credits = creditsInput.nextInt(); //TODO Need try catch! x = 2; }catch(Exception e){ System.out.println("Invalid input!"); } }while(x == 1); [/cpp] Stupid Java code refuses to work properly. I want to make sure that the user doesn't input anything other than numbers so I put up a standard try catch with a do loop. But when it shows the error message it spams it forever instead of letting the user try again. I am following this tutorial exactly and it doesn't work. I've done it before but it still refuses to work properly. [url]http://thenewboston.org/watch.php?cat=31&number=82[/url] It should show the error once and let the user try again. Not spam the error message forever.
[QUOTE=CommanderPT;39079162] Stupid Java code refuses to work properly. I want to make sure that the user doesn't input anything other than numbers so I put up a standard try catch with a do loop. But when it shows the error message it spams it forever instead of letting the user try again. I am following this tutorial exactly and it doesn't work. I've done it before but it still refuses to work properly. [url]http://thenewboston.org/watch.php?cat=31&number=82[/url] It should show the error once and let the user try again. Not spam the error message forever.[/QUOTE] I'm at work so I can't really test this: [code]int x = 1; while(x < 2) { try { string nextline = creditsInput.nextLine(); credits = Integer.parseInt(nextline); x = 2; } catch(Exception e) { System.out.println("Invalid number!"); } }[/code] Also if x only has 2 potential states, look at using a boolean value. edit: edited code with solution that might actually work.
set x to 1 when you print invalid input [editline]3rd January 2013[/editline] oh never mind
[QUOTE=NovembrDobby;39079207]set x to 1 when you print invalid input[/QUOTE] When an exception occurs, it shouldn't execute any further code within that try block. If the value was actually set to 2, the while condition would be invalid so it wouldn't spam anything.
[QUOTE=SteveUK;39079205]I'm at work so I can't really test this: Also if x only has 2 potential states, look at using a boolean value. edit: edited code with solution that might actually work.[/QUOTE] Thanks I'll try that! Also I have one more issue. My assignment is to make a casino machine of some sorts. One issue that I am having is that I have set thing up to check if the player won. Each spot on the three wheels are assigned a number between 0 and 9. So 9 9 9 = the jackpot or whatever. I however need two cases where: two wheels are equal and the third one is five two wheels are equal and the third one is two and possibly a third where: two wheels that do not matter what they are and the third one is two Thing is, I have no idea how to set that up in an if statement. Right now I check for example. - I guess there are better ways to do it. But I can't figure out how I should make the three cases above.
[QUOTE=freakadella;39073146]But is'nt [code] header[18] [/code] The same as [code] *(header+18) [/code] So both sides of the equation "header[18] = *hexwidth" are of char type. In which case I don't understand what I am doing wrong.[/QUOTE] Hmmm. Theoretically, yes. But I usually don't access arrays in that way. Have you tried using header[18] = hexwidth[0] instead of header[18]=*hexwidth and seeing if that works?
[QUOTE=anthonywolfe;39073588]Could anyone help me find a formula / algorithm for converting 32bit A8R8G8B8 images to 16bit A4R4G4B4. I have been hard pressed on google for awhile now and the closest I can find is A8R8G8B8 to A1R5G5B5.[/QUOTE] Okay so I have something that almost works. But some of the bytes are different from the source. But for the most part it's pretty similar. Is this normal or did I do something wrong? [code] for (int i = 0; i < argb.Length; i += 4) { int color = BitConverter.ToInt32(argb, i); Buffer.BlockCopy(BitConverter.GetBytes( ((color & 0xF0000000) >> 16) | ((color & 0xF0000000) >> 12) | ((color & 0x00F00000) >> 12) | ((color & 0x00F00000) >> 8) | ((color & 0x0000F000) >> 8) | ((color & 0x0000F000) >> 4) | ((color & 0x0000000F) >> 4) | (color & 0x0000000F)), 0, decbuff2, i / 2, 2); } [/code] [editline]orly[/editline] I don't see any visible difference after looking over the bitmap after running it through the above code so it seems it worked out fine.
It should be just ((color & 0xf0000000) >> 16) | ((color & 0x00f00000) >> 12) | ((color & 0x0000f000) >> 8) | ((color & 0x000000f0) >> 4) [editline]3rd January 2013[/editline] ANDing with the masks discards everything but the top 4 bits from the individual colors. Shifting shifts them into place within the 16-bit int.
I might make a thread for this, but for now I will leave this here. Anyone know why the GetNetChannelInfo in the source sdk crashes me?
[QUOTE=DarkCybo7;39079716]Hmmm. Theoretically, yes. But I usually don't access arrays in that way. Have you tried using header[18] = hexwidth[0] instead of header[18]=*hexwidth and seeing if that works?[/QUOTE] ThePuska seems to have been correct with the unwritable memory. After I had defined the header using his way I could even do this: [code] header[18] = width % 256; [/code] Nonetheless, many thanks for your help guys!!! [editline]4th January 2013[/editline] With width being an integer.
I installed MSVC 2012 express, and am trying to convert a project to it. However, when running in debug, I get the error MSVCR100D.dll is missing from your computer. The additional libraries I am using is boost and sfml2. How do I fix this? Fixed it by rebuilding SFML 2 with the new MSVC.
[QUOTE=WTF Nuke;39086296]I installed MSVC 2012 express, and am trying to convert a project to it. However, when running in debug, I get the error MSVCR100D.dll is missing from your computer. The additional libraries I am using is boost and sfml2. How do I fix this?[/QUOTE] Go download Microsoft Visual C++ 2010 SP1 Redistributable
Would the redist include the debug dlls though?
I'm trying to use SFML/OpenGL. Using this simple program: [cpp]#include <SFML/System.hpp> #include <SFML/Window.hpp> #include <iostream> int main(int argc, _TCHAR* argv[]) { sf::Window window( sf::VideoMode(800, 600), "OpenGL", sf::Style::Close); while (window.IsOpened()) { sf::Event windowEvent; while (window.GetEvent(windowEvent)) { } } return 0; }[/cpp] Which should just open a window and leave it open, but I'm getting a bunch of unresolved symbol errors like this: [IMG]http://i.imgur.com/bIrk9.png[/IMG] There are fewer errors when I use dynamic linking than when I use static linking, but they're still there nonetheless. Any help here? It would be much appreciated.
If you use static linking you need to have the preprocessor #define SFML_STATIC
[QUOTE=Meatpuppet;39087130]If you use static linking you need to have the preprocessor #define SFML_STATIC[/QUOTE] I still get the same errors :/
[QUOTE=SashaWolf;39084660]I might make a thread for this, but for now I will leave this here. Anyone know why the GetNetChannelInfo in the source sdk crashes me?[/QUOTE] Used to crash for me when calling it on entity index 0.
[QUOTE=account;39087265]I still get the same errors :/[/QUOTE] What IDE are you using?
[QUOTE=Meatpuppet;39087381]What IDE are you using?[/QUOTE] Visual Studio 11 Beta. I figured this might be a problem, but I was able to load all the files into the correct folders.
I'm very new to VB, and I want to make a program where the user can choose and replace one file on their system with another. I'm thinking of how to do it, and I'm having some trouble. I think a combo box would work great for selecting the files, but I'm having some difficulty in figuring out how to put variables in the combo box instead of just strings.
[QUOTE=account;39087624]Visual Studio 11 Beta. I figured this might be a problem, but I was able to load all the files into the correct folders.[/QUOTE] Visual Studio 11 (now 2012) went RTM a couple of months ago? Use Express for Windows Desktop if you can't get hold of the full version. [editline]4th January 2013[/editline] [QUOTE=A big fat ass;39088057]I'm very new to VB, and I want to make a program where the user can choose and replace one file on their system with another. I'm thinking of how to do it, and I'm having some trouble. I think a combo box would work great for selecting the files, but I'm having some difficulty in figuring out how to put variables in the combo box instead of just strings.[/QUOTE] VB.net? I would recommend C# over that unless you're being forced to use it. If it is .NET you can actually use the native Windows file picker rather than binding a combo box with some file names.
I'm a complete beginner to all kinds of programming, i've read through some other people's code in a few different languages but that's about it, now I finally decided to try learning a simple language, so i'd like to ask you what language it would be best for a complete beginner to start with, and where to start learning it.
Hello gentlemen, Being new to C++ I ma having some trouble with switch statements. I am in the process of making a tic tac toe game (very basic). I have the user input an x and a y coordinate (for instance tc is top centre, br, bottom right). I am using switch statements to resolve the answer but I am not sure if I am using them correctly, it is also my first attempt at using functions so I have most likely misunderstood how they work. Apologise for the noob and probably poorly written code but if you wish to help me out here is. [url]http://pastebin.com/DzsaXskm[/url] Thank you very much ^.^
[QUOTE=Two-Bit;39091846]Hello gentlemen, Being new to C++ I ma having some trouble with switch statements. I am in the process of making a tic tac toe game (very basic). I have the user input an x and a y coordinate (for instance tc is top centre, br, bottom right). I am using switch statements to resolve the answer but I am not sure if I am using them correctly, it is also my first attempt at using functions so I have most likely misunderstood how they work. Apologise for the noob and probably poorly written code but if you wish to help me out here is. [URL]http://pastebin.com/DzsaXskm[/URL] Thank you very much ^.^[/QUOTE] First of all, you should read up on Scope. The variable Place is only available in the Main function and thus your function Place1 will not be able to use it. You have to pass it as a parameter to the function. Second of all, you can't use strings in switch statements. Only primitive types like int and char. I also just noticed you're declaring the string Place twice. You also don't return any values in your functions. And you have to put the Place1 function above Main or you can't call it from Main.
[QUOTE=account;39087624]Visual Studio 11 Beta. I figured this might be a problem, but I was able to load all the files into the correct folders.[/QUOTE] You need to compile sfml 2.0 for vs11 using nmake. It won't work otherwise.
Sorry, you need to Log In to post a reply to this thread.