C/C++ :: Automatic Cast Object To OpenGL Handle / ID

Oct 24, 2014

I programming currently something with OpenGL. Now I have written some wrapper classes, like Shader, Program .... All works fine, but I don't like to call Shader.GetHandle() every time I want to call a OpenGL function manually where I need the object handle/id. (GetHandle() returns the OpenGL ID of the object)

So now I wonder, is it possible to program it in C++ so, that I can put my objects to gl methods and c++ automatically pass the handle/id member to that function ? Is there maybe a operator that I can use for that?

For example:

The way I do it now:

Shader vertexShader();
glCompileShader(vertexShader.GetHandle());

The way I want to:

Shader vertexShader;
glCompileShader(vertexShader);

View 3 Replies


ADVERTISEMENT

C++ :: 2D Game - How To Handle Drawing Order Of Object Visibility

Feb 9, 2015

In 2D games, what's the best way to handle the order of drawing objects? Because most games have a background, tiles to be drawn behind the player, perhaps tiles to be drawn covering up the player, etc. My point is, with my current setup of simply looping through all objects and drawing, I have no control over what objects are drawn on top of or behind the others. My best idea so far is to hold a vector of object pointers, each vector representing a different "visibility level", like so:

class Level{
//...
std::vector<Object> allObjectInstances;
std::vector<Object*> visibilityOne; //background objects
std::vector<Object*> visibilityTwo; //objects in front of background but not necessarily all the way in front
//and so on for more objects
};

If I go through with this, I'm wondering how I could loop through all my objects and add them to each vector, then shorten whatever I have to loop through for subsequent visibility vectors. handling the order of drawing objects?

View 6 Replies View Related

C++ :: Cast Directly Between Base Classes Of Object?

Jul 1, 2013

I've got two classes, which are both derived from the same two base classes. Here's a representation of the actual code:

Code: #include <vector>
class BaseClassA {
};
class BaseClassB {
};
class TestClassX
: public BaseClassA,
public BaseClassB

[code].....

Basically, I'd like to know if it is possible to cast directly from a BaseClassA pointer to a BaseClassB pointer, without casting to the child class first.

View 10 Replies View Related

C++ :: Designing Object In Solidworks -> OpenGL?

Jul 11, 2014

If I wanted to design an object in SolidWorks, and then output that object (I guess as a .stl file), is it possible to open that up and manipulate using openGL? How would I go about doing that?

View 1 Replies View Related

C Sharp :: How To Cast Dataset To Strongly Typed Object

Dec 17, 2014

Following is my xml file called PropertyInfo.xml :-

<?xml version="1.0" encoding="utf-8" ?>
<PropertyInformation>
<locations>
<location name="Bombay">

[Code].....

In above LoadPropertyInfo() method, how to cast DataSet to List<Location> locations before returning "locations" ?

View 2 Replies View Related

C++ :: OpenGL - Does Vertex Array Object Store Enabled Attributes

Jan 8, 2014

Does the VAO (glGenVertexArrays/glBindVertexArray/glDeleteVertexArrays) store the enabled/disabled state for the Vertex Attributes (glEnableVertexAttribArray/glDisableVertexAttribArray) or should I re-enable them every time?

View 1 Replies View Related

C :: Automatic Declaration Of Array Variables

Jul 14, 2014

I have some files:

file1: 1000x500 array of numbers
file2: 2000x600
file3: 300x5000
...

I would like to automatically declare array variables of myarray1, myarray2, myarray3... that reads the numbers from files:

Code:
for (i1=0; i1<nrows; i1++)
{
for (i2=0; i2<ncolumns; i2++)
{
fscanf(filename, "%lf", &y);
myarrayX[i1][i2]=y;
}
}

nrows and ncolumns can be passed from a config file. Also I can cat all files into a single filename. However, the difficult part is:

How to declare different myarrayX automatically ? (A workaround is to declare a huge 3d array but I do not want to do this).

View 4 Replies View Related

C++ :: Automatic Conversion For Function Parameters?

Nov 19, 2013

So I'm writing a data structure from scratch as part of a university assignment in c++, and I have to write an iterator for it. The problem involves comparison between constant iterators and normal iterators, and I'm going about it in this way: I wrote a constructor of normal iterator which takes a const iterator as its only parameter, hoping that the comparison operator between two normal iterators will be enough:

btree_iterator(const_btree_iterator<T>&conv):_target(conv._target),_index(conv._index),_last(conv._last){}

(and somewhere else)

template <typename T>
bool operator!=(btree_iterator<T> one,btree_iterator<T> other){
return !(other == one);
}

and I'm testing it in this way:

btree<int> bl(5);//the data structure
auto iter = bl.begin();
iter != bl.cend(); //trying to compare iterator with const iterator

but apparently this is wrong, since the compiler tells me something along the line of "no function 'operator!=' which takes ......" It seems the constructor is alright, since the following works:

btree<int>::iterator i(bl.cend());

Am I getting something fundamentally wrong about it? How is this functionality actually implemented in C++ library containers like vector?

View 9 Replies View Related

C Sharp :: Simulate (automatic) Mouse Right Click

Aug 22, 2013

How to simulate(automatic) mouse right click operation using c#?

View 2 Replies View Related

C++ :: Template To Hold Two Dimensional Arrays - Automatic Indexing

Mar 6, 2015

For the past couple of weeks I have been working on a template to hold two-dimensional arrays. Right now I am puzzling over an indexing question.

There are many places in the template where I would like to use initializer_lists to refer to user-specified row and column ranges, particularly in member function arguments. A typical example would be a member function whose declaration would be along the lines of:

Code:
Array<Type>::some_function(std::initializer_list<int> columns, std::initializer_list<int> rows); which could get called via

Code:
arrayInstance.some_function({3:4}, {5:8});

It would be really nice to be able to use Matlab-style indexing to specify the last column, or the last row, in the Array object -- along the lines of

Code:
arrayInstance.some_function({3:4}, {5:END}); where END takes the value -1, and can be defined in Array, or somewhere else.

The way I have tackled this so far was to write myself an Indices PODS class with two elements to hold start and finish values, and a constructor-from-initializer_list that looks something like this:

Code:
Indices::Indices(std::initializer_list<int> range, int replace_value) {
int const *it = range.begin();

start = (*it == END) ? replace_value : *it ; ++it;
finish = (*it == END) ? replace_value : *it ;
...
}

So the elements of "range" give the values of Indices::start and Indices::finish -- but if either of them are entered as END by the user, they will be replaced by replace_value. (The default value of replace_value is END, so Indices::start and Indices::finish will never change if it is omitted.)

I also defined an Indices::endset(int) function to do the same thing for existing Indices objects:

Code:
Indices::endset(int replace_value) {
if (start == END) start = replace_value;
if (finish == END) finish = replace_value;
} Using Indices::endset, you can code up Array::some_function by modifying the above signature to something like

Code:
Array<Type>::some_function(Indices columns, Indices rows) {
columns.endset(this->M);
rows.endset(this->N);
...
}

This does work, and I've been able to use it in practice. However, it is klutzy. What I would really like to be able to do is have the Indices constructor handle value-replacements in "columns" and "rows", instead of needing to put calls to Indices::endset in every single Array<Type> member function that uses this approach.

The basic problem is that, when Array<Type>::some_function is called, there is no easy way of inserting Array<Type>::M and Array<Type>::N into the optional argument of the Indices constructor when "columns" and "rows" are being built.

The Indices class needs somehow to get access to these, and know which one is being used, M or N. So it needs to have some sort of deeper connection to Array<Type>, but I don't know what that connection should be.

View 2 Replies View Related

C Sharp :: Generate Automatic Alerts With Snooze Time Before Targeted Date And Day Before

Nov 20, 2012

i want to create an application which generates popup alerts at the day of event occurs as well as a day before the event will occur in a specific time interval as well.. events are stored in database and they are all date time fields .. so i want to link those fields to create popups ..

View 2 Replies View Related

Visual C++ :: Automatic Login / Password Into Web Page Using Details Fully Automated

Feb 9, 2015

I Want to login this webpage automatically using vbs or any other javascript

I want to login into this [URL] .... web page and book the tickets for me by automatically.

Requirements into the site as given below as mentioned in order

Login with Login Details

Captcha Will be there, for that assume manually entered.

Then select particular event, pick the date and again check the event, select the number of persons, click on submit button.

Fill the Persons details and photo.

Check the button of I read the terms and conditions.

Click on the submit button

All these should be done within the small time.

View 2 Replies View Related

C++ :: Calculate Something More Than A Var Can Handle?

Jan 1, 2013

Let's say I want to calculate something like PI using some algorithm, but with the number of digits I want to.

View 1 Replies View Related

C# :: How To Close Overlapped I/O Handle

Nov 6, 2012

Consider the following code which closes an overlapped I/O serial handle during application shutdown.

Code:

Win32Com.CancelIo(hPort);
Win32Com.CloseHandle(hPort);

It works fine under .NET 2.0 but after switching to .NET 4.0 it crashes on the CloseHandle. Removing CancelIO doesn't work.

What the correct way is to close an overlapped I/O handle? And why is there the difference between NET2.0 and 4.0?

View 5 Replies View Related

C :: Handle Cmd Line Arguments?

Jul 30, 2013

How to handle cmd line argument in c.

View 5 Replies View Related

C++ ::  how To Handle Async Operations

May 29, 2013

I've been thinking over this for long time... For example, when a button is clicked, print a string "clicked" after 5 seconds. (the button won't be blocked)

Thread should be the only way to do this:

btn.on_click = []() {
thread thrd([]() { sleep_5_seconds(); cout << "clicked" << endl; });
thrd.start();
};

the local variable thrd is destructed right after it starts, which may cause a crash, so use new operator:

btn.on_click = []() {
thread* thrd = new thread([]() { sleep_5_seconds << "clicked" << endl; });
thrd->start();
};

The thrd never get deleted

How would you solve problem like this?

View 2 Replies View Related

C/C++ :: How To Handle Exception In Constructor

Apr 14, 2012

If a class A contains an array of objects of another class B.. And in the constructor of A, while constructing objects of B, any one object throws an exception, then how can we guarantee to release all the memory acquired.. so that there is no memory leak..

class B{};
class A{
public:
  B Array[100];
  ...
};  

In the above code, if in constructor of A, suppose 99 objects of B are constructed successfully, but 100th object throws exception, then how can we guarantee to release all the memory acquired by the other 99 objects?

View 1 Replies View Related

C++ :: SDL Handle Mouse Motions And Clicks?

Sep 14, 2013

I have a game that I'm trying to create but I don't really know how to handle mouse motions yet. I have read the LazyFoo.net lesson 9. And I have too searched around on Google but haven't find any good article for what I want to do

But what I want is to check if the mouse is OVER the START button of the game and if the user has pressed the LEFT mouse button the game should START.

This works when I am hovering over the area there I want the mouse to do something:

Code:
else if (event.type == SDL_MOUSEMOTION)
{
if (event.motion.x == 0)
{
quit = true;
}
}

I do not know how to check this. The START and QUIT button is in the middle of the screen and I don't know how to position the mouse there either.

View 5 Replies View Related

C++ :: SDL - How To Handle Mouse Motion Input

Oct 19, 2013

I am using SDL 2.0. But I don't know how to handle mouse input. Do you think you can explain of how to do that? Or give me a link that explains that really great?

I know how to handle a mouse button that presses down for a sec.

Code:
if (event.type == SDL_MOUSEBUTTONDOWN){
if (event.button.button == SDL_BUTTON_LEFT){
// Do something . . .
}
}

But not how to handle the mouse input of what the mouse is hovering over and that.

Like in a start menu of a game. I want a button for example to appear blue when I hover over it and when I click on it. It should start the game for example.

View 6 Replies View Related

C :: How To Handle Sound And Music Files

Mar 11, 2013

I do not know any of the functions to do this, and when I looked on the internet all the functions I saw were mainly non-standard.

View 12 Replies View Related

C# :: How To Properly Handle Thread Failures

Feb 9, 2015

I have an application that uses an array of threads to call a method along with thread.join(). I was just wondering what would be the best way to handle the thread in case if one of the thread fails? Should I put a try catch block on the method that is being called or should I put the try catch block on the array of threads, or is there any other proper way to handle failed threads?

View 3 Replies View Related

C/C++ :: How To Handle Floating Point Error

Nov 7, 2013

And it is not running successfully... abnormal termination

View 3 Replies View Related

Visual C++ :: Passing File Handle To DLL?

May 6, 2013

I write a small application and using the following API to open the file:

hHandle = CreateFile(lpszFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

Then I pass the hHandle to a DLL exported function, in that function, I will call

DWORD dwFlags = 0;

ASSERT(GetHandleInformation(hFile,&dwFlags) != 0)

to check if the handle is valid. However, the assert fails. And I use GetLastError to get the error code 6, which means invalid handle.

What is the problem with my codes?

View 4 Replies View Related

Visual C++ :: Pass A Handle To A Function

May 5, 2013

Visual C++ 2010

I'm using SFML with Visual C++ and need to pass a handle to a function. I've tried to find this on the web with no luck.

The handle happens to be a sprite defined as: sf::Sprite Numbers(MyNumbers);

Now I want to pass "Numbers" to a function.

-
-
getFrame(Numbers);
-
-
???? getFrame(??????) {
Numbers.SetSubRect(sf::IntRect(0,0,63,63));
return ????
}

How do I do this?

View 1 Replies View Related

C++ :: How To Handle The Exceptions Not Caught By Try / Catch

Nov 2, 2014

Here is an example,

Code:

int main()
{
try{
int y = 0;
int x = 2/y;
}
catch(...)
{
cout<<"catch it"<<endl;
}
return 0;
}

If you try, you will find out that catch(...) couldn't catch exception divided by zero. How'd we catch such exceptions?

View 4 Replies View Related

Visual C++ :: How To Handle Open Document

Oct 11, 2012

I have an MFC program created from the app wizard. It is an MDI program, reading/writing text files using Serialize. I can read the document and know that the entire document was read into my buffer without any errors. This was verified by compaing the number of bytes read with the file length.

How do I get the document to display in my main/child window?

How do I read the document from the window so I can save it back to the file?

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved