Hello sir,
How to make circle in c++ i am using Dev C++
Hello sir,
How to make circle in c++ i am using Dev C++
What exactly do you want to do ?
Create a class Circle that describes a circle
or
Draw some circles on the screen.
HI SIR,
how to make simple circle in c++ only
One option:
Code:class Circle { Circle(int x, int y, int radius): mCenterX(x), mCenterY(y), mRadius(radius) {} int GetCenterX() const {return mCenterX;} int GetCenterY() const { return mCenterY;} int GetRadius() const {return mRadius;} private: int mCenterX, mCenterY, mRadius; };
And if you wanted to draw the circle you could do something like this:
Code:// It returns an array of vertices to be used with GL_LINE_STRIP or equivalent const std::vector<glm::vec2> genMesh(int segments) { float step = 6.283185f/segments; float angle = 0.0f; std::vector<glm::vec2> vertices; vertices.reserve(segments + 1); for (int i = 0; i < segments; ++i, angle+=step) { float vertX = mCenterX + cosf(angle)*mRadius; float vertY = mCenterY + sinf(angle)*mRadius; vertices.push_back(glm::vec2(vertX, vertY)); } vertices.push_back(glm::vec2(mCenterX+mRadius, mCenterY)); return vertices; }
Last edited by GReaper; 10-28-2017 at 07:50 AM.
Devoted my life to programming...
It would be a huge undertaking to try to explain and/or program an entire OpenGL or DirectX program here, look them up if you're interested. That or experiment with a simple 2D library such as Allegro.
Devoted my life to programming...
For windows users:
Normally you would create a full Windows application, but for simple demos the console is sufficient.Code:#include <Windows.h> #include <iostream> int LastWinError() { DWORD err = ERROR_SUCCESS; err = GetLastError(); std::cerr << "\aWindows error: " << err << "\n\n"; return static_cast<int>(err); } int main() { HWND hConsole = GetConsoleWindow(); if (hConsole ==nullptr) { return LastWinError(); } HDC hDC = GetDC(hConsole); if (hDC == nullptr) { return LastWinError(); } Ellipse(hDC, 10, 10, 100, 100); Sleep(5000); // wait 5 seconds to admire the circle ReleaseDC(hConsole, hDC); }
You need to compile it with C++11 or replace nullptr with NULL or 0
hello sir,
now it showing error
how compile it with C++11
yes, now you have to make everything conform with that standard.
( I cannot make out whatever is in the photo)
essentially if you get an error, update that bit of code to conform to the c++11 standard, google is a good helper.
Just type in the error into the search, and refine it if needed to see if someone else had same problem.
So you can get the solution. or post everything in here and wait.
You need to include Gdi32.lib
This guy has absolutely no idea what he's doing and hasn't explained why or shown anything that he's tried. I don't even think he knows what he's doing.
How to ask smart questions
Code:DWORD dwBytesOverwritten; BYTE rgucOverWrite[] = {0xe9,0,0,0,0}; WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);