Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About FreeTutorialNewbie

  • Rank
  1. FreeTutorialNewbie

    Window redraw

    there is a message for when dragging stats and when dragging finishes however doing such will most likely bog down the machine you can even make your own code that detects when the top region is clicked on and capture the mouse and continuously reposition the window and stop when the left button is up best course of action is to not do either and allow the user's machine settings to control stuff like that.
  2. you can always close the window reset the devmode reopen a new window reinit opengl reload all textures etc and continue normal execution
  3. FreeTutorialNewbie

    crash on realloc?

    so basically... i kinda though basing your code on your compiler was bad..code is supposed to be portable and work on all compilers (or as close as you can get it) not trying to step on anybodies toes by any means
  4. FreeTutorialNewbie


    well..at least is my means of opening and using the argument pointer correct? I couldn't really find tutorials for multithreading..so i kinda poked around in the dark the reason i proposed handling the wave messages in the winproc is because according to msdn docs using almost any function inside of waveinproc causes it to hang. i wouldnt be able to send on the network from within the waveinproc thats also the reason for making a separate thread, wouldnt calling the send function everytime you get a done buffer kinda slow down the winproc? basically what the original plan was to handle the entire recording and sending, recieving and playback, and maintaining the socket connection in 1 independant thread all this while winmain handles fancy smancy window drawing stuff i havent began to put in yet, such as an admin control panel and a settings dialog box, etc. the plan for the server was to have a thread dedicated to accepting connections, that spun off threads to recv and send until connection is closed there will be 1 structure given to all threads so when a thread recv's data, it sends it to all connected clients by cycling through each socket in the shared data struct i actually made 2 separate projects with working winsock code so it should be a matter of copy and paste (i hope..lol) thank you all who read this and put up with us newbs ps: if i post code here i allow anybody to use it
  5. FreeTutorialNewbie

    Next Gen Games.......(Doom3..)

    http://www.drunkenhyena.com/pages/projects/d3d_tutorial.php use that link for directx tutorials
  6. FreeTutorialNewbie

    Next Gen Games.......(Doom3..)

    nehe.gamedev.net thats got to be the best opengl tutorials i know of, http://www.drunkenhyena.com/ directx tutorials modeled after nehe tutorials, useful for see how doing something translates between the two
  7. FreeTutorialNewbie

    Next Gen Games.......(Doom3..)

    directx enforces a single standard and you have to remake certain parts of your code for each directx version (usually simple stuff) opengl is really based on the standard as interpreted by the graphics driver programmer, different things will look different on some video cards, and this means new and cutting edge stuff (such as 64 bit color) will always be available for opengl first you usually have to do a string search on the opengl supported functions string to see what is supported on each and every machine, and assign function pointers if that function hasnt been implemented in your compilers library yet. the main ideas of both api's are similiar, you almost implement them the same way, as a matter of fact, you can implement opengl, and multiple versions of directx if you have that much time, and even make a console dialog box that allows the end user to choose what api he wants
  8. FreeTutorialNewbie


    would useing the same callback as my mainwindow work fine, instead of having to make a separate callback function? would having the callback operation inside the window callback cause periods of nonresponsivenes?
  9. FreeTutorialNewbie

    Direct3D manual drawing

    try using the HDC method like that one guy said. then you can SetPixel(HDC,x,y,RGB(255,255,255)); of even maybe a BitBlt method and drawing a bitmap?
  10. FreeTutorialNewbie


    yea...but for the most part the replies are about simple stuff like running a program that doesnt open a window and painting a bitmap to a windows background would i have to make the waveheader and buffers global to be able to reach them in the callback or is the callback considered within this thread's scope?
  11. FreeTutorialNewbie


    after removing what i was told to remove, the text output clearly displays a changing recording buffer. Thanks alot. here is the code so far... i indent my code but all indents are removed here..so it does look messy i should also comment more often do you think i should use a pointer to the maindata structure to speed up execution?, or in this case would it matter? notice the sleep method to keep this thread from useing up the cpu and freezing the computer, also a variable sleep time will be needed since it will run at the same time as some memory and cpu hungry massive 3d accelerated game, meaning if i used a constant sleep time it may be too slow #include <windows.h> #include <windowsx.h> #include <commctrl.h> #include <string.h> #include <mmsystem.h> #include <winsock2.h> #include <stdio.h> #include <process.h> #include "elitespeakres.h" typedef struct{ short sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8];} sockaddr_in; typedef struct{ int Status; char NetID; SOCKET Socket; sockaddr_in SockAddr; char *UserName; char *Password;} NETWORK; typedef struct{ HWND Hwnd; HINSTANCE Hinst; int DoRun; int Mode; int Status; MSG Msg; } MAINDATA; MAINDATA MainData; static BOOL CALLBACK DialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam){ switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: MainData.Mode=1; return 1; case IDCANCEL: MainData.Mode=0; return 1;} break; case WM_CLOSE: PostQuitMessage(0); return 1;} return 0;} void WavePlayBack(void){ int PlayTimer=0; char *c="papapapapapapapapapapapapap"; char d[4]; HWAVEOUT outHandle; HWAVEIN inHandle; WAVEFORMATEX waveFormat; waveFormat.wFormatTag = WAVE_FORMAT_PCM; waveFormat.nChannels = 1; waveFormat.nSamplesPerSec = 8000; waveFormat.wBitsPerSample = 8; waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSample/8); waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign; waveFormat.cbSize = 0; WAVEHDR waveouthdr, waveinhdr; while(MainData.DoRun){ Sleep(100); if(!MainData.Mode){ if(!waveOutOpen(&outHandle,WAVE_MAPPER,&waveFormat,0,0,CALLBACK_NULL)){ memset(&waveouthdr,0,sizeof(waveouthdr)); waveouthdr.lpData = c; waveouthdr.dwBufferLength = 4; waveouthdr.dwBytesRecorded = 1; waveouthdr.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP; waveouthdr.dwLoops = 1; waveOutPrepareHeader(outHandle,&waveouthdr,sizeof(waveouthdr)); waveOutWrite(outHandle,&waveouthdr,sizeof(waveouthdr)); PlayTimer=0; while(!MainData.Mode){ Sleep(1); PlayTimer++; if((waveouthdr.dwFlags & WHDR_DONE)==WHDR_DONE){ waveouthdr.dwFlags &= ~WHDR_DONE; PlayTimer--; waveOutWrite(outHandle,&waveouthdr,sizeof(waveouthdr)); Sleep(PlayTimer);}} waveOutReset(outHandle); waveOutClose(outHandle);} }else{ if(!waveInOpen(&inHandle,WAVE_MAPPER,&waveFormat,0,0,CALLBACK_NULL)){ memset(&waveinhdr,0,sizeof(waveinhdr)); waveinhdr.lpData = d; waveinhdr.dwBufferLength = 4; waveinhdr.dwBytesRecorded = 1; waveinhdr.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP; waveinhdr.dwLoops = 1; waveInPrepareHeader(inHandle,&waveinhdr,sizeof(waveinhdr)); waveInAddBuffer(inHandle,&waveinhdr,sizeof(waveinhdr)); waveInStart(inHandle); PlayTimer=0; while(MainData.Mode){ Sleep(1); PlayTimer++; if((waveinhdr.dwFlags & WHDR_DONE)==WHDR_DONE){ waveinhdr.dwFlags &= ~WHDR_DONE; PlayTimer--; //see what we have recorded TextOutA(GetDC(MainData.Hwnd),0,0,d,4); waveInAddBuffer(inHandle,&waveinhdr,sizeof(waveinhdr)); if(PlayTimer>30){ PlayTimer=1;} Sleep(PlayTimer);}} waveInStop(inHandle); waveInReset(inHandle); waveInClose(inHandle); }}}} int APIENTRY WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow){ WNDCLASS wc; INITCOMMONCONTROLSEX cc; WSADATA wsadata; int ret=0; if(WSAStartup(MAKEWORD(2,1),&wsadata)!=0){ MessageBox(NULL,"This program has encountered an error while attempting \n to initiate windows sockets version 2.1 or higher.", "Critical Error",MB_OK|MB_ICONERROR); }else{ memset(&MainData,0,sizeof(MAINDATA)); MainData.DoRun=1; beginthread(WavePlayBack,20000,&MainData); memset(&wc,0,sizeof(wc)); wc.lpfnWndProc = DefDlgProc; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = hinst; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszClassName = "EliteSpeak"; if(RegisterClass(&wc)){ memset(&cc,0,sizeof(cc)); cc.dwSize = sizeof(cc); cc.dwICC = 0xffffffff; InitCommonControlsEx(&cc); MainData.Hinst=hinst; if((MainData.Hwnd=CreateDialog(MainData.Hinst,MAKEINTRESOURCE(IDD_MAINDIALOG),NULL,(DLGPROC)DialogFunc))!=NULL){ MainData.DoRun=1; while(MainData.DoRun){ if(PeekMessage(&MainData.Msg,MainData.Hwnd,0,0,PM_REMOVE)){ if(MainData.Msg.message==WM_QUIT){ MainData.DoRun=0; }else{ TranslateMessage(&MainData.Msg); DispatchMessage(&MainData.Msg);} }else{ Sleep(50); }} DestroyWindow(MainData.Hwnd); }else{ MessageBox(NULL,"This program has encountered an error while \n attempting to create the main window.", "Critical Error",MB_OK|MB_ICONERROR);} UnregisterClass("EliteSpeak",MainData.Hinst); }else{ MessageBox(NULL,"This program has encountered an error while \n attempting to register a window class.", "Critical Error",MB_OK|MB_ICONERROR);} WSACleanup();} return MainData.Msg.wParam;} any help would be appreciated, btw this is my first day using gamedev, and its way better than other forums mainly because of its members
  12. FreeTutorialNewbie


    thank you for the help, this is going to be a "team speak wanna bee" and that thread will be responsible for handling the audio playback recording, and it it toggled to support legacy audio drivers believe it or not i figured out winsock (multithreaded server even) way before any of this wave api stuff clicked in my head so when you consider that the playback/recording waits for network data to be sent or received, does it begin to make sence? (after the recommended changes ofcourse) and it will play and record more than4 bytes, its just popping text representation so i can see the actual values change with the recorded sounds, as of now it remains {0,0,0,0} wich looks like 4 filled boxes in ascii thats also the reason for the crappy audio resolution, trying to work it accross the internet and trying to consider the load on the server, what audio format to you recommend and how long of a recording in bytes? (think dialup compatibility please) for those of you who havent seen or used team speak its a voice communication app used by gamers to keep in touch with freinds while playing games over the internet the game being played will consume most of the available network bandwidth, so i will have to keep throughput to a minimum
  13. FreeTutorialNewbie

    C++ to C

    thank god this arguement is limited to 2 languages, and not every language available, or else we would have a riot on our hands
  14. FreeTutorialNewbie

    C++ to C

    LCC Win32 suports c99 some other compilers may, but c isnt the most popular language anymore, but still serves its purpose and serves it well
  15. FreeTutorialNewbie

    crash on realloc?

    ok..i found this in a tutorial written for the lcc win32 compiler authored by Jacob Novia Instead of using directly malloc/free here are two implementations of equivalent functions with some added safety features: 1Freeing NULL is allowed Memory management strategies 127 2 Double freeing is made impossible. 3 Any overwrite immediately at the end of the block is checked for. 4 Memory is initialized to zero. 5 A count of allocated memory is kept in a global variable. #define MAGIC 0xFFFF #define SIGNATURE 12345678L size_t AllocatedMemory; void *allocate(size_t size) { register char *r; register int *ip = NULL; size += 3 * sizeof(int); r = malloc(size); if (r == NULL) return r; AllocatedMemory += size; ip = (int *) r; // At the start of the block we write the signature *ip++ = SIGNATURE; // Then we write the size of the block in bytes *ip++ = (int) size; // We zero the data space memset(ip, 0, size - 3*sizeof(int)); // We write the magic number at the end of the block, just behind the data section ip = (int *) (&r[size - sizeof(int)]); *ip = MAGIC; // Return a pointer to the start of the data area return (r + 2 * sizeof(int)); } void release(void *pp) { register int *ip = NULL; int s; register char *p = pp; if (p == NULL) // Freeing NULL is allowed return; // The start of the block is two integers before the data. p -= 2 * sizeof(int); ip = (int *) p; if (*ip == SIGNATURE) { // Overwrite the signature so that this block can’t be freed again *ip++ = 0; s = *ip; ip = (int *) (&p[s - sizeof(int)]); if (*ip != MAGIC) { ErorPrintf(“Overwritten block size %d”, s); return; } *ip = 0; AllocatedMemory -= s; free(p); } else { /* The block has been overwritten. Complain. */ ErrorPrintf(“Wrong block passed to release”); } } The allocate function adds to the requested size space for 3 integers. 1) The first is a magic number (a signature) that allows the identification of this block as a block allocated by our allocation system. 2) The second is the size of the block. After this two numbers, the data follows. 3) The data is followed by a third number that is placed at the end of the block. Any memory overwrite of any block will overwrite probably this number first. Since the “release” function check for this, we will be able to detect when a block has been overwritten. At any time, the user can ask for the size of total allocated memory (valid blocks in circulation) by querying the AllocatedMemory variable. The “release function” accepts NULL (that is ignored). If the pointer passed to it is not NULL, it will check that it is a valid block, and that the signature is still there, i.e. that no memory overwrites have happened during the usage of the block. -im not sure it it is compatible with all compilers, but i figure it can be modified to fit your needs
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!