# cambalinho

Member

140

234 Neutral

• Rank
Member

• Interests
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## how setup directx 11 on Code Blocks 17.12?

how setup directx 11 on Code Blocks 17.12? i add the "lib\x86" directory on Global Options-Search Directories-Linker and "include" directory on Global Options-Search Directories-Compiler. but now i get several errors(and warnings) like: " '__in' has not been declared" on "dxgi.h". how can i fix these problems? did i miss something on configurations? i must do another setup?
2. ## Directx 11 with C++: how can i draw a circule?

thank you so much for correct me. i'm sorry, i didn't knew
3. ## Directx 11 with C++: how can i draw a circule?

what i have learned today thank you so much for all... thank you
4. ## Directx 11 with C++: how can i draw a circule?

i understand how add an angle, but not starting and ending angles
5. ## Directx 11 with C++: how can i draw a circule?

thank you so much for all thank you correct me 1 thing: if i use 270 instead 360, we make a open circule or even a curve, right?
6. ## Directx 11 with C++: how can i draw a circule?

- tesselation is how many points we use for draw the circle and that it's the draw quality, right? - i'm sorry, but can you explain better how these math works? float angle = float(i) / float(tesselation) // this goes from 0 to almost 1 * M_PI*2; i'm confused on how you get the angle
7. ## Directx 11 with C++: how can i draw a circule?

theres 2 things: 1 - what value use used on M_PI? 2 - i'm confused: what is tesselation?
8. ## Directx 11 with C++: how can i draw a circule?

vector<Vertex> CirclePoints(float radius) { vector<Vertex> AllPoints; AllPoints.resize(362+361*3); AllPoints[0]= Vertex(0, 0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f); AllPoints[1] = Vertex(radius, 0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f); for (float i = 2.0f; i < AllPoints.size(); i=i+0.125f) { AllPoints[(int)i] = Vertex(radius *cos(i), radius *sin(i), 0.0f, 1.0f, 0.0f, 0.0f, 0.0f); } return AllPoints; } finally i get results: now you see why these line: vector<Vertex> AllPoints; AllPoints.resize(362+361*3); but i need more advice, please: how can i make more precision?
9. ## Directx 11 with C++: how can i draw a circule?

for now i only get 2 dots the center and 1 on right i'm sorry but let me ask in a different way(math way): 1 - we have the point A(20,30); 2 - we must rotate the point A by 30º degrees; 3 - how we calculate the point B?
10. ## Directx 11 with C++: how can i draw a circule?

i'm sorry, but i need more help. the zero is the center of window. i have 2 starting dots: 1 - on center (0,0); 2 - on (7,0). now the rest is using the angle=angle-1. and more: i must use radians instead degrees
11. ## DX11 Directx 11 with C++: how can i draw a circule?

i'm trying draw a circule using math: class coordenates { public: coordenates(float x=0, float y=0) { X = x; Y = y; } float X; float Y; }; coordenates RotationPoints(coordenates ActualPosition, double angle) { coordenates NewPosition; NewPosition.X = ActualPosition.X*sin(angle) - ActualPosition.Y*sin(angle); NewPosition.Y = ActualPosition.Y*cos(angle) + ActualPosition.X*cos(angle); return NewPosition; } but now i know that these have 1 problem, because i don't use the orign. even so i'm getting problems on how i can rotate the point. these coordinates works between -1 and 1 floating points. can anyone advice more for i create the circule?
12. ## Directx 11 with C++: how the indices works?

i'm trying understand how works the Indices. if the Primtive is D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST then 6 Vertex are 2 triangles(and i did that before). the Indices avoid 6 Vertex for 2 triangles... these is what i know. but i don't understand these line: DWORD indices[] = { 0, 1, 2, 0, 2, 3, }; the numbers are the Vertex array\vector elements? can anyone explain more about it?
13. ## C++: my 1st DirectX 11: why the memory used is increasing?

now i have the answer. my graphics card is for DirectX10... that's why i can inicializate the DirectX 11(it's an update of 10). thank you so much for all
14. ## C++: my 1st DirectX 11: why the memory used is increasing?

i'm doing my 1st DirectX 11 program: //Cambalinho.h: #include <Windows.h> #include <string> #include <functional> #include <d3d11.h> #include <d3dx11.h> #include <d3dx10.h> #include <DxErr.h> #pragma comment (lib, "d3d11.lib") #pragma comment (lib, "d3dx11.lib") #pragma comment (lib, "d3dx10.lib") #pragma comment (lib, "DxErr.lib") using namespace std; class DirectX { private: HRESULT DirectXResult=0; public: function<void()> Render; IDXGISwapChain * DXSwap; ID3D11Device *Device; ID3D11DeviceContext *DeviceContext; DXGI_SWAP_CHAIN_DESC DXSwapdesc; ID3D11RenderTargetView *backbuffer; ID3D11Texture2D *pBackBuffer; D3D11_VIEWPORT ViewPort; DirectX(HWND window) { RECT WindowRect = { 0 }; GetClientRect(window, &WindowRect); //inicializate Directx: ZeroMemory(&DXSwapdesc, sizeof(DXGI_SWAP_CHAIN_DESC)); DXSwapdesc.BufferCount = 1; DXSwapdesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; DXSwapdesc.BufferDesc.Width = WindowRect.right - WindowRect.left; DXSwapdesc.BufferDesc.Height = WindowRect.bottom - WindowRect.top; DXSwapdesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; DXSwapdesc.OutputWindow = window; DXSwapdesc.SampleDesc.Count = 1; DXSwapdesc.SampleDesc.Quality = 0; DXSwapdesc.Windowed = true; D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &DXSwapdesc, &DXSwap, &Device, NULL, &DeviceContext); //Prepare the View Port: DXSwap->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); DirectXResult=Device->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer); if (backbuffer == NULL|| DirectXResult!=S_OK) MessageBox(NULL, "error", "error", MB_OK); DeviceContext->OMSetRenderTargets(1, &backbuffer, NULL); //Create the View Port: ZeroMemory(&ViewPort, sizeof(D3D11_VIEWPORT)); ViewPort.TopLeftX = 0; ViewPort.TopLeftY = 0; ViewPort.Width = static_cast<float>( WindowRect.right- WindowRect.left); ViewPort.Height = static_cast< float>(WindowRect.bottom- WindowRect.top); ViewPort.MinDepth = 0.0f; ViewPort.MaxDepth = 1.0f; ViewPort.TopLeftX = 0.0f; ViewPort.TopLeftY = 0.0f; DeviceContext->RSSetViewports(1, &ViewPort); } void Clear(float color[4]) { DeviceContext->ClearRenderTargetView(backbuffer, color); } void Update() { DXSwap->Present(0, 0); } ~DirectX() { //DirectX Clean Up: pBackBuffer->Release(); if(DXSwap) DXSwap->Release(); if(backbuffer) backbuffer->Release(); if(Device) Device->Release(); if(DeviceContext) DeviceContext->Release(); } }; class Form { private: HWND MainWindow = NULL; static HRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM WParam, LPARAM LParam) { Form *inst =(Form*) GetWindowLongPtr(window, GWLP_USERDATA); switch (message) { case WM_CREATE: { LPCREATESTRUCT lpCreate = (LPCREATESTRUCT)LParam; inst =(Form*) lpCreate->lpCreateParams; SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)inst); } break; case WM_CLOSE: { DestroyWindow(window); } break; case WM_DESTROY: { PostQuitMessage(0); } break; default: return DefWindowProc(window, message, WParam, LParam); } return 0; } public: Form(string Title = "hello World", int PosX = CW_USEDEFAULT, int PosY=CW_USEDEFAULT, int Width=CW_USEDEFAULT, int Height=CW_USEDEFAULT) { string strWindowClassName = "WindowClassname"; WNDCLASSEX wndClassName; ZeroMemory(&wndClassName, sizeof(WNDCLASSEX)); wndClassName.cbSize = sizeof(WNDCLASSEX); wndClassName.cbClsExtra = 0; wndClassName.cbWndExtra = 0; wndClassName.hbrBackground = (HBRUSH)(COLOR_WINDOW); wndClassName.hCursor = LoadCursor(NULL, IDC_ARROW); wndClassName.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClassName.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wndClassName.hInstance = GetModuleHandle(NULL); wndClassName.lpfnWndProc = (WNDPROC)WndProc; wndClassName.lpszClassName = strWindowClassName.c_str(); wndClassName.lpszMenuName = 0; wndClassName.style = CS_HREDRAW | CS_VREDRAW; if (!RegisterClassEx(&wndClassName)) MessageBox(NULL, "Not Registed", "error", MB_OK); RECT windrect = { 0,0,Width,Height }; AdjustWindowRect(&windrect, WS_OVERLAPPEDWINDOW, FALSE); MainWindow = CreateWindowEx(WS_EX_CLIENTEDGE, strWindowClassName.c_str(), Title.c_str(), WS_OVERLAPPEDWINDOW, PosX, PosY, windrect.right- windrect.left, windrect.bottom- windrect.top, NULL, NULL, GetModuleHandle(NULL),reinterpret_cast<LPVOID> (this)); if(MainWindow==NULL) MessageBox(NULL, "Not created", "error", MB_OK); ShowWindow(MainWindow, SW_SHOWNORMAL); //UpdateWindow(MainWindow); } ~Form() { ; } operator HWND() { return MainWindow; } static std::function<void()>DirectXRender; static WPARAM MessageLoop() { MSG msgMessage; ZeroMemory(&msgMessage, sizeof(MSG)); while (msgMessage.message != WM_QUIT) { if (PeekMessage(&msgMessage, NULL, NULL, NULL, PM_REMOVE)) { TranslateMessage(&msgMessage); DispatchMessage(&msgMessage); } if (DirectXRender) DirectXRender(); } return static_cast<int>(msgMessage.wParam); } }; function<void()>Form::DirectXRender = nullptr; //maic.cpp: #include "cambalinho.h" Form frmMain("hello World!!!",CW_USEDEFAULT,CW_USEDEFAULT,800,500); DirectX DirecX(frmMain); int WINAPI WinMain(HINSTANCE ActualInstance, HINSTANCE NullInstance, LPSTR CommandLine, int WindowShow) { DirecX.Render=[] { float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f }; DirecX.Clear(clearColor); DirecX.Update(); }; //Message Loop: MSG msgMessage; ZeroMemory(&msgMessage, sizeof(MSG)); while (msgMessage.message != WM_QUIT) { if (PeekMessage(&msgMessage, NULL, NULL, NULL, PM_REMOVE)) { TranslateMessage(&msgMessage); DispatchMessage(&msgMessage); } DirecX.Render(); } return static_cast<int>(msgMessage.wParam); } i'm very new with Game Loop programming. i'm reading several tutorials for see the problem and they are more or less the same. but why the memory used is increasing?(i see that on Task Manager)
15. ## i need learn more about the Game Loop

yah... more big the chapter more big the boring lol honestly a big chapter can be much more tired and much more information\study to 'eat'