First off, hello, as this is my first post on the forums.
I recently started developing with orx. I've read the tutorials and started writing my own code/configs. Begginings were not so pleasant, especially considering that I didn't touch C/C++ for a fairly long time and Java made me quite a lazy programmer
I want to program a game for my MA thesis. The main hero of the game is a cat which is going to get fatter or thinner depending on the player's progress. To get the best result I want him to be drawn dynamically. I've searched the forums and found out that fairly recently the orxDisplay_Draw* functions have been added. The autocompletion in the Visual Studio didn't show it so I decided to get the newest version from the SVN. After updating the files it still didn't show up (is this normal for recently added things? I mean should the autocompletion automatically find functions etc. or is it required to be added manually?) so I just thought that I'll write it and see if it works. The project built successfuly but unfortunately my line was not drawn. Same thing for the circle. Dig through the forum a bit more and found out that I need to call the functions after orxRENDER_EVENT_START. Unfortunately that didn't help. I've tried calling draw functions after orxRENDER_EVENT_START and also commented out BackgroundColor field in the config. Still no success. Is there something I'm missing?
orxSTATUS orxFASTCALL TestField::Init(){
orxViewport_CreateFromConfig("Viewport");
//cat = orxObject_GetChild(orxObject_CreateFromConfig("Scene"));
//orxConfig_Load("../conf/Kotek.ini");
clock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);
orxClock_Register(clock, update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);
//orxEvent_AddHandler(orxEVENT_TYPE_INPUT, handleInputEvent);
orxEvent_AddHandler(orxEVENT_TYPE_RENDER, handleRenderEvent);
return orxSTATUS_SUCCESS;
}
orxSTATUS orxFASTCALL TestField::handleRenderEvent(const orxEVENT *currentEvent){
switch(currentEvent->eID){
case orxRENDER_EVENT_START:
{
orxVECTOR vector1, vector2;
orxVector_Set(&vector1, 0, 0, 0);
orxVector_Set(&vector2, 640, 480, 0);
orxDisplay_DrawLine(&vector1, &vector2, orx2RGBA(0xFF, 0xFF, 0xFF, 0x00));
//orxLOG("Line drawn.");
return orxSTATUS_FAILURE;
}
}
return orxSTATUS_SUCCESS;
}
Comments
I've just spent a few minutes looking this over and managed to get it to work:
here's what I have written as my 'test' event handler:
The main differences are that I render the line on the 'stop' event (to make sure it is drawn last) and I changed the Alpha value of your colour (0 = transparent, 255[0xFF] = fully opaque)
Give that a go, and if you've any more questions, don't hesitate to ask!
..I messed up with the alpha value! Thought it's value is passed as the first argument. The simplest things make the biggest headaches
Maybe you know if I can complete the autocompletion (haha) with the new functions or is it just something that'll come with newer versions of orx?
Grey beat me to it, but my money would also be on the transparent alpha.
As for the completion, that would be Visual Studio IntelliSense. You can ask it to regenerate its database but in my experience it's proven to be quite ineffective in some situations.
It might also depend on the versions, I have completion for the draw functions on my vs2008.
Just in case, for auto-completion and syntax color, there's Visual Assist, a plugin for Visual Studio (2008 in my case).
I can't use Visual Studio without it. Very great tool, never have any problems.
https://forum.orx-project.org/discussion/3070#Comment_3076
As almost all of my main character is drawn dynamically it is a serious problem for me.
Now the easiest way to draw at a given depth is to override an object's rendering. Well actually you don't have to override it, you can draw behind, on top or actually substitute your own drawing.
The depth is controlled via the Z coordinate, as usual.
There are two events sent: orxRENDER_OBJECT_START and orxRENDER_OBJECT_STOP.
If you make your drawing calls when listening to the start event, it'll be displayed behind the object, if it's done when listening to the stop event, it'll be displayed on top of the object.
If you want to override the object's redering, listen to orxRENDER_OBJECT_START, make your draw calls there and return orxSTATUS_FAILURE from the event handler: that'll tell orx not to do any regular rendering for that object.
One thing to note: only objects that have a valid orxGRAPHIC attached to them are considered by the renderer. If you only need a placeholder graphic, one solution is to use the embedded "pixel" texture if you don't want to define an external one.
Let me know if you need more details about the whole procedure!
PS: You can also listen to the orxRENDER_VIEWPORT_START/orxRENDER_VIEWPORT_STOP events if you need to draw things before/after a viewport has been rendered.