• What do you need help with? Version 1
    5,001 replies, posted
If you meant to ask if it is detectable whether a location is unreachable via A*, then yes. What your implementation does upon encountering that is up to you.
I don't have a clue whether this is correct behavior - screwing around with clang-c++ on Windows and catch clauses are only detecting thrown exceptions of derived classes when using public inheritance.
[QUOTE=HubmaN;27582200]catch clauses are only detecting thrown exceptions of derived classes when using public inheritance.[/QUOTE] I would imagine that would be correct? [editline]22nd January 2011[/editline] and fairly obvious too
So, i have the next piece of code written in Direct3D/C++. I have an exercise to make the window's background to fade from blue to black. I've been struggling to do it but i can't figure out how to do it. I'm kind of a newbie to Direct3D and i'm no expert at C++ either so i thought you guys might help me out a little bit. [cpp] // include the basic windows header files and the Direct3D header files #include <windows.h> #include <windowsx.h> #include <d3d10.h> #include <d3dx10.h> // include the Direct3D Library file #pragma comment (lib, "d3d10.lib") #pragma comment (lib, "d3dx10.lib") // global declarations ID3D10Device* device; // the pointer to our Direct3D device interface ID3D10RenderTargetView* rtv; // the pointer to the render target view IDXGISwapChain* swapchain; // the pointer to the swap chain class // function prototypes void initD3D(HWND hWnd); // sets up and initializes Direct3D void render_frame(void); // renders a single frame void cleanD3D(void); // closes Direct3D and releases memory // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); // the entry point for any Windows program int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; WNDCLASSEX wc; ZeroMemory(&wc, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = L"WindowClass"; RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, L"WindowClass", L"Our First Direct3D Program", WS_OVERLAPPEDWINDOW, 300, 300, 800, 600, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, nCmdShow); // set up and initialize Direct3D initD3D(hWnd); // enter the main loop: MSG msg; while(TRUE) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if(msg.message == WM_QUIT) break; } render_frame(); } // clean up DirectX and COM cleanD3D(); return msg.wParam; } // this is the main message handler for the program LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: { PostQuitMessage(0); return 0; } break; } return DefWindowProc (hWnd, message, wParam, lParam); } // this function initializes and prepares Direct3D for use void initD3D(HWND hWnd) { DXGI_SWAP_CHAIN_DESC scd; // create a struct to hold various swap chain information ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); // clear out the struct for use scd.BufferCount = 1; // create two buffers, one for the front, one for the back scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // tell how the chain is to be used scd.OutputWindow = hWnd; // set the window to be used by Direct3D scd.SampleDesc.Count = 1; // set the level of multi-sampling scd.SampleDesc.Quality = 0; // set the quality of multi-sampling scd.Windowed = TRUE; // set to windowed or full-screen mode // create a device class and swap chain class using the information in the scd struct D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &scd, &swapchain, &device); // get the address of the back buffer and use it to create the render target ID3D10Texture2D* pBackBuffer; swapchain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer); device->CreateRenderTargetView(pBackBuffer, NULL, &rtv); pBackBuffer->Release(); // set the back buffer as the render target device->OMSetRenderTargets(1, &rtv, NULL); D3D10_VIEWPORT viewport; // create a struct to hold the viewport data ZeroMemory(&viewport, sizeof(D3D10_VIEWPORT)); // clear out the struct for use viewport.TopLeftX = 0; // set the left to 0 viewport.TopLeftY = 0; // set the top to 0 viewport.Width = 800; // set the width to the window's width viewport.Height = 600; // set the height to the window's height device->RSSetViewports(1, &viewport); // set the viewport } // this is the function used to render a single frame void render_frame(void) { // clear the window to a deep blue device->ClearRenderTargetView(rtv, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f)); // do 3D rendering on the back buffer here // display the rendered frame swapchain->Present(0, 0); } // this is the function that cleans up Direct3D and COM void cleanD3D(void) { swapchain->Release(); // close and release the swap chain rtv->Release(); // close and release the render target view device->Release(); // close and release the 3D device } [/cpp]
[QUOTE=Venice Queen;27582348]I would imagine that would be correct? [editline]22nd January 2011[/editline] and fairly obvious too[/QUOTE] You're right - it was, given one knows what the difference is. The behavior isn't the most intuitive.
[QUOTE=Dj-J3;27574845]I want to remove the border from Bad Company 2 so that i can play fullscreen in window mode. AFAIK MainWindowHandle is the hwnd.[/QUOTE] I'm pretty sure PB will kick you if you do that.
Just reinstalled linux and when i try to build programs in codeblocks i get [quote] -------------- Clean: Debug in Perlin Noise --------------- Cleaned "Perlin Noise - Debug" -------------- Build: Debug in Perlin Noise --------------- Compiling: main.cpp /bin/sh: g++: not found Process terminated with status 127 (0 minutes, 0 seconds) 0 errors, 0 warnings [/quote] Even tho i know GCC is installed
GCC isn't the same thing as G++, you need to install that separately.
[QUOTE=PiXeN;27583458]I'm pretty sure PB will kick you if you do that.[/QUOTE] Forgot to say that i solved it. And PB does not kick me (playing on ranked servers). It also works for other games, i've tried it on Amnesia, Minecraft, and even the application itself. :v:
Hnng. anyone know what this is abot? [img]http://img220.imageshack.us/img220/8114/41180750.png[/img]
sudo?
All of my projects are set to multi-byte, VC++ is adding a A to the end of one of my functions Entity.h [cpp]#pragma once #include "..\..\Types.h" #include "..\..\..\Shared\Types\Vectors.h" namespace Mavgine { class EntityManager; class COREEXPORT Entity { public: Entity(const bool bPhysics, const bool bNetworked); ~Entity(); virtual void Tick(); virtual bool HasPhysics(); virtual bool IsNetworked(); virtual Vector3f GetPos(); virtual void SetPos(Vector3f v3fNewPos); virtual EntityID GetID(); virtual bool Is3D(); virtual String GetModel(); virtual void SetModel(String strNewModel); virtual String GetName(); virtual void SetName(String strNewName); virtual String GetClassName(); friend class EntityManager; private: bool m_bPhysics; bool m_bNetworked; bool m_bIs3D; Vector3f m_v3fPos; EntityID m_MyID; String m_strModel; String m_strName; }; }[/cpp] test.cpp [cpp]// test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include "..\Shared\Core\Engine\Engine.h" #include "..\Shared\Types\Vectors.h" #include "..\Shared\Core\Entity\Entity.h" #pragma comment(lib, "C:\\Mavgine\\Debug\\Static Shared Lib.lib") #pragma comment(lib, "C:\\Mavgine\\Debug\\Core.lib") using namespace std; class NewEntity : public Mavgine::Entity { public: NewEntity(const bool bPhysics, const bool bNetworked) : Mavgine::Entity(bPhysics, bNetworked) { } ~NewEntity() { } }; int _tmain(int argc, _TCHAR* argv[]) { Mavgine::Vector3f vec1; Mavgine::Vector3f vec2(2, 3, 4); Mavgine::Vector3f vec3(5, 6, 7); vec1 = vec2 * 4; HMODULE hCore = LoadLibrary("core.dll"); Mavgine::EngineParams *pEngineParams = new Mavgine::EngineParams; pEngineParams->uTickRate = 33; Mavgine::CreateClassFn pCreateClass = (Mavgine::CreateClassFn)GetProcAddress(hCore, "CreateClass"); Mavgine::Engine *pEngine = (Mavgine::Engine*)pCreateClass(MavgineEngineVersion, pEngineParams); NewEntity newent(false, false); float debug = pEngine->GetRealTime(); while(true) { if(pEngine->ShouldTick()) { pEngine->ForceTick(); float fETime = pEngine->GetEngineTime(); float fRTime = pEngine->GetRealTime(); float fDiff = fRTime - fETime; cout << "Tick Engine Time: " << fETime << "s RealTime: " << fRTime << "s LAG: "; printf("%f", fDiff); cout << "s" << endl; } } system("pause"); return 0; }[/cpp] Error: [code]test.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Mavgine::Entity::GetClassNameA(void)" (?GetClassNameA@Entity@Mavgine@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>C:\Mavgine\Debug\test.exe : fatal error LNK1120: 1 unresolved externals[/code] [editline]22nd January 2011[/editline] It works if the name of that func is anything other than GetClassName, even GetClassname works, so I'll just use that. Still odd though [editline]22nd January 2011[/editline] FUCKING WINDOWS.H WAS FUCKING DOING IT FUCK YOU WINDOWS.FUCKINGH
[QUOTE=Richy19;27589434]Hnng. anyone know what this is abot? [img_thumb]http://img220.imageshack.us/img220/8114/41180750.png[/img_thumb][/QUOTE] Fixed this, seems to be that it didnt like the fact that i was using the old windows codeblocks projet file. So i created a new project and included the old files and it works fine now
More problems For some reason the sfml strings are fucking up for example in the title, out of "Mavgine" only ine is being shown RenderSystem.cpp [cpp]#include "..\..\Shared\Render\RenderSystem\RenderSystem.h" #include "..\..\Shared\Core\Entity\EntityManager.h" #include "..\..\Shared\Types.h" #include <SFML\System.hpp> #include <SFML\Graphics.hpp> #include <map> sf::RenderWindow *pRenderWin = NULL; std::map<Mavgine::String, sf::Image*> mapImgList; std::map<Mavgine::EntityID, sf::Sprite*> mapSpriteList; Mavgine::RenderSystem::RenderSystem(Mavgine::RenderSystemParams *pRenderParams) { static std::string test = "Mavgine"; pRenderWin = new sf::RenderWindow(sf::VideoMode(pRenderParams->w, pRenderParams->h), test); } Mavgine::RenderSystem::~RenderSystem() { } void Mavgine::RenderSystem::ReDraw(EntityID eID) { } void Mavgine::RenderSystem::Update() { Mavgine::EntityManager *entMgr = (Mavgine::EntityManager*)CreateClass(ENTITYMGRVER, NULL); pRenderWin->Clear(); for(EntityID i = 0; i<MAXENTITIES; i++) { Mavgine::Entity *ent = entMgr->GetEntity(i); if(!ent) { if(mapSpriteList[i]) { delete mapSpriteList[i]; mapSpriteList[i] = NULL; } } else { if(ent->Is3D()) { continue; } if(!mapSpriteList[i]) { mapSpriteList[i] = new sf::Sprite(); sf::Image *img = mapImgList[ent->GetModel()]; if(!img) { mapImgList[ent->GetModel()] = new sf::Image(); Mavgine::String strFileName = ent->GetModel(); mapImgList[ent->GetModel()]->LoadFromFile("lol.png"); } img = mapImgList[ent->GetModel()]; mapSpriteList[i]->SetImage(*img); } Mavgine::Vector3f v3fPos = ent->GetPos(); Mavgine::Vector3f v3fScale = ent->GetScale(); mapSpriteList[i]->SetPosition(v3fPos.x(), v3fPos.y()); mapSpriteList[i]->Scale(v3fScale.x(), v3fScale.y()); pRenderWin->Draw(*mapSpriteList[i]); } } pRenderWin->Display(); } static Mavgine::RenderSystem *gRenderSystem = NULL; extern "C" { RENDEREXPORT void* CreateRenderClass(char* version, void* other) { std::string str1 = version; if(str1==RENDERSYSTEMVER) { if(!gRenderSystem) { gRenderSystem = new Mavgine::RenderSystem((Mavgine::RenderSystemParams*)other); return gRenderSystem; } return gRenderSystem; } return NULL; } }[/cpp] [b]Edited:[/b] Nvm, fixed it, again.
[QUOTE=Richy19;27591868]Fixed this, seems to be that it didnt like the fact that i was using the old windows codeblocks projet file. So i created a new project and included the old files and it works fine now[/QUOTE] probably just had to chown it or something
I don't know if this is the right place to ask but, I want to learn a programming language but I don't know which one? Can anybody give some suggestions?
[QUOTE=Exosel;27595506]I don't know if this is the right place to ask but, I want to learn a programming language but I don't know which one? Can anybody give some suggestions?[/QUOTE] The main things people use are probably .NET languages (C# and java), C++, and python/lua Personally i use C++ because it tries to hide less about what you're screwing around wtih
[QUOTE=Exosel;27595506]I don't know if this is the right place to ask but, I want to learn a programming language but I don't know which one? Can anybody give some suggestions?[/QUOTE] Ask a million people and you'll hear every programming language mentioned multiple times. I recommend C++ because it forces you to know what's going on under the hood, and once you know C++, it makes learning [i]any[/i] other programming language far easier.
[QUOTE=yakahughes;27595712]Ask a million people and you'll hear every programming language mentioned multiple times. I recommend C++ because it forces you to know what's going on under the hood, and once you know C++, it makes learning [i]any[/i] other programming language far easier.[/QUOTE] [QUOTE=Icedshot;27595594]The main things people use are probably .NET languages (C# and java), C++, and python/lua Personally i use C++ because it tries to hide less about what you're screwing around wtih[/QUOTE] Thanks for the help guys.
I'm having trouble importing resources in java. Right now, I'm able to get the location of the files I'm looking for by doing this: [lua]Toolkit.getDefaultToolkit().getClass().getResource("/relative/path/to/file.xyz").toString().replaceAll("%20"," ").substring(6)[/lua] Look at it, it's horrible. What's the best way to import a resource which will work both in the IDE and when I run the program as a jar? (The class I'm using to get an image requires that I use a FileInputStream)
I'm trying to learn C++, and even though I understand all of the concepts I really need hands-on practice. I would really like to have exercises like you would find in a programming textbook so that I can practice writing code. Anyone know of a website that has those sorts of exercises?
[QUOTE=Larikang;27612747]I'm trying to learn C++, and even though I understand all of the concepts I really need hands-on practice. I would really like to have exercises like you would find in a programming textbook so that I can practice writing code. Anyone know of a website that has those sorts of exercises?[/QUOTE] [url]http://projecteuler.net/[/url] is great.
OpenGL is giving me a headache. How do GLunits translate to pixels? Imagine if I wanted an quad to be drawn at 400x/200y, how do I calculate that in glunits? :saddowns:
[QUOTE=Anthophobian;27613557]OpenGL is giving me a headache. How do GLunits translate to pixels? Imagine if I wanted an quad to be drawn at 400x/200y, how do I calculate that in glunits? :saddowns:[/QUOTE] That's entirely dependant on how you've set up your projection.
[QUOTE=WTF Nuke;27612796][url]http://projecteuler.net/[/url] is great.[/QUOTE] Not for what I need. Project Euler does not require any use of object oriented programming, creating interactive programs, or advanced pointer use (to name a few examples). I'm really looking for exercises specifically geared towards learning: programs that require broad knowledge of the specific language as opposed to problems that require knowledge of fast, clever algorithms (e.g. Project Euler).
I have a Hashtable (C#) with instances of a class, but I'm having trouble iterating through it. I've tried everything I could find on MSDN. Using a DictionaryEntry make the value an object or something, and using a KeyValuePair with the correct type arguments gives a "Specified cast is not valid" exception.
[QUOTE=ZenX2;27619668]I have a Hashtable (C#) with instances of a class, but I'm having trouble iterating through it. I've tried everything I could find on MSDN. Using a DictionaryEntry make the value an object or something, and using a KeyValuePair with the correct type arguments gives a "Specified cast is not valid" exception.[/QUOTE] Use Dictionary<TK,TV> in System.Collections.Generic
[QUOTE=John.Lua;27618640]So I've decided to write a copy of GWEN (Similar in some aspects). So I've got my self Windower.dll, Contexter.dll and Gui.dll. In Gui.dll I am drawing the GUI. But I've hit a little problem with perspective rendering in OpenGL. The GUI does draw the rectangle but, it seems my projection matrix is off; the rectangle is draw half the size (320 x 240). I thought the Z component was messing it up but it doesn't seem to be the cause. TL; DR: In OpenGL my rectangle is half the size, I'm using perspective (glFrustrum). I bet I'm missing something simple.[/QUOTE] I tried setting W to 1.0f, no avail. [cpp] Window::Message Msg; Msg.IsRunning = true; while(Msg.IsRunning) { Msg = g_pEditorWindow->GetNextMessage(); switch(Msg.MsgType) { case Window::MSG_TYPE_RESIZED: { if(Msg.Height == 0) { // Divide by 0 Msg.Height = 1; } UpdateContext(Msg.Width, Msg.Height); } break; } glClearColor(112.0f/255.0f, 112.0f/255.0f, 112.0f/255.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Render gui (test) g_pEditorRenderer->Begin(); g_pEditorRenderer->SetDrawColor(Gui::Color(179, 179, 179)); g_pEditorRenderer->DrawFilledRect(Gui::Rect(640 - 120, 0, 120, 480)); g_pEditorRenderer->End(); glFlush(); g_pEditorContext->Swap(); } [/cpp] [editline]23rd January 2011[/editline] [img]http://anyhub.net/file/1zLz-guierror.png[/img]
Does anybody know or can recommend some really good books for learning C++?
[QUOTE=John.Lua;27620907]I tried setting W to 1.0f, no avail. [cpp] Window::Message Msg; Msg.IsRunning = true; while(Msg.IsRunning) { Msg = g_pEditorWindow->GetNextMessage(); switch(Msg.MsgType) { case Window::MSG_TYPE_RESIZED: { if(Msg.Height == 0) { // Divide by 0 Msg.Height = 1; } UpdateContext(Msg.Width, Msg.Height); } break; } glClearColor(112.0f/255.0f, 112.0f/255.0f, 112.0f/255.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Render gui (test) g_pEditorRenderer->Begin(); g_pEditorRenderer->SetDrawColor(Gui::Color(179, 179, 179)); g_pEditorRenderer->DrawFilledRect(Gui::Rect(640 - 120, 0, 120, 480)); g_pEditorRenderer->End(); glFlush(); g_pEditorContext->Swap(); } [/cpp] [editline]23rd January 2011[/editline] [img_thumb]http://anyhub.net/file/1zLz-guierror.png[/img_thumb][/QUOTE] Are you sure the coordinates aren't from 0,0 in the middle to 1,1 in top right? I haven't read the whole discussion but that might be the problem.
Sorry, you need to Log In to post a reply to this thread.