You know, the reason OGL 3 was such a shitty release is because the CAD people (iirc) didn't wanna change shit.
The deprecating-system is a good thing towards a forward compatible OGL future.
[editline]25th December 2010[/editline]
If you don't want a forward-compatible context, create none and use deprecated functionality; this is what a non-forward-compatible context is for.
Still haven't answered my question.
More C++ trouble in here. I have 2 questions.
[list][*]I've been getting some bugs with sprites. The images get an ugly edge at the sides when smoothing is enabled. Here's a picture which demonstrates the problem.
[img]http://anyhub.net/file/1gyk-tiling_ore_desktop.png[/img]
As you can see, the ball on the left has an ugly white edge at the top and at the side. The one on the right is the desirable result.
I know that setting smooth to false fixes it, but I still want to have smooth graphics. How do I fix this? (using SFML 1.6)
[*]I keep getting problems with stuff being out of scope and not being to access it. Basically, my project is built like this:
[img]http://anyhub.net/file/1gz3-plo.png[/img]
I'm trying to make the GameManager create a Screen, which in turn creates an Entity in it's Init function. Problem is that they don't know each other or something, and keep saying there's no GameManager, Screen or Entity. Any help?
[/list]
[QUOTE=Dlaor-guy;26964050]More C++ trouble in here. I have 2 questions.
[list][*]I've been getting some bugs with sprites. The images get an ugly edge at the sides when smoothing is enabled. Here's a picture which demonstrates the problem.
[img_thumb]http://anyhub.net/file/1gyk-tiling_ore_desktop.png[/img_thumb]
As you can see, the ball on the left has an ugly white edge at the top and at the side. The one on the right is the desirable result.
I know that setting smooth to false fixes it, but I still want to have smooth graphics. How do I fix this? (using SFML 1.6)
[*]I keep getting problems with stuff being out of scope and not being to access it. Basically, my project is built like this:
[img_thumb]http://anyhub.net/file/1gz3-plo.png[/img_thumb]
I'm trying to make the GameManager create a Screen, which in turn creates an Entity in it's Init function. Problem is that they don't know each other or something, and keep saying there's no GameManager, Screen or Entity. Any help?
[/list][/QUOTE]
1: Set smooth is only set on one image, so you can just set smooth to false for that one image. All it does is changes how the image is read from the file.
2: You should declare that the game manager has a screen decleration in it's decleration, and the screen have an entity decleration in it's decleration as well. So something like this:
[cpp]class GameManager{
...
public:
screen myscreen;
...
};[/cpp]
Dumb question but:
When I run [url=http://pastebin.com/pMgNUR4e]this[/url] C# code, rather than creating an SFML.Net window or anything similar, I just get a blank console window. It's probably something stupid but I'm not seeing it.
EDIT:
Nevermind, ATI Drivers + Dynamic Linkage to SFML = bork. (See [url=http://www.sfml-dev.org/forum/viewtopic.php?t=3438]this[/url] thread.)
Change Window to RenderWindow anyways
[QUOTE=WTF Nuke;26966007]1: Set smooth is only set on one image, so you can just set smooth to false for that one image. All it does is changes how the image is read from the file.[/QUOTE]
Are you sure that's the case? I'm pretty sure it changes how the image is rendered, not how it's read from the file.
I may be wrong though
[QUOTE=WTF Nuke;26966007]1: Set smooth is only set on one image, so you can just set smooth to false for that one image. All it does is changes how the image is read from the file.
2: You should declare that the game manager has a screen decleration in it's decleration, and the screen have an entity decleration in it's decleration as well. So something like this:
[cpp]class GameManager{
...
public:
screen myscreen;
...
};[/cpp][/QUOTE]
1: I know that it's per-image, but I still want the ball to be smooth without the ugly edges. Setting smooth to false means it keeps jumping when using positions with decimals, an undesirable result.
2: I already have done this but the problem is that GameManager gives me an error about not knowing what Screen is. That's why I can't create a Screen in my GameManager.
[editline]26th December 2010[/editline]
Information that might be useful: GameManager is a static class and Screen and Entity are normal classes.
[QUOTE=Chris220;26978814]Are you sure that's the case? I'm pretty sure it changes how the image is rendered, not how it's read from the file.
I may be wrong though[/QUOTE]
I may be wrong, the documentation is kind of shoddy on this. But if you want to keep it smooth, then there is no other way (that I know of). Also are you including screen.h in GameManager.cpp and forward declaring the classes? Same with entity.h, is it in screen.cpp?
1: Didn't someone say that in SFML2 that stuff is fixed?
2: You didn't #include Screen.h then I guess? Or if you did, could it be a circular dependency? If that's the case, than you can try to refactor the design (usually the dependency should be linear, e.h. thing A needs to know about thing B, not circular like thing A needs to know about thing B, which needs to know about thing A) or use a reference (or pointer).
[QUOTE=ZeekyHBomb;26979235]1: Didn't someone say that in SFML2 that stuff is fixed?
2: You didn't #include Screen.h then I guess? Or if you did, could it be a circular dependency? If that's the case, than you can try to refactor the design (usually the dependency should be linear, e.h. thing A needs to know about thing B, not circular like thing A needs to know about thing B, which needs to know about thing A) or use a reference (or pointer).[/QUOTE]
Oh quick question, isn't it smarter to put include files in the .cpp and just forward declare in the .h?
[QUOTE=ZeekyHBomb;26979235]2: You didn't #include Screen.h then I guess? Or if you did, could it be a circular dependency? If that's the case, than you can try to refactor the design (usually the dependency should be linear, e.h. thing A needs to know about thing B, not circular like thing A needs to know about thing B, which needs to know about thing A) or use a reference (or pointer).[/QUOTE]
The problem is that GameManager has a function for switching the current Screen and that Screen calls a GameManager function, so they are dependent on each other. I tried including them but which file gets read first gives me errors because it hasn't read the other file yet. I would have no idea how to make only one of them depend on the other...
[QUOTE=Dlaor-guy;26979460]The problem is that GameManager has a function for switching the current Screen and that Screen calls a GameManager function, so they are dependent on each other. I tried including them but which file gets read first gives me errors because it hasn't read the other file yet. I would have no idea how to make only one of them depend on the other...[/QUOTE]
Try including the GameManager.h in the Screen.cpp not Screen.h. Also put header guards on the headers.
[QUOTE=WTF Nuke;26979497]Try including the GameManager.h in the Screen.cpp not Screen.h. Also put header guards on the headers.[/QUOTE]
I already have #pragma once in there, that's a header guard I guess?
Also, it worked! Holy shit, thanks a ton :buddy:
Now my edge smoothing problem...
[QUOTE=WTF Nuke;26979338]Oh quick question, isn't it smarter to put include files in the .cpp and just forward declare in the .h?[/QUOTE]
Forward declaration is only possible under certain circumstances. But if these apply, yes.
[QUOTE=Dlaor-guy;26979810]I already have #pragma once in there, that's a header guard I guess?
Also, it worked! Holy shit, thanks a ton :buddy:
Now my edge smoothing problem...[/QUOTE]
There's nothing you can really do about edge smoothing. You either have it on, or you don't.
Edit: Actually maybe upgrading to SFML 2.0 will work better because I have smoothing off, but the movement is still smooth. Smoothing only affected the image, not the movement. When rendered though, the image looked a bit weird (with smoothing on).
[QUOTE=Dlaor-guy;26979810]I already have #pragma once in there, that's a header guard I guess?
Also, it worked! Holy shit, thanks a ton :buddy:
Now my edge smoothing problem...[/QUOTE]
Yes. If you care about cross-platform development or plan to release your source, you should not use #pragma, or if for some reason you need to check for the compiler (in case of MSVC the macro _MSC_VER is defined).
If not it still might be a habit to not get used to.
Does anybody here know anything about [url=http://nemesis.thewavelength.net/index.php?p=35]HLLib[/url]? I'm trying to use it with C# (with the included wrapper) but keep getting a System.AccessViolationException during the call to the hlItemGetName funtion.
[csharp]string path = "C:\\Program Files\\Steam\\steamapps\\team fortress 2 content.gcf";
uint uiPackage = HLLib.HL_ID_INVALID;
uint uiMode;
HLLib.hlInitialize();
HLLib.HLPackageType packageType = HLLib.hlGetPackageTypeFromName(path);
HLLib.hlCreatePackage(packageType, out uiPackage);
HLLib.hlBindPackage(uiPackage);
uiMode = (uint)HLLib.HLFileMode.HL_MODE_READ;
uiMode |= (uint)HLLib.HLFileMode.HL_MODE_VOLATILE;
HLLib.hlPackageOpenFile(path, uiMode);
IntPtr root = HLLib.hlPackageGetRoot();
string name = HLLib.hlItemGetName(root); // Exception here
HLLib.hlPackageClose();
HLLib.hlDeletePackage(uiPackage);
HLLib.hlShutdown();[/csharp]
Relevant part of HLLib.cs:
[csharp][DllImport("HLLib.x86.dll", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string hlItemGetName(IntPtr pItem);[/csharp]
Relevant part of stack trace:
[code]at Microsoft.Win32.Win32Native.CoTaskMemFree(IntPtr ptr)
at HLLib.x86.hlItemGetName(IntPtr pItem)
at HLLib.hlItemGetName(IntPtr pItem) in ...my project dir.../HLLib.cs:line 565
[/code]
Other functions that involve items work perfectly (like hlItemGetType) and the library works perfectly when used with C++. However, the HLExtract.Net example that is included with the library also seems to have the same problem.
I've tried recompiling the .dll, but that doesn't fix it. Am I doing something wrong or is it a problem with HLLib?
Is root != IntPtr.Zero?
[QUOTE=ZeekyHBomb;26996450]Is root != IntPtr.Zero?[/QUOTE]
Yes, it appears to be pointing to a valid piece of memory since all other functions like getting the type and finding subitems work correctly (hlItemGetName causes an exception on those items too, not just the root).
Im trying to make a dynamic box drawing program that allows you to draw new boxes on the go
C++ and SFML
[code]
#include <SFML/Graphics.hpp>
#include <iostream>
#include <list>
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
std::list<sf::Shape> myList;
sf::Vector2f firstPos = sf::Vector2f(0.0f , 0.0f);
sf::Vector2f endPos = sf::Vector2f(0.0f , 0.0f);
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
if(App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
if(App.GetInput().IsKeyDown(sf::Key::Escape))
App.Close();
if(App.GetInput().IsKeyDown(sf::Key::A))
{
firstPos = sf::Vector2f(Event.MouseMove.X,Event.MouseMove.Y);
std::cout << "new vect at x: " <<firstPos.x << " y: " << firstPos.y<< std::endl;
}
if(Event.Type == Event.MouseButtonReleased && Event.MouseButton.Button == sf::Mouse::Left)
{
endPos = sf::Vector2f(-Event.MouseMove.X,Event.MouseMove.Y);
myList.push_back(sf::Shape::Rectangle( firstPos,endPos ,sf::Color::Red ) );
std::cout << "new square width: "<< endPos.x<< " eight: "<< endPos.y << std::endl;
}
}
// Clear the screen (fill it with black color)
App.Clear();
for(std::list<sf::Shape>::iterator iter = myList.begin(); iter != myList.end(); ++iter)
{
App.Draw(*iter);
}
// Display window contents on screen
App.Display();
}
return 0;
}
[/code]
But the console is printing:
[img]http://img407.imageshack.us/img407/3339/12152951.png[/img]
Well, you're trying to access the MouseMove-event, although it might not be present.
What you want instead is
[cpp]const sf::Input& Input = App.GetInput();
firstPos = sf::Vector2f(Input.GetMouseX(),Input.GetMouseY());[/cpp]
Also, you need a more consistent scheme to name your variables (some start with upper-case, others with lower-case).
:D works fine now, thanks.
So i take it what i was using is only for detecting if the mouse is moving?
It's for the delta-position of the mouse I think.
And if it didn't move, probably just random values.
[img]http://img839.imageshack.us/img839/7706/94283491.png[/img]
Red shapes are draw shapes, blue one is what will be drawn if you click at that position
Does anyone know if VS2010 has problems using Lua with C++?
I have not had any issues with lua. What errors are you getting.
main.cpp code:
[code]#include <iostream>
#include <SFML/System.hpp>
#include <string.h>
extern "C"
{
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
}
using namespace std;
void printText(char myText[],float Delay)
{
for(int i = 0; i < strlen(myText) ; i++ )
{
cout << myText[i] << flush;
sf::Sleep(Delay);
}
}
int main()
{
lua_State *L = luaL_newstate();
// load the libs
luaL_openlibs(L);
//run and check for Lua scrip here
if( luaL_dofile(L,"foo.lua") )
{
cout << lua_tostring(L, -1); // the error is on top of the stack
}
printText("Hi, enjoy hacking with Lua\n", 0.2f);
printf("\nI am done with Lua in C++.\n");
lua_close(L);
return 0;
}[/code]
foo.lua code
[code]io.write("Please enter your name: ")
name = io.read()
io.write("Hi " .. name .. ", enjoy hacking with Lua\n")
[/code]
errors:
[quote]1>------ Build started: Project: Lua embedding, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl sf::Sleep(float)" (?Sleep@sf@@YAXM@Z) referenced in function "void __cdecl printText(char * const,float)" (?printText@@YAXQADM@Z)
1>main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _lua_tolstring referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _lua_pcall referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_loadfile referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main
1>C:\Users\Richy\documents\visual studio 2010\Projects\Lua embedding\Debug\Lua embedding.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/quote]
[QUOTE=Richy19;27013294]main.cpp code:
[code]#include <iostream>
#include <SFML/System.hpp>
#include <string.h>
extern "C"
{
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
}
using namespace std;
void printText(char myText[],float Delay)
{
for(int i = 0; i < strlen(myText) ; i++ )
{
cout << myText[i] << flush;
sf::Sleep(Delay);
}
}
int main()
{
lua_State *L = luaL_newstate();
// load the libs
luaL_openlibs(L);
//run and check for Lua scrip here
if( luaL_dofile(L,"foo.lua") )
{
cout << lua_tostring(L, -1); // the error is on top of the stack
}
printText("Hi, enjoy hacking with Lua\n", 0.2f);
printf("\nI am done with Lua in C++.\n");
lua_close(L);
return 0;
}[/code]
foo.lua code
[code]io.write("Please enter your name: ")
name = io.read()
io.write("Hi " .. name .. ", enjoy hacking with Lua\n")
[/code]
errors:[/QUOTE]
Are you linking everything correctly? As in, did you add the libs to the dependencies?
Sorry, you need to Log In to post a reply to this thread.