collapse collapse

* Who's Online

  • Dot Guests: 70
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11163
  • stats Total Topics: 1699
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 248

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - powerfear

Pages: [1] 2
1
C++ / Re: Undeclared Indentifier
« on: April 30, 2013, 04:59:05 pm »
I fixed it for you, I attached the working source below.

First you were using precompiled header wrong. I fixed that, your precompiled header (Stdafx in your case) should be included at the start of every .cpp but not in any .h!
Then you need to set the project to use precompiled header, then you need to create a source file Stdafx.cpp that will be the only file to create the precompiled header, if you right click a file you can change precompiled header option on that single file, thats what I did for you. Another thing you did wrong is how you used the precompiled header, you included every single one of your header there which defeat the purpose of having precompiled header, any change to a file contained in the precompiled header will trigger its recompilation. Precompiled header are used to save compilation time so you can include stuff that won't change in them example the standard library and the other library you are using example in your case sdl.

Also in your objectmanager class you had a vector of object and not pointer to object. That's a bad thing if something is bigger then the size of a pointer it should be a pointer or a reference. Pointer allowed forward class declaration to work so I didnt need to include the object header in the objectmanager header, I added header in your source file only where nescecary. If you wonder why you can't simply add all your header everywhere that's because they are likely to often have modification so you will have extremely long compilation time if your project ever scale up. It's good to take the practice of using precompiled header properly, using forward declaration everywhere possible, and only including header where they are really needed.

2
C++ / Re: [Sockets] Having some problems.
« on: February 19, 2013, 01:04:08 pm »
A bit off-topic but if you wish to support concurrency and you have no experience using winsock is an horrible idea. I would go for a library like Boost Asio or POCO, they both are very efficient and will take care of the concurrency behind a worker thread system. They don't enforce any premade protocol on you either, only give you an equivalent read / write system. This will most likely save you a lots of time and you won't run into errors like this one, and judging by your current code which is not using the most efficient way to handle networking on windows, you will gain performance, and also cross-platform ability.

http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio.html
http://pocoproject.org/

3
OpenGL / Re: Using VBO's to render a Cube
« on: November 17, 2012, 10:23:58 am »
are your directory like this:

ex: i place glew in C:

include: C:\glew-1.9.0\include
lib: C:\glew-1.9.0\lib

and for both settings (debug and release) at top of project properties, Configuration: All configuration
you may have setted it up only for debug and you are using release or vice versa

4
OpenGL / Re: Using VBO's to render a Cube
« on: November 16, 2012, 12:48:40 pm »
did you link glew32s.lib?

also don't forget to define glew static before the include, but if you are using my precomp.h it should already work.

#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/wglew.h>

Another problem could be if you use the 64 bit glew and not the 32 bit glew

5
OpenGL / Re: Using VBO's to render a Cube
« on: November 15, 2012, 11:12:05 pm »

6
OpenGL / Re: Using VBO's to render a Cube
« on: November 15, 2012, 11:45:37 am »
If you're on windows it should come with visual studio by default.

it's over there on win7 x64: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\Gl\glu.h

here's the file http://pastebin.com/3Q6tazSv

7
Hardware Hacking / Re: Raspberry Pi controlling a LDP8806 LED Strip
« on: November 11, 2012, 01:10:45 pm »
Not Found

The requested URL /tutorials-143/raspberry-pi-controlling-a-ldp8806-led-strip/msg12372/\"http://www.youtube.com/embed/-9bquYQzxvA was not found on this server.
Apache/2.2.14 (Ubuntu) Server at celestialcoding.com Port 80

;p

8
OpenGL / Re: Using VBO's to render a Cube
« on: November 09, 2012, 06:31:28 pm »
It's from this https://github.com/pabennett/glblox

I modified it a week ago so it work only with C++ and I modified some stuff like I made the shader work with lower version of OpenGL it should support opengl2 and I added texture. There is some bug with it that I am still not sure how to fix, like some black artifact that appear with certain camera angle.

But I am now working on a new version from scratch that won't use shader and will be cleaner, that guy didn't code in a way i like ;p. Might open a github repository for it soon.

9
OpenGL / Re: Using VBO's to render a Cube
« on: November 09, 2012, 04:30:48 pm »
Below I attached some code, there is some stuff you may not need, most interesting part are in Chunk.cpp and in the shader files, vertex.shader and fragment.shader

10
Modify your function then right now it only take 3 arguments

Code: C++
  1. private: void SetXY(int& x, int& y, double angle_radians, int newarg1, int newarg2)
  2. {
  3.              //and change some of your logic here to work with your new arguments
  4.              x = xcenter + smajor * Math::Cos(angle_radians);
  5.              y = ycenter - sminor * Math::Sin(angle_radians);
  6.  
  7. }
  8.  

11
Trash / G
« on: August 28, 2012, 02:39:01 pm »
G

12
C# / Re: Issue with GUI with OutputLabel and OKButton
« on: June 30, 2012, 11:13:51 am »
OKButton and OuputLabel are not static while the function you are using: public static void SmallLarge(int[] entries) is static.

A static function can not access members that are not static. So make that function not static and it will work. public void SmallLarge(int[] entries)



13
Project Advertisment / Re: Memory Scanner
« on: February 01, 2012, 06:47:01 pm »
HE IS ALIVE!!!!!!!

On another note, do you plan on making it using ReadProcessMemory / WriteProcessMemory or injecting a .dll to directly read the memory.

14
php / Re: Can't connect to database
« on: July 14, 2011, 11:36:06 am »
Ok so your problem is quite obvious, either you got the wrong login/password combination or the ip you are connecting from is not allowed, in this case if i understood correctly you are logging-in from your external ip. Your external ip may not be allowed to connect, but anyways there is no reason to use your external ip to connect to a database that is hosted on the same computer as the php script. So just try using "localhost" or "127.0.0.1" to connect and tell me if it worked.

15
Software support / Re: system32 folder popping up constantly?
« on: April 06, 2011, 06:29:58 pm »
perhaps you can try using this software: http://www.rohitab.com/apimonitor or something similar to see what process is making the call to open it? Might not work if it's actually an advanced virus.

16
Project Advertisment / Re: SimpleGameLibrary
« on: October 12, 2010, 05:54:35 pm »
Ah, I see its built on top of Irrlicht, I'm using it currently for 3D really nice engine.

Good luck with your game library, might get widely used if you keep working on it and make a nice doc with lots of example ;P

17
Suggestions / Re: Next eBook?
« on: July 17, 2010, 10:48:26 am »
My vote was Custom Script Language 101, since it look interesting to make your own scripting language.

18
Introductions / Re: Hello
« on: July 11, 2010, 11:59:19 am »
Since sometime microsoft recommand to use raw input rather then direct input for the input so direct input is somewhat useless now.

Quote
Microsoft are now advising you to use the Raw Input functions rather than DirectInput for keyboard and mouse and to just use DirectInput for joysticks.

Also if you want to use sprite with Directx you have to know there is a bug that modify the image size, that is really annoying.

That's why more advanced poeple use textured quads rather then sprite.

Directx is also less user friendly then OpenGL, it's more complicated and may be harder to use then OpenGL. Thought that if you want to work for those big game publisher that make game for Windows most of them use Directx so it's a good thing to know it. But i'll say that if you just want to make game alone, OpenGL might be a better option since it's somewhat easier to use and is more portable then Directx.

19
C++ / C++ code cave
« on: May 15, 2010, 01:08:41 pm »
ok here's how you easily make codecave with C++ also called detours

note: this is a basic way to hook, and might be detected by online game that use anti-hacking system

Ok so start by creating a new project Win32 project

Application type: DLL

Additional options: Empty project

Ok so basicaly how it work is that you create a __declspec(naked) void function, those kind of function don't have any C++ prefix or anything so you can use pure asm with them.

inside the function you insert the desired asm content of your codecave inside
__asm
{

}
 you can also mix up with some C++ if you know what you're doing.

now you need to call your codecave at your desired location so we need a hooking function (creating a jmp to the code cave)

here's a simple one with the little advantage of automaticly using VirtualProtect to allow writting on the specified memory area if it's protected

Code: C
  1. void CopyBuffer(BYTE *Buffer, int Size, DWORD *Address)
  2. {
  3.         DWORD pPrevious = 0;
  4.         VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, &pPrevious);
  5.         memcpy(Address, Buffer, Size);
  6.         VirtualProtect(Address, Size, pPrevious, &pPrevious);
  7. }
  8.  
  9. void SetupHook(DWORD Function, DWORD Hook, int Size)
  10. {
  11.         Hook = Hook - Function - 5;
  12.         BYTE bHook[4];
  13.         memcpy(bHook,(void*)&Hook,4);
  14.         BYTE Buffer[10];
  15.         memset(Buffer,0x90,10);
  16.         Buffer[0] = 0xE9;
  17.         Buffer[1] = bHook[0];
  18.         Buffer[2] = bHook[1];
  19.         Buffer[3] = bHook[2];
  20.         Buffer[4] = bHook[3];
  21.         CopyBuffer(Buffer, Size, (DWORD*)Function);
  22. }
  23.  

now let's look at a fake example i made up for a game that don't exist

Code: C
  1. #include <windows.h>
  2. DWORD hookaddy = 0x004B9302;
  3. DWORD addy = 0x004FC260;
  4. DWORD addy2 = hookaddy+5
  5. int loop = 50;
  6. __declspec(naked) void CodeCave()
  7. {
  8.         __asm
  9.         {
  10.                 MOV EAX,loop;
  11.                 loopstart:
  12.                 PUSH EAX;
  13.                 CALL addy1;
  14.                 POP EAX;
  15.                 DEC EAX;
  16.                 CMP EAX,0;
  17.                 JNZ loopstart;
  18.                 JMP addy2;
  19.         }
  20. }
  21.  
  22. void CopyBuffer(BYTE *Buffer, int Size, DWORD *Address)
  23. {
  24.         DWORD pPrevious = 0;
  25.         VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, &pPrevious);
  26.         memcpy(Address, Buffer, Size);
  27.         VirtualProtect(Address, Size, pPrevious, &pPrevious);
  28. }
  29.  
  30. void SetupHook(DWORD Function, DWORD Hook, int Size)
  31. {
  32.         Hook = Hook - Function - 5;
  33.         BYTE bHook[4];
  34.         memcpy(bHook,(void*)&Hook,4);
  35.         BYTE Buffer[10];
  36.         memset(Buffer,0x90,10);
  37.         Buffer[0] = 0xE9;
  38.         Buffer[1] = bHook[0];
  39.         Buffer[2] = bHook[1];
  40.         Buffer[3] = bHook[2];
  41.         Buffer[4] = bHook[3];
  42.         CopyBuffer(Buffer, Size, (DWORD*)Function);
  43. }
  44.  
  45. DWORD WINAPI dwMainThread(LPVOID)
  46. {
  47.         SetupHook(hookaddy,(DWORD)CodeCave,5);
  48.         return 0;
  49. }
  50.  
  51. BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
  52. {
  53.         DisableThreadLibraryCalls(hDll);
  54.         if ( dwReason == DLL_PROCESS_ATTACH )
  55.         {
  56.                 CreateThread(NULL, NULL, dwMainThread, NULL, NULL, NULL);
  57.         }
  58.         return TRUE;
  59. }
  60.  

The creating of a thread to do the SetupHook is optional there since i don't have anything else to do, but if you have other code you could put it inside the dwMainThread.

Ok so now i'll explain what the example do, since it's a .dll once it will be injected it will run the CreateThread function that will run the dwMainThread function in a separate thread then the game main thread, then it will call the SetupHook function that will change the opcode at the hookaddy to a jmp that will point to our codecave function address, now the hack itself let's see what it do, basicaly let's say the game had a function to add points, we replace the original call to the function with a jmp to our codecave inside our codecave we have a loop using eax that will call the function the number of time corresponding to our loop variable, as an option i could put a hotkey system in the dwMainThread to increase / decrease that variable. A far jump in ASM is 5 byte so after all the loop are done i make the codecave JMP back 5 byte after the call to our codecave so it continue to execute the normal code of the game.



[edited name=powerfear date=1273947022][/edited]

20
hmm

@Celestialkey

I don't see why you would need to send the packet size it's useless, normally how game work is that a couple of the first byte are a time stamp to prevent packet hacking after that there is a byte that tell the packet ID so server know how to read each part of the packet, usually you make a switch case or something simillar on that byte of the packet and analyse the rest in function of that.

The packet are received inside a buffer with a quite big size usually so there is no need to know the size of the packet.

Those information are based on a 3D MMORPG i was analysing with some other poeple to make an emulator.

21
General Talk / Re: Whats your personality type?
« on: April 15, 2010, 06:54:30 pm »
Your Type is:
ISTP

Introverted: 33%
Sensing: 1%
Thinking: 88%
Perceiving: 22%

You are:
* moderately expressed introvert
* slightly expressed sensing personality
* very expressed thinking personality
* slightly expressed perceiving personality

22
Humor / Re: Me vs Cybersex bot
« on: April 01, 2010, 04:45:53 pm »
Lol that's funny like 5 of those bot that work for webcam site added me recently wth is going o.o
my conversation looked the same also with the "i just got out of the shower" part and also the "i don't cam cause i have been recorded before but..."

23
C++ / Re: Help!! >.<
« on: March 20, 2010, 10:00:39 am »
Code: C++
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.         cout << "Hey now Brown Cow\nDon't jump that Fence";  
  6.         getchar();
  7.         return 0;
  8. }
  9.  

moved the namespace outside the function, and used \n just for shortness, endl work too.

I compiled that code it work fine, if it don't work reply with the error.

24
OS Developement / Re: Celestialkey's Ultimate OSDeveloper Batch Helper
« on: March 13, 2010, 11:58:12 am »
5 post in a row ! BAN BAN BAN

25
DirectX / D3D9 Tutorial 3: Loading an image from file and drawing it
« on: March 06, 2010, 10:28:01 am »
Loading an image from a file and drawing it

Code: C++
  1. #include <windows.h> //include windows header for some function like MessageBox, creating the window.
  2. #include "d3dx9.h" //include a directx header
  3. #include <stdio.h> //for the sprinf_s function used by DrawString
  4.  
  5. #pragma comment(lib, "d3dx9.lib") //link the library
  6. #pragma comment(lib, "d3d9.lib") //link the library
  7. #define Emsg(msg){MessageBox(NULL,msg,"Error",MB_OK|MB_ICONEXCLAMATION);} //macro for error pop-up
  8.  
  9. int WINDOW_WIDTH = 1024; //window width
  10. int WINDOW_HEIGHT = 768; //window height
  11. bool windowed = true; //window mode, change to false for full screen
  12.  
  13. IDirect3D9 *pD3D; //global variable that will be used by a couple of our function
  14. IDirect3DDevice9 *pDevice; //a device that will be used for msot of our function created inside *pD3D
  15. LPD3DXFONT pFont; //font variable to use with our create font function and to display text after
  16.  
  17. LPDIRECT3DTEXTURE9 imagetex; //textute our image will be loaded into
  18. LPD3DXSPRITE sprite; //sprite to display our image
  19. D3DXVECTOR3 imagepos; //vector for the position of the sprite
  20.  
  21. LRESULT CALLBACK wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) //callback function for our GetMessage function on the while statement inside the main function
  22. {
  23.         switch(uMsg) //switch the MSG variable passed
  24.         {
  25.         case WM_CLOSE: //case it's a Window Close MSG
  26.                 PostQuitMessage(0); //Apply a Quit Message
  27.                 break;
  28.         }
  29.         return DefWindowProc(hWnd,uMsg,wParam,lParam); //pass the variable
  30. }
  31.  
  32. HRESULT initialize()
  33. {
  34.         if(FAILED(D3DXCreateTextureFromFile(pDevice,"test.png",&imagetex)))//first parameter is our device,second is the path to our image, third is a texture variable to load the image into
  35.         {
  36.                 Emsg("Failed to laod the image"); //error pop-up for debug purpose
  37.                 return E_FAIL; //return it failed
  38.         }
  39.         if(FAILED(D3DXCreateSprite(pDevice,&sprite)))//first parameter is our device, second is a empty sprite variable
  40.         {
  41.                 Emsg("Failed to create the sprite"); //error pop-up for debug purpose
  42.                 return E_FAIL; //return it failed
  43.         }
  44.         imagepos.x=8.0f; //coord x of our sprite
  45.         imagepos.y=18.0f; //coord y of out sprite
  46.         imagepos.z=0.0f; //coord z of out sprite
  47.         return S_OK;
  48. }
  49.  
  50. HRESULT render() //function where all Drawing/Render stuff go
  51. {
  52.         if(SUCCEEDED(pDevice->BeginScene())) //Call the BeginScene function with our Device and see if it succeeded, all drawing/render code go behind BeginScene and EndScene
  53.         {
  54.                 sprite->Begin(D3DXSPRITE_ALPHABLEND); //begin our sprite with alphablend so it support alpha, like png use alpha
  55.                 sprite->Draw(imagetex,NULL,NULL,&imagepos,0xFFFFFFFF); //Draw the sprite, first parameter is the image texture, 4th parameter is the position, last parameter is the color change leave to 0xFFFFFFFF for no change
  56.                 sprite->End(); //end the sprite
  57.                 pDevice->EndScene(); //Call the EndScene function with our Device
  58.                 return S_OK; //return it succeeded
  59.         }
  60.         return E_FAIL; //return it failed
  61. }
  62.  
  63. void CleanUp() //function to delete/release things to prevent memory leak
  64. {
  65.         if(pD3D) //check if pD3D ism't released
  66.                 pD3D->Release(); //release it
  67.         if(pDevice) //check if pDevice ism't released
  68.                 pDevice->Release(); //release it
  69.         if(sprite) //check if sprite ism't released
  70.                 sprite->Release(); //release it
  71.         if(imagetex) //check if imagetex ism't released
  72.                 imagetex->Release(); //release it
  73. }
  74.  
  75. int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) //our main function the first function called of the program
  76. {
  77.         WNDCLASSEX wc; //window class won't go in detail not related to this tutorial really
  78.         wc.cbSize = sizeof(WNDCLASSEX);
  79.         wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  80.         wc.lpfnWndProc = (WNDPROC)wndProc;
  81.         wc.cbWndExtra = 0;
  82.         wc.cbClsExtra = 0;
  83.         wc.hInstance = hInstance;
  84.         wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
  85.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  86.         wc.hbrBackground = NULL;
  87.         wc.lpszMenuName = NULL;
  88.         wc.lpszClassName = "D3DTEST"; //class name
  89.         wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
  90.  
  91.         RECT rect; //window rectangle
  92.         rect.top = (long)0;
  93.         rect.left = (long)0;
  94.         rect.right = WINDOW_WIDTH; //use our global WINDOW_WIDTH variable
  95.         rect.bottom = WINDOW_HEIGHT; //use our global WINDOW_HEIGHT variable
  96.  
  97.         if(!RegisterClassEx(&wc)) //register the window cs
  98.         {
  99.                 Emsg("Could not register window class"); //error pop-up for debug purpose
  100.                 return 1; //return error
  101.         }
  102.  
  103.         AdjustWindowRectEx(&rect,WS_OVERLAPPEDWINDOW,false,WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); //set the window width and height with the rect above
  104.         //the D3DTEST must match the class name of the window class and D3D TEST is the window name
  105.         HWND hWindow = CreateWindowEx(NULL,"D3DTEST","D3D TEST",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,0,0,rect.right-rect.left,rect.bottom-rect.top,NULL,NULL,hInstance,NULL); //create the window
  106.  
  107.         if(!hWindow) //if the window failed to create
  108.         {
  109.                 DestroyWindow(hWindow); //destroy the window
  110.                 UnregisterClass("D3DTEST",hInstance); //unregister our window class
  111.                 Emsg("Failed to create the window"); //error pop-up for debug purpose
  112.                 return 1; //return error
  113.         }
  114.  
  115.         ShowWindow(hWindow,SW_SHOW); //show our window
  116.         UpdateWindow(hWindow); //update our window
  117.         SetForegroundWindow(hWindow); //set our window on top
  118.         SetFocus(hWindow); //set the focus on our window
  119.  
  120.         D3DPRESENT_PARAMETERS d3dpp; //the presentation parameters that will be used when we will create the device
  121.         ZeroMemory(&d3dpp,sizeof(d3dpp)); //to be sure d3dpp is empty
  122.         d3dpp.Windowed = windowed; //use our global windowed variable to tell if the program is windowed or not
  123.         d3dpp.hDeviceWindow = hWindow; //give the window handle of the window we created above
  124.         d3dpp.BackBufferCount = 1; //set it to only use 1 backbuffer
  125.         d3dpp.BackBufferWidth = WINDOW_WIDTH; //set the buffer to our window width
  126.         d3dpp.BackBufferHeight = WINDOW_HEIGHT; //set the buffer to out window height
  127.         d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //the backbuffer format
  128.         d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //SwapEffect
  129.  
  130.         pD3D = Direct3DCreate9(D3D_SDK_VERSION); //Create the presentation parameters
  131.  
  132.         if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWindow,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pDevice))) //create the device and check if it failed
  133.         {
  134.                 Emsg("Failed to create device"); //error pop-up for debug purpose
  135.                 CleanUp(); //call your CleanUp() function to prevent memory leak
  136.                 return 1; //exit the program return 1 error
  137.         }
  138.  
  139.         if(FAILED(initialize())) //call the initialize() function and check if it failed
  140.         {
  141.                 Emsg("Failed to initialize"); //error pop-up for debug purpose
  142.                 CleanUp(); //call your CleanUp() function to prevent memory leak
  143.                 return 1; //exit the program return 1 error
  144.         }
  145.  
  146.         MSG msg; //declare a MSG local variable for the GetMessage of the while loop
  147.         while(GetMessage(&msg,NULL,0,0)) //GetMessage reffer to the wndProc() function
  148.         {
  149.                 pDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0.0f); //Clear the screen with black, basically since we only draw text here it's like your background change the D3DCOLOR_XRGB(0,0,0) to change the color the 3 number additioned must make 255 maximum
  150.                 if(FAILED(render())) //call the function render() and verify if it worked
  151.                 {
  152.                         Emsg("Render failed"); //error pop-up for debug purpose
  153.                 }
  154.  
  155.                 pDevice->Present(NULL,NULL,NULL,NULL); //display your buffer on screen
  156.                 TranslateMessage(&msg); //translate the msg of the GetMessage of your while loop
  157.                 DispatchMessage(&msg); //dispath the msg of the GetMessage of your while loop
  158.         }
  159.         CleanUp(); //call your CleanUp() function to prevent memory leak
  160.         return 0; //return 0 no problem
  161. }
  162.  

note: if you test your program directly from your compiler you need to provide the full path to the image

26
DirectX / D3D9 Tutorial 2: Drawing a rectangle
« on: March 06, 2010, 10:01:54 am »
Drawing a rectangle

Code: C++
  1. #include <windows.h> //include windows header for some function like MessageBox, creating the window.
  2. #include "d3dx9.h" //include a directx header
  3.  
  4. #pragma comment(lib, "d3dx9.lib") //link the library
  5. #pragma comment(lib, "d3d9.lib") //link the library
  6. #define Emsg(msg){MessageBox(NULL,msg,"Error",MB_OK|MB_ICONEXCLAMATION);} //macro for error pop-up
  7.  
  8. int WINDOW_WIDTH = 1024; //window width
  9. int WINDOW_HEIGHT = 768; //window height
  10. bool windowed = true; //window mode, change to false for full screen
  11.  
  12. IDirect3D9 *pD3D; //global variable that will be used by a couple of our function
  13. IDirect3DDevice9 *pDevice; //a device that will be used for msot of our function created inside *pD3D
  14.  
  15. D3DRECT crec = {200, 200, 400, 600}; //position and dimensions of our rectangle
  16. LRESULT CALLBACK wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) //callback function for our GetMessage function on the while statement inside the main function
  17. {
  18.         switch(uMsg) //switch the MSG variable passed
  19.         {
  20.         case WM_CLOSE: //case it's a Window Close MSG
  21.                 PostQuitMessage(0); //Apply a Quit Message
  22.                 break;
  23.         }
  24.         return DefWindowProc(hWnd,uMsg,wParam,lParam); //pass the variable
  25. }
  26.  
  27. HRESULT render() //function where all Drawing/Render stuff go
  28. {
  29.         if(SUCCEEDED(pDevice->BeginScene())) //Call the BeginScene function with our Device and see if it succeeded, all drawing/render code go behind BeginScene and EndScene
  30.         {
  31.                 //Clear a part of the screen to make a red rectangle, crec give the coord and the dimensions, and D3DCOLOR_XRGB(255,0,0) give the color
  32.                 pDevice->Clear( 1, &crec, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,0,0), 0, 0 );
  33.                 pDevice->EndScene(); //Call the EndScene function with our Device
  34.                 return S_OK; //return it succeeded
  35.         }
  36.         return E_FAIL; //return it failed
  37. }
  38.  
  39. void CleanUp() //function to delete/release things to prevent memory leak
  40. {
  41.         if(pD3D) //check if pD3D ism't released
  42.                 pD3D->Release(); //release it
  43.         if(pDevice) //check if pDevice ism't released
  44.                 pDevice->Release(); //release it
  45. }
  46.  
  47. int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) //our main function the first function called of the program
  48. {
  49.         WNDCLASSEX wc; //window class won't go in detail not related to this tutorial really
  50.         wc.cbSize = sizeof(WNDCLASSEX);
  51.         wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  52.         wc.lpfnWndProc = (WNDPROC)wndProc;
  53.         wc.cbWndExtra = 0;
  54.         wc.cbClsExtra = 0;
  55.         wc.hInstance = hInstance;
  56.         wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
  57.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  58.         wc.hbrBackground = NULL;
  59.         wc.lpszMenuName = NULL;
  60.         wc.lpszClassName = "D3DTEST"; //class name
  61.         wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
  62.  
  63.         RECT rect; //window rectangle
  64.         rect.top = (long)0;
  65.         rect.left = (long)0;
  66.         rect.right = WINDOW_WIDTH; //use our global WINDOW_WIDTH variable
  67.         rect.bottom = WINDOW_HEIGHT; //use our global WINDOW_HEIGHT variable
  68.  
  69.         if(!RegisterClassEx(&wc)) //register the window cs
  70.         {
  71.                 Emsg("Could not register window class"); //error pop-up for debug purpose
  72.                 return 1; //return error
  73.         }
  74.  
  75.         AdjustWindowRectEx(&rect,WS_OVERLAPPEDWINDOW,false,WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); //set the window width and height with the rect above
  76.         //the D3DTEST must match the class name of the window class and D3D TEST is the window name
  77.         HWND hWindow = CreateWindowEx(NULL,"D3DTEST","D3D TEST",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,0,0,rect.right-rect.left,rect.bottom-rect.top,NULL,NULL,hInstance,NULL); //create the window
  78.  
  79.         if(!hWindow) //if the window failed to create
  80.         {
  81.                 DestroyWindow(hWindow); //destroy the window
  82.                 UnregisterClass("D3DTEST",hInstance); //unregister our window class
  83.                 Emsg("Failed to create the window"); //error pop-up for debug purpose
  84.                 return 1; //return error
  85.         }
  86.  
  87.         ShowWindow(hWindow,SW_SHOW); //show our window
  88.         UpdateWindow(hWindow); //update our window
  89.         SetForegroundWindow(hWindow); //set our window on top
  90.         SetFocus(hWindow); //set the focus on our window
  91.  
  92.         D3DPRESENT_PARAMETERS d3dpp; //the presentation parameters that will be used when we will create the device
  93.         ZeroMemory(&d3dpp,sizeof(d3dpp)); //to be sure d3dpp is empty
  94.         d3dpp.Windowed = windowed; //use our global windowed variable to tell if the program is windowed or not
  95.         d3dpp.hDeviceWindow = hWindow; //give the window handle of the window we created above
  96.         d3dpp.BackBufferCount = 1; //set it to only use 1 backbuffer
  97.         d3dpp.BackBufferWidth = WINDOW_WIDTH; //set the buffer to our window width
  98.         d3dpp.BackBufferHeight = WINDOW_HEIGHT; //set the buffer to out window height
  99.         d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //the backbuffer format
  100.         d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //SwapEffect
  101.  
  102.         pD3D = Direct3DCreate9(D3D_SDK_VERSION); //Create the presentation parameters
  103.  
  104.         if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWindow,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pDevice))) //create the device and check if it failed
  105.         {
  106.                 Emsg("Failed to create device"); //error pop-up for debug purpose
  107.                 CleanUp(); //call your CleanUp() function to prevent memory leak
  108.                 return 1; //exit the program return 1 error
  109.         }
  110.  
  111.         MSG msg; //declare a MSG local variable for the GetMessage of the while loop
  112.         while(GetMessage(&msg,NULL,0,0)) //GetMessage reffer to the wndProc() function
  113.         {
  114.                 pDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0.0f); //Clear the screen with black, basically since we only draw text here it's like your background change the D3DCOLOR_XRGB(0,0,0) to change the color the 3 number additioned must make 255 maximum
  115.                 if(FAILED(render())) //call the function render() and verify if it worked
  116.                 {
  117.                         Emsg("Render failed"); //error pop-up for debug purpose
  118.                 }
  119.  
  120.                 pDevice->Present(NULL,NULL,NULL,NULL); //display your buffer on screen
  121.                 TranslateMessage(&msg); //translate the msg of the GetMessage of your while loop
  122.                 DispatchMessage(&msg); //dispath the msg of the GetMessage of your while loop
  123.         }
  124.         CleanUp(); //call your CleanUp() function to prevent memory leak
  125.         return 0; //return 0 no problem
  126. }
  127.  

27
DirectX / D3D9 Tutorial 1: Hello world
« on: March 06, 2010, 09:41:15 am »
My first d3d9 tutorial, drawing Hello World


Code: C++
  1. #include <windows.h> //include windows header for some function like MessageBox, creating the window.
  2. #include "d3dx9.h" //include a directx header
  3. #include <stdio.h> //for the sprinf_s function used by DrawString
  4.  
  5. #pragma comment(lib, "d3dx9.lib") //link the library
  6. #pragma comment(lib, "d3d9.lib") //link the library
  7. #define Emsg(msg){MessageBox(NULL,msg,"Error",MB_OK|MB_ICONEXCLAMATION);} //macro for error pop-up
  8.  
  9. int WINDOW_WIDTH = 1024; //window width
  10. int WINDOW_HEIGHT = 768; //window height
  11. bool windowed = true; //window mode, change to false for full screen
  12.  
  13. IDirect3D9 *pD3D; //global variable that will be used by a couple of our function
  14. IDirect3DDevice9 *pDevice; //a device that will be used for most of our function created inside *pD3D
  15. LPD3DXFONT pFont; //font variable to use with our create font function and to display text after
  16.  
  17. int textx = 482; //text x coord
  18. int texty = 378; //text y coord
  19. LRESULT CALLBACK wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) //callback function for our GetMessage function on the while statement inside the main function
  20. {
  21.         switch(uMsg) //switch the MSG variable passed
  22.         {
  23.         case WM_CLOSE: //case it's a Window Close MSG
  24.                 PostQuitMessage(0); //Apply a Quit Message
  25.                 break;
  26.         }
  27.         return DefWindowProc(hWnd,uMsg,wParam,lParam); //pass the variable
  28. }
  29.  
  30. HRESULT initialize() //funciton where all the initialization stuff go
  31. {        //change the parameter (LPCSTR)"Arial" to any other font name in your font folder to test other font
  32.         if(FAILED(D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, (LPCSTR)"Arial", &pFont))) //create a font in our Device with the pFont variable
  33.         {
  34.                 Emsg("Failed to create the font"); //error pop-up for debug purpose
  35.                 return E_FAIL; //return it failed
  36.         }
  37. }
  38.  
  39. void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt) //function to draw text won't go in detail in this tutorial
  40. {
  41.         RECT FontPos = { x, y, x + 120, y + 16 };
  42.         char buf[1024] = {'\0'};
  43.         va_list va_alist;
  44.  
  45.         va_start(va_alist, fmt);
  46.         vsprintf_s(buf, fmt, va_alist);
  47.         va_end(va_alist);
  48.         g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
  49. }
  50.  
  51. HRESULT render() //function where all Drawing/Render stuff go
  52. {
  53.         if(SUCCEEDED(pDevice->BeginScene())) //Call the BeginScene function with our Device and see if it succeeded, all drawing/render code go behind BeginScene and EndScene
  54.         {       //first parameter is the x coord of the text we use our global variable textx, second parameter is samething but with y, last parameter is the text to draw in this case Hello World
  55.                 DrawString(textx, texty, D3DCOLOR_ARGB(255, 0, 255, 0), pFont, "Hello World"); //if it did draw Hello world on buffer, D3DCOLOR_ARGB(255, 0, 255, 0) is the color the first parametter is the alpha (transparent),rest is Red Blue Green the total of red blue green must be 255 maximum
  56.                 pDevice->EndScene(); //Call the EndScene function with our Device
  57.                 return S_OK; //return it succeeded
  58.         }
  59.         return E_FAIL; //return it failed
  60. }
  61.  
  62. void CleanUp() //function to delete/release things to prevent memory leak
  63. {
  64.         if(pD3D) //check if pD3D ism't released
  65.                 pD3D->Release(); //release it
  66.         if(pDevice) //check if pDevice ism't released
  67.                 pDevice->Release(); //release it
  68.         if(pFont) //check if pFont ism't released
  69.                 pFont->Release(); //release it
  70. }
  71.  
  72. int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) //our main function the first function called of the program
  73. {
  74.         WNDCLASSEX wc; //window class won't go in detail not related to this tutorial really
  75.         wc.cbSize = sizeof(WNDCLASSEX);
  76.         wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  77.         wc.lpfnWndProc = (WNDPROC)wndProc;
  78.         wc.cbWndExtra = 0;
  79.         wc.cbClsExtra = 0;
  80.         wc.hInstance = hInstance;
  81.         wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
  82.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  83.         wc.hbrBackground = NULL;
  84.         wc.lpszMenuName = NULL;
  85.         wc.lpszClassName = "D3DTEST"; //class name
  86.         wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
  87.  
  88.         RECT rect; //window rectangle
  89.         rect.top = (long)0;
  90.         rect.left = (long)0;
  91.         rect.right = WINDOW_WIDTH; //use our global WINDOW_WIDTH variable
  92.         rect.bottom = WINDOW_HEIGHT; //use our global WINDOW_HEIGHT variable
  93.  
  94.         if(!RegisterClassEx(&wc)) //register the window cs
  95.         {
  96.                 Emsg("Could not register window class"); //error pop-up for debug purpose
  97.                 return 1; //return error
  98.         }
  99.  
  100.         AdjustWindowRectEx(&rect,WS_OVERLAPPEDWINDOW,false,WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); //set the window width and height with the rect above
  101.         //the D3DTEST must match the class name of the window class and D3D TEST is the window name
  102.         HWND hWindow = CreateWindowEx(NULL,"D3DTEST","D3D TEST",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,0,0,rect.right-rect.left,rect.bottom-rect.top,NULL,NULL,hInstance,NULL); //create the window
  103.  
  104.         if(!hWindow) //if the window failed to create
  105.         {
  106.                 DestroyWindow(hWindow); //destroy the window
  107.                 UnregisterClass("D3DTEST",hInstance); //unregister our window class
  108.                 Emsg("Failed to create the window"); //error pop-up for debug purpose
  109.                 return 1; //return error
  110.         }
  111.  
  112.         ShowWindow(hWindow,SW_SHOW); //show our window
  113.         UpdateWindow(hWindow); //update our window
  114.         SetForegroundWindow(hWindow); //set our window on top
  115.         SetFocus(hWindow); //set the focus on our window
  116.  
  117.         D3DPRESENT_PARAMETERS d3dpp; //the presentation parameters that will be used when we will create the device
  118.         ZeroMemory(&d3dpp,sizeof(d3dpp)); //to be sure d3dpp is empty
  119.         d3dpp.Windowed = windowed; //use our global windowed variable to tell if the program is windowed or not
  120.         d3dpp.hDeviceWindow = hWindow; //give the window handle of the window we created above
  121.         d3dpp.BackBufferCount = 1; //set it to only use 1 backbuffer
  122.         d3dpp.BackBufferWidth = WINDOW_WIDTH; //set the buffer to our window width
  123.         d3dpp.BackBufferHeight = WINDOW_HEIGHT; //set the buffer to out window height
  124.         d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //the backbuffer format
  125.         d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //SwapEffect
  126.  
  127.         pD3D = Direct3DCreate9(D3D_SDK_VERSION); //Create the presentation parameters
  128.  
  129.         if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWindow,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pDevice))) //create the device and check if it failed
  130.         {
  131.                 Emsg("Failed to create device"); //error pop-up for debug purpose
  132.                 CleanUp(); //call your CleanUp() function to prevent memory leak
  133.                 return 1; //exit the program return 1 error
  134.         }
  135.  
  136.         if(FAILED(initialize())) //call the initialize function and check if it failed
  137.         {
  138.                 Emsg("Failed to initialize"); //error pop-up for debug purpose
  139.                 CleanUp(); //call your CleanUp() function to prevent memory leak
  140.                 return 1; //exit the program return 1 error
  141.         }
  142.  
  143.         MSG msg; //declare a MSG local variable for the GetMessage of the while loop
  144.         while(GetMessage(&msg,NULL,0,0)) //GetMessage reffer to the wndProc() function
  145.         {
  146.                 pDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0.0f); //Clear the screen with black, basically since we only draw text here it's like your background change the D3DCOLOR_XRGB(0,0,0) to change the color the 3 number additioned must make 255 maximum
  147.                 if(FAILED(render())) //call the function render() and verify if it worked
  148.                 {
  149.                         Emsg("Render failed"); //error pop-up for debug purpose
  150.                 }
  151.  
  152.                 pDevice->Present(NULL,NULL,NULL,NULL); //display your buffer on screen
  153.                 TranslateMessage(&msg); //translate the msg of the GetMessage of your while loop
  154.                 DispatchMessage(&msg); //dispath the msg of the GetMessage of your while loop
  155.         }
  156.         CleanUp(); //call your CleanUp() function to prevent memory leak
  157.         return 0; //return 0 no problem
  158. }
  159.  

28
Suggestions / Re: Changing the Chat back -- Celestial Chat
« on: March 01, 2010, 02:34:50 pm »
I honestly think flashchat would be the best of both worlds.

"the best of both worlds"
ah hannah montana reference!

29
General Talk / Re: Who needs a Google hacking database...
« on: January 30, 2010, 10:42:59 am »
ya there is lots of thing like that to search some years ago i had hacked into a street camera and was watching poeple

30
C++ / Re: [1] C++ First Program
« on: January 29, 2010, 09:42:09 pm »
Wow, what a deep voice  :o

Pages: [1] 2

Donate


* Search


* Recent Posts

Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]


Re: Client-Server Messaging by Nathan
[October 25, 2015, 05:48:57 pm]