Advertisement Jump to content
  • Advertisement

cherryyosh

Member
  • Content Count

    105
  • Joined

  • Last visited

Community Reputation

100 Neutral

About cherryyosh

  • Rank
    Member
  1. I am woundering if anyone could help me figure out how to pass a c++ object to lua using swig. I have found the command SWIG_NewPtrObj() but have not been able to find out how to use this and what include files to use. Any help would be useful but would love a simple example of this. Thanks
  2. Hi, Im trying to use lua to parse a xml file for themes. I am using luaexpat for reading the xml and luabind for binding the c++ functions. The erro happens when I set values in the struct, after I set two values luaexpat stops calling any callbacks, no errors are thown.. any ideas?? the lua script print("-- Loading Theme --") require "lxp" local theme = Theme() local curWidget = nil local function texture(name, args) local widget = theme : NewWidget(args["name"], nil) for i=1,#args do if args ~= "name" then widget[args] = tonumber(args[args]) end end end local function widget(name, args) curWidget = theme : NewWindow(args["name"], nil) end local function child(name, args) local child = theme : PushWidget( curWidget, args["type"] ) for i=1,#args do print(args) end end callbacks = { StartElement = function (parser, name, attribs) if name == "texture" then print("here") texture(name, attribs) elseif name == "widget" then widget(name, attribs) elseif name == "child" then child(name, attribs) end end } local parser = lxp.new(callbacks) local file = io.open("themes/default.xml", "r") for line in file:lines() do print(line) parser:parse(line) end file:close() print("-- Finished loading theme --") the parts of the xml file that are read +1 line note: doesnt matter what they are, always failes on two <theme> <textures file="default.png" format="RGBA"> <texture name="rule.top" x="55" y="7" width="186" height="20" /> <texture name="button.close" x="10" y="10" width="10" height="10" /> and the binding code void Theme::RegisterFunctions() { luabind::module(GetLuaState())[ luabind::class_<Theme > ("Theme") .def(luabind::constructor<>()) .def("Init", &Theme::Init) .def("LoadTheme", &Theme::LoadTheme) .def("PushWidget", &Theme::PushWidget) .def("NewWidget", &Theme::NewWidgetData) .def("NewWindow", &Theme::NewWindowData) .property("Image", &Theme::GetImage, &Theme::SetImage) ]; luabind::module(GetLuaState())[ luabind::class_<WindowData > ("WindowData") .def(luabind::constructor<>()) .def_readwrite("Widgets", &WindowData::Widgets) ]; luabind::module(GetLuaState())[ luabind::class_<WidgetData > ("WidgetData") .def(luabind::constructor<>()) .def_readonly("name", &WidgetData::name) .def_readwrite("x", &WidgetData::x) .def_readwrite("y", &WidgetData::y) .def_readwrite("width", &WidgetData::width) .def_readwrite("height", &WidgetData::height) ]; luabind::module(GetLuaState())[ luabind::class_<ChildData > ("ChildData") .def(luabind::constructor<>()) .def_readwrite("Data", &ChildData::Data) .def_readwrite("Callback", &ChildData::Callback) .def_readwrite("x", &ChildData::x) .def_readwrite("y", &ChildData::y) .def_readwrite("z", &ChildData::z) ]; } Edit: the new widget data function WidgetData* Theme::NewWidgetData(std::string name, WidgetData* data) { if (data != NULL) Widgets[name] = data; else Widgets[name] = new WidgetData; Widgets[name]->name = name; return Widgets[name]; } and here is the output im expecting here after every texture element not just two, which means its not reaching the callback... -- Loading Theme -- <theme> <textures file="default.png" format="RGBA"> <texture name="rule.top" x="55" y="7" width="186" height="20" /> here <texture name="button.close" x="10" y="10" width="10" height="10" /> here <texture name="rule.side" x="58" y="41" width="12" height="166"/> <texture name="rule.bottom" x="76" y="34" width="161" height="7"/> <texture name="editbox.input" x="82" y="194" width="155" height="20"/> <alias name="exitbutton" ref="button.close"/> </textures> <widgets> <widget name="console"> <child type="rule.top" x="0" y="0"/> <child type="button.close" x="10" y="2"/> </widget> </widgets> </theme> -- Finished loading theme -- thanks EDIT2: Finally found out that the error is caused by a stack corruption, no idea how to fix this tho.. so help still needed [Edited by - cherryyosh on May 16, 2009 10:43:21 PM]
  3. cherryyosh

    That annoying warning

    Quote:Original post by Deyja Then I wonder what compiler you're using, because that is not legal C++. The size of an array must be constant at compile time. This is allowed in C++... Don't know where you got your facts from... @BladeStone, Dont use Dev-C++ its old as crap.. Look at MS Visual Stuidos (windows) or for a portable approch Netbeans or eclipse are good IDE's (I use netbeans on linux when I feel like using a ide)
  4. Hi, I have a quad that can be rotated along all three axises, and am trying to figure out where in this quad the mouse lay. Without the x and y axis rotation I know I can unproject the mouses position to get the correct object space, however once I rotate around either the x or y axis this no longer works for me. So wondering how I can do this without resorting to ray casting. Also note I have tryed 'inverse(rotation) * mouse' but it doesnt work. edit: I figure what is happening with the inverse is that it is also affecting the z value and throwing off the x and y so this works correctly. However because im trying to negate any z transformations this just serves to throw off everything else.. so is there any way to ignore adjusting for the z?? (if that makes any since)
  5. cherryyosh

    [C++]Key input question...

    key[KEY_SPACE]{ (Do this); (Do this); key[KEY_SPACE] = false; } ...
  6. Hey guys, I am looking for a way to convert a screen spaced 2d vector to a object space 2d vector. Basically I have a gui that can be rotated and what to be able to quickly tell if the mouse is inside the object. Currently I am simply check the x, x+width, y, +height. However once rotation comes into play these, of course, no longer work. I have heard from several people that gluUnproject will do what I need which ha led me to build my own unproject function, as I needed to use floats and not doubles. The code below tends to give me skewed results. With no rotation the Y axis is mirrored over the x axis, and when rotated 90 degrees the x axis becomes skewed. Any ideas?? void Window::Unproject( float winx, float winy, float* p, int* view, float* ox, float* oy ){ nv::vec4<float> in = nv::vec4<float>( ((winx - view[0]) * 2.0) / view[2] - 1.0, ((winy - view[1]) * 2.0) / view[3] - 1.0, -1.0, 1.0 ); nv::matrix4<float> proj; proj.set_value( p ); nv::vec4<float> ret = inverse( proj * Modelview ) * in; if( ret.w == 0.0 ) return; *ox = ret.x / ret.w; *oy = ret.y / ret.w; } SOLVED: Inverted the in.y and it seems to work fine now.. [Edited by - cherryyosh on April 22, 2009 6:57:47 PM]
  7. cherryyosh

    Help with GUI design

    Quote:With the gl_static_draw, do you never intend to let the screen be resized? The current plan is to pass in a modleview matrix per object, this will scale and translate (and could be used to rotate the gui, if I ever come up with a need to) each object. Quote:How come the sliders need to be drawn twice? using this method I would have a texture position for both the bar and the slider object, no idea what the name is, this will cause me to draw the bar and then the slider, but I guess I will always have to do this. Quote: And to store offsets, I guess you could store all the objects in a tree structure with an x,y which offsets from the parent. that is exactly what I was plaining on doing :]
  8. cherryyosh

    Help with GUI design

    Quote:Original post by andrew111 I'd think it would be easier to draw each element using the basic glBegin (triangle or quad etc)/ glEnd and store all the gui information in your own data structures, including texture coordinates, texture buffer pointers, button captions etc. As I said before I wish for this code to be fully 3.1 compatible. This includes removing all immediate mode functions. I will also be storing all of the information in the gui data structors. Currently this holds information such as the translation, the state of the button, aka weather it is highlighted, pressed or not, and the width and height which will be replaced by a scale factor. Also I do not care abotu how 'easy' something is, as long as it is a working fast solution, which can be placed in this format without looking like a complete hack. :P
  9. cherryyosh

    Help with GUI design

    By offset I mean the offset of the texture coords and vertices' in the VBO as they all will be in one large vbo then this is necessary.
  10. cherryyosh

    a couple of opengl questions

    Quote:Original post by andy_boy Okay then thanks. Now I've read that opengl 3.0 is basically opengl 2.1 (with extensions) and a deprecation feature. Is there some tool I could use to know which features of opengl 2.1 I should not be using, so when I make the jump to 3.X it will be smoother? http://www.devklog.net/2008/08/23/forward-compatible-opengl-3-entry-points/
  11. So, I've been talking with a friend for the past few days about a gui class design, namely updating it to take advantage of new features and be fully OpenGL 3.x compatible. And of course speeding it up from the standard glBegin()/glEnd that it is using currently. I would like your thoughts on my design and help figuring out some parts of it. Currently the gui is set up so that it has a manager, When this manager is created it calls a function (ThemeMgr_LoadTheme()) which loads a theme file which stores the location to a monolithic theme image and data for which type of gui object uses what range (close:10,10,40,40 would tell any button marked as close to have a topleft of 10,10 on the image and a bottom right of 40,40 [this would also set the default (1) scale to be 30x30]) once all this data is loaded a large vbo holding both the vertex data and the texure coord data. This VBO is bound as GL_STATIC_DRAW and indices will be created . I am currently trying to figure out a clean way to store the needed offset on a per gui-object-class (button, text edit.. etc) way (perhaps static?). Every frame a simple 2d shader is loaded, and a orthographic projection matrix is sent to it, this is done only once per frame as it is not needed more. from there guimgr->render() is called where the needed things are bound and for each object a new modelview matrix is created, this will be used to scale and translate the object, and glDrawElements() is called with the given objects offset. This should work for simple objects and for containers I can just draw all the objects inside it, however for things such as sliders, I can only guess I will need to actually draw two times. I am wondering what your thoughts are on this design, if any of you have tryed it or any flaws I am missing. And also if there is a better, or faster, way to go about doing this.
  12. cherryyosh

    OpenGL 3.1

    Quote:Original post by lightbringer It's here. Looks like they added (promoted?) some features and removed immediate mode, but still nothing like the major rewrite that was promised a long time ago for version 3. Is that still in the pipeline or should we forget about that? Removing all the features they did will allow a major rewrite of the code. It is about what I was expecting. I am guessing 3.0 is a result of the bureaucrat that said just removing features without notice would have been to harsh so they marked them for deletion wait a little while and then deleted them. I am happy with this, cant wait to see what is added later and how much of a speed improvement this will cause.
  13. cherryyosh

    gluLookAt + glsl shaders

    Quote:Original post by EternityZA Thnx a Lot, i got it working! by the way. Is there anything bad about the way im doing this? meaning is it uncommon/bad to calculate the matrixes yourself and not use the built in functions like glRotate/glTranslate etc. There is nothing wrong with it, its the way I do it. they just make it much easier. Also as a note, you basically have to do it yourself to be forwards with oGL 3.0.. I would say it is uncommon right now, just due to the work involved. But I really like doing it this way better, dont have to mess with all that glMatrixMode stuff...
  14. cherryyosh

    OpenGL 3.0 is not OOP because C++ has no ABI

    Quote:Original post by Yann L The problem of OpenGL 3.0 is not so much the lack of OOP. OpenGL by itself is reasonably OO, although still with a C interface. That isn't really a problem, as some might argue that D3D's COM isn't really ideal either. If you need C++ like OO, you can write a wrapper (and most engines do this to some extend), which can have very low overhead if done right. The main problem with OpenGL 3.0 is the antiquated state model. Consider this source snippet to update the modelview matrix (taken from the DSA extension): *** Source Snippet Removed *** While it should be something like this: *** Source Snippet Removed *** Same goes for any other area that uses current state selectors: textures, shaders, vertex streams, etc. Or consider the hoops you have to go through if you want to bind a texture object to a GLSL sampler. You first have to select the texture image unit you want to use. Then you have to bind the texture object to it. And finally, you have to assign the sampler to the texture image unit number. Why not simply assign the texture object to the sampler ? One single command instead of three, and no current state changes. The hardware can do it. But the obsolete state model of OpenGL prevents this. I dont mean to say what your saying in invalid. But opengl 3.0 has no glLoadMatrix* or anything like that. You are suppose to store and keep track of the matrix's yourself and then upload them to a shader. thus the code becomes 'shader.setMVMatirx( modelView );' where setMVMatrix does something like ' glUniformMatrix4fv( modelViewLoc, 1, false, matrix);' or something like that... http://www.devklog.net/2008/08/23/forward-compatible-opengl-3-entry-points/ edit: atleast there deprecated..
  15. this is a odd error the only thing I can think of is that the card creates a depth buffer for the texture, plus perhaps your card does not support true RGB textures and internally raise it to a RGBA.. Still dont think this would account for 254MB but would be a lot closer.. Maybe someone can shead more light on the subject... also are you doing more then just creating a FBO and binding it? The card will (should) cache any other FBO's or textures for speed reasons... and what are you using to get the free memory? That itself might be more of a estimate then a true value.. actuly now that I think about your math may be off, your mult'ing it by 2 for 2bytes but if your diving it by 1024(bits) you will get the wrong value... tryed it with multing it by 16 and came out right [Edited by - cherryyosh on March 17, 2009 2:28:28 PM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!